Posts

Showing posts from February, 2010

Mercurial tutorial by ‘Joel Spolsky’

Image

.Net WPF Tutorials

Good set of tutorials about WPF (Windows Presentation Foundation) WPFtutorial.netThis is a good start Learn WPF in two Weeks

How to always browse in Incognito mode with Google Chrome

Image

SQL Server run query from command line

C:\>sqlcmd -SLOCALHOST\SQLEXPRESS -Q "Select 'Hello World'"

C# Sample Cache with timeout

publicenum CacheEventType { ADD, REMOVE } publicclass Cache<K, V> { publicconstint CheckInterval = 1000; privateint _timeoutSeconds; private SortedList<Timeout, K> timeouts = new SortedList<Timeout, K>(); private Dictionary<K, V> items = new Dictionary<K, V>(); private Timer timer; privateobject locker = newobject(); publicdelegatevoid CacheEventHandler(object source, CacheEvent<K, V> e); publicevent CacheEventHandler changed; public Cache(int timeoutSeconds) : this(timeoutSeconds,CheckInterval){} public Cache(int timeoutSeconds, int checkInterval) { this._timeoutSeconds = timeoutSeconds; timer = new Timer(PurgeCache, "Cache", checkInterval, checkInterval); //purge cache } privatevoid PurgeCache(object data) { lock (locker) { for (int i = timeouts.Count - 1; i >= 0; i--) { if (timeouts.Keys[i].IsExpired()) { K key = timeouts.Values[i]; timeouts.RemoveAt(i); V value = items[key…

C# Converting array or List to string

publicvoid Test() { List<string> list = new List<string>(); dogs.Add("One"); dogs.Add("Two"); dogs.Add("Three"); Console.WriteLine(string.Join(",", list.ToArray())); }