Skip to content

Instantly share code, notes, and snippets.

View kennethreitz's full-sized avatar
🌙

Kenneth Reitz kennethreitz

🌙
View GitHub Profile
@brosner
brosner / gist:2899595
Created June 9, 2012 05:15
S3 eventlet backend for django-ajax-uploader
"""
This file provides an eventlet based S3 uploader for django-ajax-uploader. It
supports chunk retry and chunk parallelism for efficient uploads.
This backend will only work with the forked django-ajax-uploader from my
multipart-post branch which adds some efficiencies to file upload.
django-ajax-uploader: https://github.com/brosner/django-ajax-uploader/tree/multipart-post
Author: Brian Rosner <[email protected]>
@idan
idan / oauthlib_twitter_example.py
Created May 2, 2012 22:50
Requests + OAuth, sample usage
import requests
from requests.auth import OAuth1
url = u'https://api.twitter.com/1/account/settings.json'
client_key = u'...'
client_secret = u'...'
resource_owner_key = u'...'
resource_owner_secret = u'...'
@dcrosta
dcrosta / gist:2562350
Created April 30, 2012 20:17
A Python Mystery
Guess the output:
>>> def exec_code_object_and_return_x(codeobj, x):
... exec codeobj
... return x
...
>>> co1 = compile("""x = x + 1""", '<string>', 'exec')
>>> co2 = compile("""del x""", '<string>', 'exec')
>>> exec_code_object_and_return_x(co1, 1)
# What do you get here?
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@shanemcd
shanemcd / gist:2209334
Created March 26, 2012 20:14
Populate staging server with Production DB
heroku pgbackups:restore DATABASE `heroku pgbackups:url --app instruments2` --app instruments2-staging
@bfirsh
bfirsh / short_urls.py
Created March 8, 2012 21:24
Efficiently expand short URLs
import requests
from urlparse import urlparse, urljoin
URL_SHORTENERS = [
'bit.ly',
'ow.ly',
'dlvr.it',
'fb.me',
'4sq.com',
'is.gd',
@danp
danp / gist:1897546
Created February 24, 2012 04:13
bundler as virtualenv!
mkdir -p bin
bundle exec bash -c 'cat > bin/activate <<EOF
#!/bin/sh
export BUNDLE_BIN_PATH="$BUNDLE_BIN_PATH"
export PATH="$PATH"
export BUNDLE_GEMFILE="$BUNDLE_GEMFILE"
export RUBYOPT="$RUBYOPT"
EOF'
source bin/activate
@garnaat
garnaat / update_key.py
Created February 10, 2012 17:25
Update the content-type of an existing key in S3 using boto
import boto
s3 = boto.connect_s3()
bucket = s3.lookup('mybucket')
key = bucket.lookup('mykey')
# Copy the key onto itself, preserving the ACL but changing the content-type
key.copy(key.bucket, key.name, preserve_acl=True, metadata={'Content-Type': 'text/plain'})
key = bucket.lookup('mykey')
@panicsteve
panicsteve / gist:1641705
Created January 19, 2012 18:26
Form letter template for acquired startups
Dear soon-to-be-former user,
We've got some fantastic news! Well, it's great news for us anyway. You, on
the other hand, are fucked.
We've just been acquired by:
[ ] Facebook
[ ] Google
[ ] Twitter
@pydanny
pydanny / field.html
Created November 8, 2011 16:33
django-uni-form + Twitter Bootstrap
<!-- this usually goes in <project-root>/templates/uni_form/field.html -->
{% if field.is_hidden %}
{{ field }}
{% else %}
<div class="clearfix {% if field.errors %}error{% endif %}">
<label for="{{ field.auto_id }}" {% if field.field.required %}class="requiredField"{% endif %}>
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
</label>
<div class="input">