Skip to content

Instantly share code, notes, and snippets.

@bennage
bennage / app.html
Created December 8, 2012 02:15
bootstrapping my game
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>sidera</title>
<link href="/css/default.css" rel="stylesheet" />
<script src="requestAnimationFrameShim.js"></script>
<script src="bootstrap.js"></script>
public class SomeClass {
public void SomeMethod() {
this.Log().Info(() => "Here is a log message with params which can be in Razor Views as well: '{0}'".FormatWith(typeof(SomeClass).Name));
}
}
@gregoryyoung
gregoryyoung / gist:1500720
Created December 20, 2011 08:00
Greg's Stop Loss Kata
Greg's Stop Loss Kata
Testing is very hard when time is involved ...
A trailing stop loss is a term used in financial trading. For a very in depth explanation you can read here http://www.investopedia.com/articles/trading/03/080603.asp and http://en.wikipedia.org/wiki/Order_(exchange)#Stop_orders
However we do not need a huge amount of background in order to do the kata as we are going to limit the problem a bit.
The general idea is that when you buy into a stock at a price say $10. You want it to automatically get sold if the stock goes below $9 (-$1). If we use the term "trailing" that means that id the price goes up to $11 then the sell point becomes $10.
anonymous
anonymous / mapping.cs
Created October 1, 2011 07:08
NH 3.2 core mapping
//mapping
public class EntityMapping<T> : ClassMapping<T> where T : IEntity
{
public EntityMapping()
{
DynamicInsert(true);
DynamicUpdate(true);
Lazy(false);
Id(x => x.Id, mapper => mapper.Generator(Generators.Identity));
}
using System;
using System.IO;
using System.Net;
using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Linq;
namespace NodeSharp
{
class Program
@abdullin
abdullin / RedirectToWhen.cs
Created June 26, 2011 08:59
Static helper class for invoking handling methods on AR and AR state.
// snippet is for http://abdullin.com/journal/2011/6/26/event-sourcing-a-la-lokad.html
// simple helper, that looks up and calls the proper overload of
// When(SpecificEventType event). Reflection information is cached statically
// once per type.
public static class RedirectToWhen
{
static class Cache<T>
{
public static readonly IDictionary<Type, MethodInfo> Dict = typeof(T)
anonymous
anonymous / LINQCount.cs
Created June 16, 2011 07:59
public static int Count<TSource>(this IEnumerable<TSource> source) {
if (source == null) {
throw Error.ArgumentNull("source");
}
var collectionT = source as ICollection<TSource>;
if (collectionT != null) {
return collectionT.Count;
}
var collection = source as ICollection;
if (collection != null) {
@ToJans
ToJans / 0.Specs.cs
Created February 16, 2011 16:19
An a attempt for a message-less CQRS setup (the idea is messages being generated by the proxy) (CQRS gen2)
using System;
namespace CG2.ExamplePOC
{
public class WithDrawCashContext : WithDrawCashHandler
{
protected Guid CardId = Guid.NewGuid();
protected Guid AccountId = Guid.NewGuid();
protected Guid AtmId = Guid.NewGuid();
}