Skip to content

Instantly share code, notes, and snippets.

View chribben's full-sized avatar

Christian Jacobsen chribben

View GitHub Profile
[STAThread]
static void Main()
{
_nui = new Runtime();
var app = new Application();
var window = new Window();
InitializeNui(); //Initializing the Runtime object and opening video streams
CreateGUI(window); //Setting up a canvas to hold the RGB video and the image attached to the hand of captured person
var skeletonFrameReadyObservable = Observable.FromEventPattern(_nui, "SkeletonFrameReady");
var trackedSkeletons = from ev in skeletonFrameReadyObservable
@chribben
chribben / FailingMTUnitTest.cs
Created January 14, 2012 20:55
Failing MT unit test
[Scenario]
public class Test_Bus_Subscriptions_For_Consumers_In_Dummy_Saga_Using_Castle_As_IoC :
Given_a_service_bus_instance
{
readonly IWindsorContainer _container;
public Test_Bus_Subscriptions_For_Consumers_In_Dummy_Saga_Using_Castle_As_IoC()
{
_container = new WindsorContainer();
_container.Register(
@chribben
chribben / EventsNotPublishedUsingMT.cs
Created February 1, 2012 21:19
Events that aren't published
//Test
[TestFixture]
public class TestSendMessageReceiveEvent
{
private IWindsorContainer _container;
private readonly Guid _aggregateId = Guid.NewGuid();
private static readonly ILog _Logger = LogManager.GetLogger(typeof (TestSendMessageReceiveEvent));
private readonly ManualResetEvent _received = new ManualResetEvent(false);
public TestSendMessageReceiveEvent()
@chribben
chribben / TestSendReceive_using_MT_No_IoC.cs
Created February 12, 2012 22:36
Quantum.TestSendReceive w/o IoC
[TestFixture]
public class TestSendMessageReceiveEventNoIoC
{
private readonly Guid _aggregateId = Guid.NewGuid();
private static readonly ILog Logger = LogManager.GetLogger(typeof (TestSendMessageReceiveEvent));
private readonly ManualResetEvent _received = new ManualResetEvent(false);
public TestSendMessageReceiveEventNoIoC()
{
BasicConfigurator.Configure();
@chribben
chribben / Luhn.fsx
Created March 30, 2012 19:27
Luhn implementation F#
let luhn (inp:string) =
let algo (s:string) =
Regex.Replace(s, "[^0-9]", "").ToCharArray()
|> Array.rev
|> Seq.map(int << string)
|> Seq.fold (fun (fldr,weight) num -> fldr + (num * weight) / 10 + (num * weight) % 10, weight % 2 + 1) (0,2)
|> fst
match inp with
| "" -> 0
| _ -> 10 - (algo inp) % 10
@chribben
chribben / sum.fs
Created May 1, 2012 21:37
F# implementation of list sum
let rec sum list =
match list with
| [] -> 0;
| h::t -> h + sum t
@chribben
chribben / async.js
Created May 26, 2012 21:46
Async in jQuery with nested $.when
function A(){
promises1 = new Array();
promises2 = new Array();
for (var i = start; i < end; i++)
{
B(someUri);
}
await();
}
@chribben
chribben / TailRecursiveSolution.fsx
Created May 31, 2012 22:39
FuncProgSTHLM challenge
//Challenge https://groups.google.com/group/functional-programming-sthlm/browse_thread/thread/647165dc2d923529?hl=sv
// The record type Part
type Part = {
Heading : string;
Text : string;
IsColumnLayout : bool;
}
// Make some test data
let r = { Heading="Wide part"; Text="This is a wide part"; IsColumnLayout=false }
@chribben
chribben / Buildlists.fs
Created July 21, 2012 21:17
Build lists using append and cons
let rec buildAppend (lst:int list) num =
if lst.Length < 30000 then
buildAppend (lst @ [num]) num
else
lst
let rec buildCons (lst:int list) num =
if lst.Length < 30000 then
buildCons (num::lst) num
@chribben
chribben / fibo.fsx
Created July 21, 2012 21:19
Fibonacci
let fibonacci =
seq{yield 0
yield 1
yield 1
let rec fibo a b =
seq{yield (a + b)
yield! fibo b (a+b)}
yield! fibo 1 1 }