Skip to content

Instantly share code, notes, and snippets.

@couchand
couchand / .block
Last active November 26, 2018 22:03 — forked from mbostock/.block
Interactive Stereographic
license: gpl-3.0
@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 / 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 / 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 / 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 / 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 / react-d3.js
Created March 5, 2014 16:02
Integrating D3 charts into React.js applications
/** @jsx React.DOM */
// d3 chart function
// note that this is a higher-order function to
// allowing passing in the component properties/state
update = function(props) {
updateCircle = function(me) {
me
.attr("r", function(d) { return d.r; })
.attr("cx", function(d) { return 3 + d.r; })
#!/bin/sh
sed 's/\B\w*//g;s/\s//g' full_file.txt > acronym_file.txt
@couchand
couchand / README.md
Last active November 9, 2017 21:52 — forked from mbostock/.block
Link nodes to avoid node/link overlap

This gist demonstrates the inserting of link nodes to avoid node/link overlap.



This simple force-directed graph shows character co-occurence in *Les Misérables*. A physical simulation of charged particles and springs places related characters in closer proximity, while unrelated characters are farther apart. Layout algorithm inspired by [Tim Dwyer](http://www.csse.monash.edu.au/~tdwyer/) and [Thomas Jakobsen](http://web.archive.org/web/20080410171619/http://www.teknikus.dk/tj/gdc2001.htm). Data based on character coappearence in Victor Hugo's *Les Misérables*, compiled by [Donald Knuth](http://www-cs-faculty.stanford.edu/~uno/sgb.html).