Skip to content

Instantly share code, notes, and snippets.

@yaniv-aknin
yaniv-aknin / brew-python3
Created January 16, 2011 15:19
Brew build errors for Python 3
$ brew install python3
==> Downloading http://www.python.org/ftp/python/3.1.3/Python-3.1.3.tar.bz2
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/python3/3.1.3 --with-computed-gotos --enable-shared
==> make
/usr/bin/cc -c -O3 -w -pipe -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -I/usr/local/Cellar/readline/6.1/include -DPy_BUILD_CORE -o Modules/python.o ./Modules/python.c
/usr/bin/cc -c -O3 -w -pipe -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -I/usr/local/Cellar/readline/6.1/include -DPy_BUILD_CORE -o Parser/acceler.o Parser/acceler.c
/usr/bin/cc -c -O3 -w -pipe -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -I/usr/local/Cellar/readline/6.1/include -DPy_BUILD_CORE -o Parser/grammar1.o Parser/grammar1.c
/usr/bin/cc -c -O3 -w -pipe -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -I/usr/local/Cellar/readline
@yaniv-aknin
yaniv-aknin / pyrocfile.py
Created February 9, 2012 09:39 — forked from asenchi/pyrocfile.py
pyrocfile - 100 line Procfile manager in Python
# Pyrocfile - Simple Python impementation of Procfile manager
# Written by Chris Testa (http://testa.co/) in 2011
# Released in the Public Domain
import argparse, logging, os.path, random, re, select, signal, subprocess
def _new_logger(name, color=None):
logger = logging.getLogger(name)
hdlr = logging.StreamHandler()
color, end_color = '\033[9%dm' % (color or random.randint(1, 6)), '\033[0m'
@yaniv-aknin
yaniv-aknin / muroku.py
Created April 3, 2012 09:50
muroku: small utility to aid syncing staging/testing/live heroku environments
#!/usr/bin/env python
# Written by @aknin
# https://gist.github.com/gists/2290744
# This code has been placed in the public domain, no strings attached either way.
from __future__ import print_function
import platform
import os
@yaniv-aknin
yaniv-aknin / heroku-dupdb.sh
Created April 14, 2012 18:18
heroku-dupdb: small utility to clone a database between two apps, useful for copying production into staging
#!/usr/bin/env bash
cprint () {
printf "%b" "\e[1;37m${1}\e[0m\n"
}
usage() {
cat << EOF
usage: $0 [OPTIONS] <src> <dst>
--confirm <dst> dont ask for confirmation before destroying and restoring into <dst>
% heroku apps:create -s cedar restpaste
Creating restpaste... done, stack is cedar
http://restpaste.herokuapp.com/ | git@heroku.com:restpaste.git
Git remote heroku added
% heroku addons:remove shared-database:5mb
! WARNING: Potentially Destructive Action
! This command will affect the app: restpaste
! To proceed, type "restpaste" or re-run this command with --confirm restpaste
@yaniv-aknin
yaniv-aknin / requirements.txt
Created April 23, 2012 17:31
s3lint: a simple lint tool to update S3 content-type and cache-control headers
boto==2.3.0
gevent==0.13.7
greenlet==0.3.4
wsgiref==0.1.2
@yaniv-aknin
yaniv-aknin / gist:3047862
Created July 4, 2012 15:19
Dirtys: shell function for a quick-and-dirty Redis instance
dirtys () {
if ! which redis-server > /dev/null
then
echo no redis, no dirtys
return 1
fi
redis-server - <<EOF
timeout 0
logfile stdout
databases 1
@yaniv-aknin
yaniv-aknin / gist:3075120
Created July 9, 2012 08:35
odd coffeescript 1.3.3 behaviour with superflous indentation on first line
$ cat > ok.coffee
1
2
$ cat > bad.coffee
1
2
$ coffee -cs < ok.coffee
// Generated by CoffeeScript 1.3.3
(function() {
1;
@yaniv-aknin
yaniv-aknin / gist:3089763
Created July 11, 2012 11:26
Mixpanel client library with separate communications and URL creation code
#! /usr/bin/env python
#
# Mixpanel, Inc. -- http://mixpanel.com/
#
# Python API client library to consume mixpanel.com analytics data.
import hashlib
import urllib
import time
try:
@yaniv-aknin
yaniv-aknin / gist:3720047
Created September 14, 2012 05:50
demonstration of how embedding IPython (pulling in SQLite) can trigger unwanted side effects atexit
$ pip freeze
ipython==0.13
readline==6.2.2
wsgiref==0.1.2
$ cat test.py
from IPython import embed ; embed()
import thread ; thread.start_new_thread(lambda: 5/0, ())
$ python test.py
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
Type "copyright", "credits" or "license" for more information.