This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(trees). | |
-export([build_tree/1]). | |
%% @doc Builds a (proplist-based) tree from a proplist where each key | |
%% is a list of keys. | |
build_tree(Proplist) -> | |
build_tree(Proplist, []). | |
build_tree([], Tree) -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo_tests() -> | |
{foreach, | |
fun setup/0, | |
fun teardown/1, | |
[{"Should do something", | |
do_something()}]}. | |
setup() -> | |
Mods = [foo, bar], | |
meck:new(Mods), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'open-uri' | |
require 'json' | |
require 'pp' | |
# Some example URLs; | |
# http://hypem.com/playlist/loved/JohnyTex/json/1/data.js | |
# http://hypem.com/playlist/popular/3day/json/1/data.js | |
# http://ws.spotify.com/search/1/track.json?q=little%20talks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The classic for-loop | |
var strings = ['1', '2', '3'], | |
numbers = []; | |
for (var i = 0; i < strings.length; i++) { | |
var number = parseInt(strings[i]); | |
numbers.push(number); | |
} | |
// numbers == [1, 2, 3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
/* | |
TODO: Support more join types? | |
TODO: Support single key? | |
*/ | |
var crossProduct = function(objects1, objects2) { | |
var objects = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# USAGE: | |
# | |
# json-to-csv [filename] | |
# | |
# This script takes a JSON array of objects as its input and outputs | |
# the data as CSV to STDOUT. The JSON array can be fed to the | |
# script either via STDIN or by supplying a filename as an argument. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Quick sketch / spec for how a JSQL module might work | |
var people = [{ | |
'name': 'Mary Jane Watson', | |
'job': 'Actress', | |
'alignment': 'Good', | |
'age': 23 | |
}, { | |
'name': 'Peter Parker', | |
'job': 'Photographer', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Reads JSON from a file or STDIN and outputs CSV to STDOUT. | |
import fileinput | |
import json | |
import sys | |
import csv | |
jsonstr = '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
OUTPUT=/tmp/$(basename $1).html | |
markdown $1 > $OUTPUT | |
open $OUTPUT | |
# FIXME: This is a hack to prevent deleting the file before it's opened. | |
# Is it possible to use `wait` instead? | |
sleep 1 | |
rm $OUTPUT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# Interactively remove branches not in remote, *by name*. This is | |
# useful for pruning branches that were rebased prior to merging, | |
# since those branches will not show up in `git branch --merged`. | |
# List local branches which may have been merged | |
remotes = `git branch -r`.split.map {|x| x.sub('origin/', '') } | |
locals = `git branch`.split.select {|x| x != '*' } | |
complement = locals.select {|x| not (remotes.include? x) } |
OlderNewer