Skip to content

Instantly share code, notes, and snippets.

@ToJans
ToJans / phonenumbers.hs
Last active Sep 11, 2015 — forked from mathiasverraes/phonenumbers.hs
Phone Number Kata
View phonenumbers.hs
-- Given a list of phone numbers, determine if it is consistent.
-- In a consistent phone list no number is a prefix of another. For example:
-- Bob 91 12 54 26
-- Alice 97 625 992
-- Emergency 911
-- In this case, it is not possible to call Bob because the phone exchange
-- would direct your call to the emergency line as soon as you dialled the
-- first three digits of Bob's phone number. So this list would not be consistent.
module PhoneList(isConsistent) where
View FutureOfEventReader.cs
using System;
using System.Collections.Generic;
using System.Linq;
using AggregateSource;
namespace TheStuff
{
class Program
{
static void Main()
@ToJans
ToJans / ring.erl
Created Oct 23, 2012 — forked from stiiifff/ring.erl
Erlang process ring (Erlang programming, Chapter 4, Ex 4.2)
View ring.erl
-module (ring).
-export ([start/3, first_proc/3, first_loop/4, proc_start/3, proc_loop/2]).
start(MsgCount, ProcCount, Msg) ->
spawn(ring, first_proc, [MsgCount, ProcCount, Msg]).
first_proc(MsgCount, ProcCount, Msg) ->
io:format("First process ~w created, setting up the rest of the ring ...~n", [self()]),
NextPid = spawn(ring, proc_start, [self(), self(), ProcCount-1]),
LastPid = receive
View ConsoleSpinner.cs
using System;
namespace Spinner
{
class Program
{
static void Main(string[] args)
{
Console.Write("Working... ");
int spinIndex = 0;
@ToJans
ToJans / console.erl
Created Oct 2, 2012
Attempt for CQRS in erlang
View console.erl
Erlang R13B04 (erts-5.7.5) [smp:8:8] [rq:8] [async-threads:0]
Eshell V5.7.5 (abort with ^G)
1> cd('/blah/erlang/CQRS').
C:/blah/erlang/CQRS
ok
2> ls().
item.erl item.hrl
ok
3> c(item).
@ToJans
ToJans / getUserMedia.html
Created Dec 8, 2011 — forked from tomayac/getUserMedia.html
navigator.getUserMedia Test
View getUserMedia.html
<html>
<head>
<title>navigator.getUserMedia() Demo</title>
</head>
<body>
<h1>See yourself?</h1>
If your browser supports
<span style="font-family:monospace;">navigator.getUserMedia()</span>
you should see yourself below. If you don't see yourself, try
downloading the
@ToJans
ToJans / gist:1014127
Created Jun 8, 2011 — forked from kristofclaes/gist:1008780
Retrieving next and previous records with Simple.Data
View gist:1014127
// Checked blog at http://blog.markrendle.net/2011/05/23/simple-data-0-6-5/
// and code at https://github.com/markrendle/Simple.Data/blob/master/Simple.Data/SimpleQuery.cs
int? previousPhotoId = DB.Photos.Query()
.Select(DB.Photos.Id)
.Where(DB.Photos.Published == true && DB.Photos.DatePublished < currentPhoto.DatePublished.Value)
.OrderByDatePublishedDescending()
.ToScalarOrDefault<int?>();
int? nextPhotoId = DB.Photos.Query()
View NancyFixture.cs
public class BrowserFixture
{
private readonly Browser browser;
public BrowserFixture()
{
var bootstrapper =
new FakeDefaultNancyBootstrapper();
this.browser = new Browser(bootstrapper);
View UmbracoRazorLogin.cshtml
@using System.Web
@using System.Web.Security
<style type="text/css">
p,label {color:black;}
</style>
@{
// just refactored things a bit
var flashmessage = Request["flash"];
@ToJans
ToJans / 0.Specs.cs
Created Mar 3, 2011 — forked from thecodejunkie/ConNegModule.cs
The current implementation is a bit ugly, but this could become an easy to use content provider for the NancyFx framework
View 0.Specs.cs
using System;
using System.Collections;
namespace CG2.FluentContent
{
// note that I currnelty do not have any testing libs or Nancy available
public class ContentProviderSpecs
{
public void A_content_provider_should_respond_to_available_content_types()
{