Skip to content

Instantly share code, notes, and snippets.

@couchand
couchand / factorial.coffee
Created March 13, 2014 05:40
The Little CoffeeScripter
# the little coffeescripter
# http://weblog.bocoup.com/little-javascripter-revisited/
Y = (le) ->
((f) -> f f) (f) ->
le (args...) ->
f(f) args...
factorial =
Y (f) ->
@couchand
couchand / README.markdown
Created July 10, 2014 14:11
Some fun FIFA pairings

These were selected from the 43,472 possible FIFA pairings by comparing their bigrams (sequences of pairs of letters) to the frequencies observed in Google Books N-grams dataset. The algorithm could probably be improved by weighting the middle pair greater (since that's the only degree of freedom), normalizing for letter frequency, increasing the analysis to trigrams or further, etc.

Code forthcoming.

@couchand
couchand / Program.cs
Last active August 29, 2015 14:11
Jil Deserialization reduced test case
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Jil;
namespace JilDeserializeIssue
{
public enum SelectionAlgorithm : int
@couchand
couchand / Immutable.tt
Created June 19, 2015 19:40
Generate an immutable data structure with a T4 template
<#@ template language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#
var name = "Badge";
var fields = new Dictionary<string, string>{
{ "UserId", "string" },
@couchand
couchand / flatten.coffee
Last active December 12, 2015 04:39
flatten an array
# Let's set up a quick and dirty test framework
# a helper to define the tests
expect = (expected, input) ->
[expected, input]
# an array equivalence test
areSameArrays = (left, right) ->
return no unless left.length is right.length
for i of left
@couchand
couchand / flare.json
Last active December 16, 2015 21:49 — forked from mbostock/.block
{
"name": "flare",
"children": [
{
"name": "analytics",
"children": [
{
"name": "cluster",
"children": [
{"name": "AgglomerativeCluster", "size": 3938},
@couchand
couchand / isogram.js
Created May 10, 2013 14:41
Google Analytics new tracking code
(function(i,s,o,g,r,a,m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
( i[r].q = i[r].q || [] ).push(arguments)
},
i[r].l = 1 * new Date();
a = s.createElement(o),
@couchand
couchand / index.html
Last active December 22, 2015 01:49 — forked from njvack/LICENSE
Voronoi-based point picker (experiment inverting the draw and clip paths)
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js"></script>
</head>
<body>
<div id="chart">
</div>
<script type="text/javascript">
var w = 960,
@couchand
couchand / index.html
Created August 31, 2013 16:19
Draggable clip path
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.min.js"></script>
</head>
<body>
<div id="chart">
</div>
<script type="text/javascript">
var w = 800,
h = 600,