Skip to content

Instantly share code, notes, and snippets.

# Context manager to generate batches in the background via a process pool
# Usage:
#
# def batch(seed):
# .... # generate minibatch
# return minibatch
#
# with BatchGenCM(batch) as bg:
# minibatch = next(bg)
# .... # do something with minibatch
@creationix
creationix / run.js
Last active March 7, 2017 18:36
universal callback/continuable/thunk generator runner
function run(generator) {
// Pass in resume for no-wrap function calls
var iterator = generator(resume);
var data = null, yielded = false;
next();
check();
function next(item) {
var cont = iterator.next(item).value;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@FrancescAlted
FrancescAlted / simple-key-store.py
Created January 14, 2016 12:54
A demonstration of a simple key-value store using numpy (.npz) and bcolz (ctable)
# Benchmark to compare the times for storing numpy arrays in a key-value.
# The main point is to compare numpy serialization vs a bcolz approach.
from __future__ import print_function
import sys
import os
import os.path
import subprocess
import getopt
@paulusm
paulusm / ipython.conf
Created January 19, 2013 21:22
Upstart conf for iPython web
start on runlevel [2345]
stop on runlevel [016]
respawn
setuid <user>
chdir /home/<user>/ipython_notebooks
exec ipython notebook --pylab --profile=nbserver --ipython-dir=/home/<user>/.ipython --log-level=DEBUG
@buritica
buritica / glossy.html
Last active August 29, 2015 14:01
Glossy JSON Spec
<script>
var namespace = 'onswipe';
var message = JSON.stringify({
view_url: '%%VIEW_URL_UNESC%%',
click_url: '%%CLICK_URL_UNESC%%%%DEST_URL%%',
cachebuster: '%%CACHEBUSTER%%',
glossy_id: 'my_id',
type: 'glossy',
pixels: []
});