Skip to content

Instantly share code, notes, and snippets.

@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"
#!/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>
@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
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\] "
@revolunet
revolunet / lzw_encoder.js
Created February 25, 2011 14:55
LZW javascript compress/decompress
// LZW-compress a string
function lzw_encode(s) {
var dict = {};
var data = (s + "").split("");
var out = [];
var currChar;
var phrase = data[0];
var code = 256;
for (var i=1; i<data.length; i++) {
currChar=data[i];
@valyagolev
valyagolev / __init__.py
Created April 29, 2011 02:46
Django settings awesomness
from .base import *
try:
from .local import *
except ImportError:
pass
@kennethreitz
kennethreitz / flaskapp.py
Created June 9, 2012 15:38
My typical flask app base
# -*- coding: utf-8 -*-
import os
from flask import Flask
from flask_heroku import Heroku
from flask_sslify import SSLify
from raven.contrib.flask import Sentry
from flask.ext.celery import Celery
@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
@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) {