Skip to content

Instantly share code, notes, and snippets.

@handloomweaver
handloomweaver / gist:1953185
Created March 1, 2012 20:57 — forked from FestivalBobcats/gist:1323387
Underscore.js implementation of Cartesian Product
function cartesianProductOf(){
return _.reduce(arguments, function(mtrx, vals){
return _.reduce(vals, function(array, val){
return array.concat(
_.map(mtrx, function(row){ return row.concat(val); })
);
}, []);
}, [[]]);
}
@handloomweaver
handloomweaver / gist:2226471
Created March 28, 2012 14:09 — forked from FestivalBobcats/gist:1323387
Underscore.js implementation of Cartesian Product
function cartesianProductOf(){
return _.reduce(arguments, function(mtrx, vals){
return _.reduce(vals, function(array, val){
return array.concat(
_.map(mtrx, function(row){ return row.concat(val); })
);
}, []);
}, [[]]);
}
@handloomweaver
handloomweaver / tlc.lua
Created March 28, 2012 17:49 — forked from fjolnir/tlc.lua
LuaJIT ObjC bridge
-- TLC - The Tiny Lua Cocoa bridge
-- Note: Only tested with LuaJit 2 Beta 9 on x86_64 with OS X >=10.7.3 & iPhone 4 with iOS 5
-- Copyright (c) 2012, Fjölnir Ásgeirsson
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
@media only screen and (min-width: 320px) {
/* Small screen, non-retina */
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 320px),
import time
import networkx as nx
from contextlib import contextmanager
@contextmanager
def hidden(G, nodes=None, edges=None):
if nodes is None:
nodes = []
if edges is None:
edges = []
import time
import networkx as nx
from contextlib import contextmanager
@contextmanager
def hidden_nodes(G, nodes=None):
import types
if nodes is None:
nodes = []
def successors_iter(G,n):
after = (ms, cb) -> setTimeout cb, ms
every = (ms, cb) -> setInterval cb, ms

Now we can say:

after 500, -> # do something...

Instead of:

setTimeout ->

@handloomweaver
handloomweaver / S3 bucket sync
Created February 29, 2016 19:55 — forked from andrewschoen/S3 bucket sync
Python script to sync an S3 bucket to the local file system
# -*- coding: utf-8 -*-
import os
import StringIO
import hashlib
try:
from boto.s3.connection import S3Connection
from boto.s3.key import Key
except ImportError:
raise ImproperlyConfigured, "Could not load Boto's S3 bindings."