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 RelationManagementExtensions | |
{ | |
[ThreadStatic] | |
private static bool inAddToParentCall; | |
[ThreadStatic] | |
private static readonly ICollection<Tuple<object,object>> InChildAction = new HashSet<Tuple<object, object>>(); | |
public static TParent AddToParent<TChild, TParent>(this TParent parent, TChild child, Func<Action<TChild>> addToParentAction) where TParent:class | |
{ | |
try |
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
.gist .gist-file .gist-data .gist-highlight pre{ | |
font-family: "Consolas", "Courier New", Courier, "Bitstream Vera Sans Mono", monospace; | |
} |
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.Diagnostics; | |
using System.IO; | |
using Db4objects.Db4o; | |
using Db4objects.Db4o.Config; | |
namespace Gamlor.Db4oForum | |
{ | |
class RunBenchmark |
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 Program | |
{ | |
private static void Main(string[] args) | |
{ | |
File.Delete("tmp.db4o"); | |
using (var db = OpenDB()) | |
{ | |
var usr = new User(); | |
db.Store(usr); |
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
// ==UserScript== | |
// @name YoutubeProtectionRemover | |
// @include http://www.youtube.com/* | |
// @description Removes lame protection on YouTube | |
// @copyright 2010, Snap | |
// ==/UserScript== | |
window.opera.addEventListener( | |
'BeforeScript', | |
function (ev){ |
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
Action workItem = () => | |
{ | |
throw new ExpectedExeption(); | |
}; | |
var syncHandle = workItem.BeginInvoke(null, null); | |
// later | |
try | |
{ | |
workItem.EndInvoke(syncHandle); | |
}catch (ExpectedExeption e) |
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
// Even a cast generates a warning | |
List<MyClass> data = (List<MyClass>) legacyLibraryCall(); |
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 BootsTrapper { | |
private final static String APPLICATION_PATH = "./application"; | |
private final static String APPLICATION_MAIN = "info.gamlor.application.ApplicationMain"; | |
public static void main(String[] args) { | |
final File file = new File(APPLICATION_PATH); | |
try { | |
tryStartUp(file,args); | |
} catch (Exception e) { | |
System.err.println("Unexpected exception'" + file + "'."); |
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 MyPrimitiveSynchronisationContext : SynchronizationContext | |
{ | |
private readonly Queue<Action> messagesToProcess = new Queue<Action>(); | |
private readonly object syncHandle = new object(); | |
private bool isRunning = true; | |
public override void Send(SendOrPostCallback codeToRun, object state) | |
{ | |
throw new NotImplementedException(); | |
} |
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 string AwesomeBusinessOperation() | |
{ | |
var firstPart = TakesALongTimeToProcess("Tons"); | |
var secondPart = TakesALongTimeToProcess(firstPart+" of "); | |
var result = TakesALongTimeToProcess(secondPart+"money"); | |
return result; | |
} | |
private string TakesALongTimeToProcess(string word) | |
{ |
OlderNewer