Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
Upload a document of any type to Google Docs from the command line. Requires a Google Apps Premier domain and the Google Data APIs Python client (http://code.google.com/p/gdata-python-client/downloads/list).
Usage:
$ pump_to_gdocs.py -f <file name> -t <mime type>
package dropify;
import processing.core.PApplet;
import processing.core.PImage;
import java.awt.dnd.*;
import java.awt.datatransfer.*;
import java.io.BufferedReader;
import java.io.DataOutputStream;
@malcolmt
malcolmt / Malcolm's $PS1 prompt
Created September 17, 2010 19:21
People keep asking about my fancy bash prompt (I've been using it since the mid-90's). So, here it is.
.-(malcolm@djelibeybi 15:19:34) ~
`--> echo $PS1
\n\[\033[35m\].-(\[\033[33m\]\u@\h \[\033[36m\]\t\[\033[35m\]) \[\033[0m\]\w\n\[\033[35m\]\`-->\[\033[0m\]
I should note that in my .bashrc file, I enter the information like this:
# My fancy two-line, colored prompt
e=\\\033
export PS1="\n\[$e[35m\].-(\[$e[33m\]\u@\h \[$e[36m\]\t\[$e[35m\])\[$e[0m\]\w\n\[$e[35m\]\\\`-->\[$e[0m\] "
@swinton
swinton / percentages.js
Created August 8, 2012 20:59
Function to generate a percentage calculator.
// Function to generate a percentage calculator.
// Percentages will be rounded to nearest whole number.
// The calculator ensures the entire set of percentages adds up to 100.
var percentageCalculatorGenerator = function(numDataPoints, total) {
// Ensure cumulative total adds up to 100
var cumulativeTotal = 0;
// Return the generated function
return function(value, idx) {
@swinton
swinton / grequests_oauth_example.py
Created August 16, 2012 13:13
Example of using grequests with oauth
#!/usr/bin/env python
"""
Example of using grequests with OAuth.
See: https://github.com/kennethreitz/grequests
"""
import json
@swinton
swinton / echobot.py
Created September 24, 2012 15:21
Connect to Twitter, track a hashtag, read out the tweets
#!/usr/bin/env python
"""Connect to Twitter, track a hashtag, read out the tweets!"""
import sys
import subprocess
import multiprocessing
import track
"""
How Django generates SECRET_KEYs for new Django projects.
See:
https://github.com/django/django/blob/1.7.1/django/core/management/commands/startproject.py#L27
"""
from django.utils.crypto import get_random_string
# Create a random secret_key
@sigma
sigma / ipy_profile_gae.py
Created August 29, 2010 09:39
#published GAE #ipython configuration
import IPython.ipapi
from getpass import getpass
from netrc import netrc
from optparse import OptionParser
from google.appengine.ext.remote_api import remote_api_stub
from google.appengine.tools.appcfg import AppCfgApp, StatusUpdate
from google.appengine.tools.bulkloader import RequestManager
@johnantoni
johnantoni / mysql.txt
Created August 7, 2012 18:57
mysql + vagrant + remote access
username: vagrant
password: vagrant
sudo apt-get update
sudo apt-get install build-essential zlib1g-dev git-core sqlite3 libsqlite3-dev
sudo aptitude install mysql-server mysql-client
sudo nano /etc/mysql/my.cnf
@onyxfish
onyxfish / fabfile.py
Created February 9, 2010 23:05
Chicago Tribune News Applications fabric deployment script
from fabric.api import *
"""
Base configuration
"""
env.project_name = '$(project)'
env.database_password = '$(db_password)'
env.site_media_prefix = "site_media"
env.admin_media_prefix = "admin_media"
env.newsapps_media_prefix = "na_media"