Showing posts from September, 2009

Asp.NET redirect


Umbraco C# Open Source CMS Installation

Install IIS on your windows machine if it’s not there yetControl Panel
Add or Remove Programs
Add/Remove Windows Components (on the left)Install SQL Server Express EditionMake the following changes after the installationSQL Server Configuration Manager Go to SQL Native Client Configuration/Client Protocols and Enable TCP/IP & Named Pipes SQL Server Surface Area Configuration Go to Surface Configuration for Services and Connections/Database Engine/Remove Connections and set remote connections to TCP/IP and Named Pipes SQL Server Management Studio Right click on top node (database name) and go to Properties/Security and set Server Authentication to SQL Server and Windows Authentication mode (mixed mode) Enable sa account (temporarily, only for Umbraco installation). Go to Security/Logins, right click on sa account choose Properties. On General Page set password (if not set yet) and on Status Page set Login to Enabled. Install XP PRO IIS AdminAllows to…

Open command line from context menu

This is the x64 version of Open Command Windows Here from PowerToys for Windows XPCreate .reg file with this script and execute it.Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\Command Prompt] @="Open Command Window Here" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\Command Prompt\command] @="Cmd.exe /k pushd %L"

Open cygwin command line from context menu

This script will add extra option to context menu to open cygwin command line. Create .reg file with this script and execute it.

Windows x86 REGEDIT4

@="&Open Cygwin Window Here"

@="c:\\cygwin\\bin\\bash.exe --login -c \"cd '%1' ; exec /bin/bash -rcfile ~/.bashrc\""

@="&Open Cygwin Window Here"

@="c:\\cygwin\\bin\\bash.exe --login -c \"cd '%1' ; exec /bin/bash -rcfile ~/.bashrc\"" Windows x64 Windows Registry Editor Version 5.00

@="&Open Cygwin Window Here"

@="c:\\Development\\tools\\Cygwin\\bin\\bash.exe --login -c \"cd '%1' ; exec /bin/bash -rcfile ~/.bashrc\"&q…

SQL Server Copy Table

This SQL will create another table from the select statementSELECT *
INTO table2
FROM table1

C# LoopFileSystemWatcher

This is another implementation of FileSystemWatcher as FileSystemWatcher doesn’t work in all cases.publicclass LoopFileSystemWatcher
public delegate void LoopFileSystemEventHandler(object source, LoopFileSystemEvent e);
public event LoopFileSystemEventHandler created;

readonly List<string> fileCache = new List<string>();

private readonly string folderPath;
private readonly string fileFilter;
private readonly int checkFrequency;

private bool cancelled = false;

public LoopFileSystemWatcher(string folderPath, string fileFilter, int checkFrequency)
this.folderPath = folderPath;
this.fileFilter = fileFilter;
this.checkFrequency = checkFrequency;

DirectoryInfo dir = new DirectoryInfo(folderPath);
foreach (FileInfo filein dir.GetFiles(fileFilter))

public void Wait(int waitSeconds)
Thread t = new Thread(delegate() { WaitThread(waitSeconds,false); });

C# Pub/Sub example

publicclass PubSub
readonly Queue<string> queue = new Queue<string>();

object locker = newobject();

public string Subscribe()
string text;
lock (locker)
while(queue.Count== 0)
text = queue.Dequeue();
return text;

public void Publish(string request)
lock (locker)
class Program
Random r = new Random();

public Program()
PubSub pubSub = new PubSub();

Thread t1 = new Thread(delegate() { Publish(pubSub); });
Thread t2 = new Thread(delegate() { Subscribe(pubSub); });





void Publish(PubSub pubSub)
for (int i = 1; i <= 10; i++)