Skip to content

Instantly share code, notes, and snippets.

View chreke's full-sized avatar
💭
Just catching up on some reading

Christoffer Ekeroth chreke

💭
Just catching up on some reading
View GitHub Profile
@chreke
chreke / underscore.join.js
Last active December 22, 2015 16:48
SQL-like "join" function as an underscore.js mixin
(function () {
/*
TODO: Support more join types?
TODO: Support single key?
*/
var crossProduct = function(objects1, objects2) {
var objects = [];
@chreke
chreke / gist:6382345
Last active December 21, 2015 23:29
js examples
// 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]
@chreke
chreke / gist:6181891
Created August 8, 2013 06:10
hypem.rb, a script that will turn HypeMachine playlists into Spotify playlists, eventually
#!/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
@chreke
chreke / eunit_and_meck.erl
Created December 5, 2012 21:48
Eunit and Meck test skeleton
foo_tests() ->
{foreach,
fun setup/0,
fun teardown/1,
[{"Should do something",
do_something()}]}.
setup() ->
Mods = [foo, bar],
meck:new(Mods),
@chreke
chreke / trees.erl
Created November 23, 2012 08:14
Build tree from proplist with list keys
-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) ->