Skip to content

Instantly share code, notes, and snippets.

@jonathana
jonathana / alembic_helper.py
Created November 2, 2016 04:44
Helper functions for the alembic database migration package
""" alembic_helper.py
Copyright (c) 2016 Jonathan M. Altman
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
### Keybase proof
I hereby claim:
* I am jonathana on github.
* I am async_io (https://keybase.io/async_io) on keybase.
* I have a public key whose fingerprint is FAA7 9642 2B31 D4F6 91F6 9E89 335C 076F 41A0 559E
To claim this, I am signing this object:
var fs = require('fs'),
zlib = require('zlib');
var r = fs.createReadStream('file.txt');
var z = zlib.createGzip();
var w = fs.createWriteStream('file.txt.gz');
r.pipe(z).pipe(w);
@jonathana
jonathana / vagrant_useful_functions.sh
Last active May 26, 2020 04:46
Helpful bash command line functions/tab completions for use with vagrant boxes. See http://blog.async.io/2013/01/11/helpful-vagrant-bash-functions-tab-completions for more detail on using this.
# Common directory under which all our servers will live. Set this to where you keep your vagrant servers
export VAGRANT_SERVERS=__SET_THIS_TO_THE_PATH_WHERE_YOUR_VAGRANT_SERVER_SETUPS_ARE
# Grab the subcommands out of the no-arg invocation of vagrant
VAGRANT_SUBCMDS=`vagrant list-commands | awk 'BEGIN { in_subs=0 }; /^$/ { if (in_subs == 0) { in_subs=1; next } }; { if (in_subs) { print $1 } };'`
# FUNCTION: vgt
# PURPOSE: shell "command" to run a vagrant sub-command against a specific VM
# USAGE: vgt _server_name_ _vagrant_subcommand_
# ARGUMENTS:
@jonathana
jonathana / grouplens_evaluator.py
Created June 22, 2011 20:15
"Mahout in Action" Grouplens evaluator sample from section 2.5 ported to jython
import sys, os, glob
from datetime import datetime
sys.path.append(os.environ.get("MAHOUT_CORE"))
for jar in glob.glob(os.environ.get("MAHOUT_JAR_DIR") + "/*.jar"):
sys.path.append(jar)
from org.apache.mahout.common import RandomUtils
from org.apache.mahout.cf.taste.common import TasteException
from org.apache.mahout.cf.taste.eval import *