Archive for February, 2009


Mounting an ISO file..

Feb 25, 2009 in Linux

sudo mount -o loop /path/to/file.iso /somedir
ls /somedir

Pointers in C# (CSharp) .. example with bits..

Feb 12, 2009 in .Net, Microsoft

// 32 bit source Bitmap
System.Drawing.Bitmap b

int bWidth, bHeight;
int idx = 0;

bWidth = b.Width;
bHeight = b.Height;

byte[,] Disp = new byte[bWidth, bHeight];

// create a new 16 bit bitmap
Bitmap b565 = new Bitmap(b.Size.Width,b.Size.Height,System.Drawing.Imaging.PixelFormat.Format16bppRgb565);

Graphics g = Graphics.FromImage(b565);
// draw the 32 bit source bitmap to the 16 bit bitmap
g.DrawImage(b, new Point(0, 0));

BitmapData bmd = b565.LockBits(new Rectangle(0, 0, 480, 272), System.Drawing.Imaging.ImageLockMode.ReadOnly, b565.PixelFormat);

byte[] Result = new byte[bWidth * bHeight * 2];

   // get a pointer to the beginning of image data in the 16 bit bitmap
   byte* bitdata = (byte*)bmd.Scan0;

   for (int y = 0; y < bmd.Height*bmd.Width*2; y++)
       // just copy the image data from the Bitmap to the byte array
       Result[y] = bitdata[y];

USBD480_DrawFullScreen(ref di, Result);

gnu make pattern ..

Feb 12, 2009 in Software

Make multiple sources into targets..

.SUFFIXES: .htm .htmt

SRCS := $(wildcard *.htmt)
TARGS := $(patsubst %.htmt, %.htm, ${SRCS})

all : $(TARGS)
	echo "-- done --"

%.htm : %.htmt
	cpp $< | egrep -v '^\#' > $@

Design Patterns with Java – Summary ..

Feb 10, 2009 in Engineering, Software


  • Design patterns describe how objects communicate without becoming
    entangled in each other’s data models and methods.
    In other words, they describe methods for keeping objects decoupled.
  • Program to an interface and not to an implementation.
  • Favor object composition over inheritance.

Creational Patterns

All of the creational patterns deal with the best way to create
instances of objects. This is important because your program should not
depend on how objects are created and arranged.

  • The Factory Method provides a simple decision making class that
    returns one of several possible subclasses of an abstract base class
    depending on the data that are provided.
  • The Builder Pattern separates the construction of a
    complex object from its representation, so that several different
    representations can be created depending on the needs of the
  • The Singleton Pattern is a class of which there can be no more
    than one instance. It provides a single global point of access to that

Structural Patterns

Structural patterns describe how classes and objects can be combined
to form larger structures. The difference between class patterns and object
patterns is that class patterns describe how inheritance can be used to provide
more useful program interfaces. Object patterns, on the other hand, describe
how objects can be composed into larger structures using object composition,
or the inclusion of objects within other objects.

  • The Adapter pattern is used to convert the programming interface of
    one class into that of another. The source interface is different than the target.
  • The Decorator pattern provides us with a way to modify the behavior
    of individual objects without having to create a new derived class.
    i.e. Add features to a class without inheritance and at runtime.
  • The Façade pattern allows one to simplify complexity by
    providing a simplified interface to complex subsystems.
    i.e. It is an aggregation mechanism.
  • The Flyweight design pattern provides an approach for handling
    many small objects (like characters in a font, for example).
  • The Proxy pattern is used when you need to represent a complex
    object by a simpler one. Used to interface to expensive-to-create
    objects. The source interface side of a proxy is the same as the
    target class (see Adapter).

Behavioral Patterns (page 129)

Behavioral patterns are those patterns that are most specifically
concerned with communication between objects.

  • The Observer pattern defines the way a number of classes can be notified
    of a change. i.e. subscribe and publish.
  • The Strategy pattern encapsulates an algorithm inside a class.
  • The Iterator pattern formalizes the way we move through a list
    or collection of data within a class using a standard interface.
    Enumerators are read-only Iterators.
  • Observer pattern..
  • MVC – Revisit:
  • The Strategy pattern
  • Visitor – revisit: