View ticket.rb
This file contains 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
class Ticket < ActiveRecord::Base | |
belongs_to :event | |
default_scope where(event_id: -1) | |
end |
View tweet_text.js
This file contains 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
$(".tweet-text").map(function() { return $(this).text(); }) |
View condiments.dot
This file contains 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
graph condiments { | |
ketchup -- mayonnaise -- tartar -- lemon | |
ketchup -- bbq | |
} |
View jqm_example.html
This file contains 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
<div data-role="page" id="first"> | |
<div data-role="header"> | |
<h1>Page Title1</h1> | |
</div><!-- /header --> | |
<div data-role="content"> | |
<p>Page content goes here.</p> | |
<a href="#second">Go to second page</a> | |
</div><!-- /content --> | |
</div><!-- /page --> |
View imgur.py
This file contains 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 requests | |
import urlparse | |
from oauth_hook import OAuthHook | |
# consumer key + secret | |
CONSUMER_KEY = '' | |
CONSUMER_SECRET = '' | |
# get access token, create client | |
client = requests.session( |
View vis.py
This file contains 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 MySQLdb | |
db = MySQLdb.connect(host="localhost", port=3306, user="user", passwd="passwd", db="db") | |
cursor = db.cursor() | |
cursor.execute("SELECT id, referrer_id FROM users") | |
print "graph referrers {" | |
for row in cursor.fetchall(): | |
print "%s -- %s" % (row[0], row[1]) |
View FizzBuzz.java
This file contains 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
/* Write a program that prints the numbers from 1 to 100. | |
But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. | |
For numbers which are multiples of both three and five print “FizzBuzz”. | |
Pythonic Java - https://gist.github.com/1725650 | |
*/ | |
public class FizzBuzz { | |
public static void main(String[] args) { |
View Object model.py
This file contains 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
class Category(models.Model): | |
name = models.CharField(max_length=255) | |
class Merchant(models.Model): | |
name = models.CharField(max_length=255) | |
category = models.ForeignKey(Category, blank=True, null=True, db_index=True) | |
class Transaction(models.Model): |
View Capital One credit card CSV importer.py
This file contains 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
for filename in os.listdir(path): | |
reader = csv.reader(open(path + filename), dialect=csv.excel) | |
headers = reader.next() | |
for row in reader: | |
m, created = Merchant.objects.get_or_create(name=row[3]) | |
# lose the £ symbol and minus sign, cast to float |
View AJAX helper for categorising credit card transactions.js
This file contains 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
var setCategory = function(transactionId, categoryId) { | |
$.ajax({ | |
type: "GET", | |
url: "/transaction/", | |
data: { | |
transactionId: transactionId, | |
categoryId: categoryId | |
} | |
}).done(function( msg ) { | |
console.log(msg); |
OlderNewer