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
class ExceptionTest | |
{ | |
long maxLevel = 20; | |
static void Main(string[] args) | |
{ | |
ExceptionTest test = new ExceptionTest(); | |
int count = 10000; | |
Stopwatch sw = new Stopwatch(); | |
sw.Start(); |
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
/****************************************************************************** | |
Module: Wintellect.cs | |
Notices: Copyright (c) 2008-2009 Jeffrey Richter | |
******************************************************************************/ | |
using System; | |
using System.ComponentModel; | |
using System.Diagnostics; | |
using System.Runtime.InteropServices; |
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 CodeTimer | |
{ | |
public static void Initialize() | |
{ | |
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; | |
Thread.CurrentThread.Priority = ThreadPriority.Highest; | |
Time("", 1, () => { }); | |
} | |
public static void Time(string name, int iteration, Action action) |
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
/// <summary> | |
/// Determines the size of the object or struct created and returned by the | |
/// specified method. </summary> | |
/// <remarks>Should not be used in production! This is meant for use during | |
/// development, not as a general purpose sizeof function.</remarks> | |
/// <param name="maker">The method that creates and returns the object or | |
/// struct whose size will be determined.</param> | |
/// <returns>The size in bytes of the object created by the method.</returns> | |
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] | |
public long ByteSize<T>(Func<T> maker) |
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
class Program | |
{ | |
private readonly Dictionary<Foo, int> dict = new Dictionary<Foo, int>(); | |
private readonly List<Data> data = new List<Data>(); | |
static void Main(string[] args) | |
{ | |
Program p = new Program(); | |
var foo = new Foo(1); | |
//foo.GetHashCode(); //this will cache hashcode in foo, but data.Foo is another object... |
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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Sin1 sin11 = new Sin1(); | |
//4 core-cpu | |
Thread t1 = new Thread(sin11.DoWork); | |
Sin1ThreadParam p1 = new Sin1ThreadParam(0); | |
Thread t2 = new Thread(sin11.DoWork); | |
Sin1ThreadParam p2 = new Sin1ThreadParam(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
public static class WeakEventHandler { | |
private class WeakEventHandlerImpl { | |
protected readonly WeakReference m_wrTarget; // WeakReference to original delegate's target object | |
protected Delegate m_openEventHandler; // "Open" delegate to invoke original target's delegate method | |
public WeakEventHandlerImpl(Delegate d) { m_wrTarget = new WeakReference(d.Target); } | |
// Match is used to compare a WeakEventHandlerImpl object with an actual delegate. | |
// Typically used to remove a WeakEventHandlerImpl from an event collection. | |
public Boolean Match(Delegate strongEventHandler) { |
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
Full-screen mode - Alt + Shift + Enter | |
Quick Lauch - Ctrl + Q | |
Search Solution Explorer - Ctrl + ; | |
Opens the menu on a class that isn't recognized and gives you import options - Alt + Shift + F10 | |
Comment lines - Ctrl + K, Ctrl + C | |
Uncomment lines - Ctrl + K, Ctrl + U |
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
#!/usr/bin/env ruby | |
# 1. export your RIL bookmarks | |
# 2. save this file to the same directory where your ril_export.html is | |
# 3. change username and password in the script bellow | |
# 4. run 'ruby ril_to_instapaper.rb' in terminal | |
require "cgi" | |
require "net/http" | |
require "net/https" |
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.Expressions; | |
using System.Reflection; | |
namespace Bleroy.Helpers { | |
public static class NotNull { | |
public static TProp Get<TSource, TProp>(this TSource source, Expression<Func<TSource, TProp>> property) where TSource : class { | |
if (source == null) return default(TProp); | |
var current = property.Body; |
OlderNewer