Skip to content

Instantly share code, notes, and snippets.

module CheapProcess =
open System.Diagnostics
type Agent<'T> = MailboxProcessor<'T>
type Answer =
Ok
let rec start howMany (pid: Agent<Answer>) =
Agent.Start(fun inbox ->
@digitalBush
digitalBush / Elixir.Foo.beam.erl
Created November 27, 2013 01:36
Shadowing in Elxir and the resulting decompiled Erlang version.
-file("foo.ex", 1).
-module('Elixir.Foo').
-export(['__info__'/1, test/0]).
'__info__'(functions) -> [{test, 0}];
'__info__'(macros) -> [];
'__info__'(docs) -> [{{test, 0}, 2, def, [], nil}];
'__info__'(moduledoc) -> {1, nil};
@digitalBush
digitalBush / DependencyResolverExtensions.cs
Created March 14, 2013 02:15
SignalR scale out via RabbitMQ and ServiceStack.Text
using System;
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Messaging;
using RabbitMQ.Client;
namespace SignalR.RabbitMQ {
public static class DependencyResolverExtensions {
public static IDependencyResolver UseRabbitMq(this IDependencyResolver resolver, ConnectionFactory connectionFactory) {
if (connectionFactory == null) {
@digitalBush
digitalBush / model-sync-specs.js
Last active December 14, 2015 07:09
Preview of KO Model Sync
describe('Model Sync',function(){
var Test=ko.Model.extend({urlRoot:'/Foo'});
describe('When fetching a model', function() {
var model = new Test({id:1}),
parseSpy = sinon.spy(model,"parse");
sinon.stub(jQuery, "ajax")
.returns(jQuery.when({foo:"bar"}));
@digitalBush
digitalBush / gist:2410522
Created April 18, 2012 01:58
F# Luhny Bin
let luhn chars =
let rec luhn even sum digits =
match digits, even with
| [], _ -> sum % 10 = 0
| head :: tail, false when head > 4 -> luhn true (sum + head*2-9) tail
| head :: tail, false -> luhn true (sum + head*2) tail
| head :: tail, true -> luhn false (sum + head) tail
chars
|> List.rev
|> List.map(fun (c:char) -> int c - int '0')
@digitalBush
digitalBush / vowelhistogram.fs
Created November 19, 2011 02:32
Vowel Histogram
let histogram (str:string)=
str.ToCharArray()
|> Seq.map(fun x-> Char.ToLower(x))
|> Seq.filter(fun x-> vowels.IndexOf(x)>=0)
|> Seq.countBy(fun x-> x)