Skip to content

Instantly share code, notes, and snippets.

@Dervall
Dervall / Crashy
Created May 29, 2013 12:12
Compiler! Why you not work...
class A<T>
{
public virtual T X() { return default(T); }
}
class B : A<int>
{
public override int X()
{
Func<int> x = () => base.X();
@Dervall
Dervall / gist:3979248
Created October 30, 2012 09:32
Stupid parsing
var configurator = ParserFactory.Configure<object>();
var price = configurator.CreateTerminal("[0-9]+,[0-9]* ", s => double.Parse(s.Substring(0, s.Length - 1)));
var unknownText = configurator.CreateTerminal("((-|[A-Öa-ö])[^\n]+)|[0-9]+,[0-9]*kr[^\n]*\n", s => s);
var reciept = configurator.CreateNonTerminal();
var recieptLine = configurator.CreateNonTerminal();
reciept.AddProduction(reciept, recieptLine);
reciept.AddProduction(recieptLine);
@Dervall
Dervall / gist:2292142
Created April 3, 2012 13:48
Making Quartz .NET work with a separate configuration file
Stuff this into your start method
// Configure the Scheduler
ISchedulerFactory schedFact = new StdSchedulerFactory();
// get a scheduler
IScheduler sched = schedFact.GetScheduler();
sched.Start();
Add to app config
@Dervall
Dervall / gist:2001447
Created March 8, 2012 15:13
I so can remember this: Count lines of code
This counts the number of lines in CS files.
find . -name '*.php' | xargs wc -l
@Dervall
Dervall / IHideObjectMembers.cs
Created February 22, 2012 11:42
Removing intellisense in fluent interfaces
[EditorBrowsable(EditorBrowsableState.Never)]
public interface IHideObjectMembers
{
[EditorBrowsable(EditorBrowsableState.Never)]
Type GetType();
[EditorBrowsable(EditorBrowsableState.Never)]
int GetHashCode();
[EditorBrowsable(EditorBrowsableState.Never)]