This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from hado.models import * | |
import datetime | |
f = open("prepayments.csv", "w+") | |
import csv | |
ppcsv = csv.DictWriter(f, ["user", "email", "balance"]) | |
ppcsv.writeheader() | |
total = 0 | |
users = User.objects.all().order_by('first_name') | |
for u in users: | |
for c in u.contracts.exclude(start__gte=datetime.date(2010, 10, 1)): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Facebook SDK | |
angular.module('facebook', []) | |
.directive('fb', ['$FB', function($FB) { | |
return { | |
restrict: "E", | |
replace: true, | |
template: "<div id='fb-root'></div>", | |
compile: function(tElem, tAttrs) { | |
return { | |
post: function(scope, iElem, iAttrs, controller) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ActivityTypes | |
Transaction.I_OWE = 0; | |
Transaction.OWES_ME = 1; | |
Transaction.I_PAID = 2; | |
Transaction.PAID_ME = 3; | |
Transaction.VOID = 4; | |
Transaction.WELCOME = 5; | |
// Transaction types as strings | |
Transaction.types = ["I owe", "owes me", "I paid", "paid me"]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Stick this in your repo's .git/config | |
# OR ~/.gitconfig | |
# | |
# Also, | |
# $ sudo apt-get install bash-completion | |
# for autocompletion goodness | |
[color] | |
ui = always | |
[alias] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Borrowed from http://stackoverflow.com/a/2527623/149468 | |
class objectJSONEncoder(json.JSONEncoder): | |
"""A specialized JSON encoder that can handle simple lxml objectify types | |
>>> from lxml import objectify | |
>>> obj = objectify.fromstring("<Book><price>1.50</price><author>W. Shakespeare</author></Book>") | |
>>> objectJSONEncoder().encode(obj) | |
'{"price": 1.5, "author": "W. Shakespeare"}' | |
""" | |
def default(self,o): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
#!/bin/python | |
# RSS feed parser/scraper for WhatsHappening.sg | |
import urllib2 | |
import csv | |
import re | |
import cStringIO | |
import codecs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Unicode DictWriter object | |
# http://stackoverflow.com/a/5838817 | |
class DictUnicodeWriter(object): | |
def __init__(self, f, fieldnames, dialect=csv.excel, encoding="utf-8", **kwds): | |
# Redirect output to a queue | |
self.queue = cStringIO.StringIO() | |
self.writer = csv.DictWriter(self.queue, fieldnames, dialect=dialect, **kwds) | |
self.stream = f | |
self.encoder = codecs.getincrementalencoder(encoding)() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto | |
import os | |
import base64 | |
import hashlib | |
import requests | |
import datetime | |
import hmac | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto | |
import os | |
import json | |
import base64 | |
import hashlib | |
import requests | |
import datetime | |
import hmac | |
import pytz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto | |
import os | |
import json | |
import base64 | |
import hashlib | |
import requests | |
import datetime | |
import hmac | |
import pytz |