Sunday, February 5, 2012

How to execute large SQL file in sql server


sqlcmd -S myServer\instanceName -i C:\myScript.sql

Saturday, February 4, 2012

GNOME Shell Extensions development

In order to develop the GNOME Shell Extensions, a few resources may be extremely helpful:

As the extensions will not be loaded it self when GNOME Shell starts, the extension uid need to be added:
$gsettings set org.gnome.shell enabled-extensions "['LittleRabbit@gosteven.com']"
then 
$gsettings get org.gnome.shell enabled-extensions
it will be there


Few tips for development:

1. See the log and debug information: Press Alt+F2, type lg to open the Looking Glass. P.S. Currently the debug method is logging everything. Actually You can also force a gdb breakpoint from _javascript_ with "global.breakpoint();"
2. Make GNOME Shell reload extensions after modified js files without log out: Press Alt+F2, type r to refresh.  

Sunday, January 29, 2012

mac lion terminal doesn't source profile

I have encountered the problem that my MacBook Pro ~/.profile doesn't been sourced in the terminal.

The solution is simple:
bash first runs /etc/profile. /etc/profile (on Mac OS X 10.6.7) runs path_helper(8) which is where your default paths get set. After that it runs /etc/bashrc which doesn't do much. Once the default configuration is set, it moves on to the user login scripts.

bash looks in your home directory for .bash_profile, .bash_login, and .profile in that order. bash will run the first of these that it finds and stop looking.

So, if you have a .bash_profile in the home directory, the .profile will be ignored. In this case, just append a line in .bash_profile:

$cat "source ~/.profile" >> .bash_profile

Thursday, December 8, 2011

Wednesday, December 7, 2011

Linq calculate average of a list C#

Only one line of code will do it:

List<float> f = new List<float>();
for (int i = 0; i < 10; i++)
{
    f.Add((float)i);
}
float ave = f.Aggregate((acc, cur) => acc + cur) / f.Count;
Console.WriteLine(ave);

Wednesday, November 30, 2011

How to play audio files on a particular soundcard C#

I have been working on playing audio files on particular audio devices for a few days. On windows platform. the [C#]using Microsoft.DirectX.AudioVideoPlayback; only works for the default audio device. We need to work on a lower layer, using DirectShow.

I will post the detail of the implementation a few days later.

Wednesday, November 23, 2011

Get regex matched strings (Regex Capture) C#

Program that uses Match [C#]
using System;
using System.Text.RegularExpressions;

class Program
{
    static void Main()
    {
 // A
 // The input string we are using
 string input = "OneTwoThree";

 // B
 // The regular expression we use to match
 Regex r1 = new Regex(@"One([A-Za-z0-9\-]+)Three");

 // C
 // Match the input and write results
 Match match = r1.Match(input);
 if (match.Success)
 {
     string v = match.Groups[1].Value;
     Console.WriteLine("Between One and Three: {0}",
  v);
 }
    }
}
Output Between One and Three: Two