Thursday, August 25, 2011

C# Invoke particular EventHandler in InvocationList

I am trying to get particular EventHandler get fired.

Event ProjectChanged was hooked by several EventHandlers

public static event EventHandler ProjectChanged;

foreach (var eventHandler in ProjectChanged.GetInvocationList())
    if (eventHandler.Method.Name == "UserContext_ProjectChanged")

String to Guid in C#

public static Guid StringToGUID(string value)
    // Create a new instance of the MD5CryptoServiceProvider object.
    MD5 md5Hasher = MD5.Create();
    // Convert the input string to a byte array and compute the hash.
    byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(value));
    return new Guid(data);

Sunday, August 21, 2011

configure git with color

To display color in the output of git diff, you need to configure git. Try running
$ git config --global color.diff true
to set your $HOME/.gitconfig appropriately.
To enable color for all:
$ git config --global color.ui true

Thursday, August 18, 2011

Popular Command Lines for Linux

The original article are in three parts:

In my post, part_1part_2part_3part_4

I love working in the shell. Mastery of shell lets you get things done in seconds, rather than minutes or hours, if you chose to write a program instead.
In this article I’d like to explain the top one-liners from the It’s a user-driven website where people get to choose the best and most useful shell one-liners.

Wednesday, August 17, 2011

WPF GridViewColumn Width 100 percent

    <GridView ColumnHeaderContainerStyle="{StaticResource CustomHeaderStyle}">
        <GridViewColumn Header="xxx" 
             Width="{Binding RelativeSource={RelativeSource FindAncestor, 
             AncestorType=ListView}, Path=ActualWidth}">

Monday, August 8, 2011

OpenCV material

PYTHON iterate all files in a directory

To iterate through all the files within the specified directory (folder), with ability to use wildcards (*, ?, and [ ]-style ranges), use the following code snippet:
  1. import os
  2. import glob
  4. path = 'sequences/'
  5. for infile in glob.glob( os.path.join(path, '*.fasta') ):
  6.     print "current file is: " + infile
If you do not need wildcards, then there is a simpler way to list all items in a directory:
  1. import os
  3. path = 'sequences/'
  4. listing = os.listdir(path)
  5. for infile in listing:
  6.     print "current file is: " + infile

PYTHON RuntimeError: maximum recursion depth exceeded in cmp

if your python code produces the following error: “RuntimeError: maximum recursion depth exceeded in cmp,” try adding this line to the beginning of your code:
note that python’s default limit is 1000.

Saturday, August 6, 2011


g++ hello-world.cpp -o hello-world \
    -I /usr/local/include/opencv -L /usr/local/lib  \
    -lm -lcv -lhighgui -lcvaux
c++ find_obj.cpp -o o -I /usr/local/include -L /usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann

Monday, August 1, 2011