This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct NotNull<T> | |
{ | |
private T _value; | |
public T Value { | |
get | |
{ | |
return _value; | |
} | |
set | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System.Collections.Generic.Dictionary<int, string> regularDictionary = new System.Collections.Generic.Dictionary<int, string>(); | |
System.Collections.Concurrent.ConcurrentDictionary<int, string> concurrentDictionary = new System.Collections.Concurrent.ConcurrentDictionary<int, string>(); | |
void Main() | |
{ | |
for(int i = 10000; i < 10000000; i *= 10) | |
{ | |
regularDictionary = new System.Collections.Generic.Dictionary<int, string>(); | |
concurrentDictionary = new System.Collections.Concurrent.ConcurrentDictionary<int, string>(); | |
Wrapper(TestRegularDictionaryWrite, i).TotalMilliseconds.Dump(String.Format("milliseconds for {0} regular write", i)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Extensions | |
{ | |
public static Action<TKey, TValue> CurryAddUpdate<TKey,TValue>(this Dictionary<TKey, List<TValue>> dict) | |
{ | |
Action<TKey, TValue> op = (key, val) => { | |
if(dict.ContainsKey(key)) | |
{ | |
dict[key].Add(val); | |
} else { | |
dict.Add(key, new List<TValue>(new TValue[]{val})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($, selector) | |
{ | |
var coll = {}; | |
$(selector).map(function(ei, ev) { | |
if(typeof ev.attributes != "undefined") { | |
$.map(ev.attributes, function(av, ai) { | |
if(!coll[av.name]) coll[av.name] = true; | |
}); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HelloService : Service | |
{ | |
public object NamedMethod(Hello request) | |
{ | |
return new HelloResponse { Result = "Hello, " + request.Name }; | |
} | |
} | |
public class HelloResponse | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
Dictionary<int, int> dict = new Dictionary<int, int>(); | |
Random rndm = new Random(); | |
for(int i = 0; i < 100; i++) | |
{ | |
int foo = rndm.Next(10); | |
dict.AddOrUpdate(foo, 1, (val) => { return val+=1; }); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace OptionalParams | |
{ | |
public class CoolKidsClass | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
namespace ObjectSize | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine(SizeOfInstantiatedObjects()); |