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 --> |
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 | |
} |
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( |
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]) |
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) { |
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): |
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 |
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
{% loop through transactions... %} | |
<td> | |
{% if not transaction.merchant.category %} | |
<select data-value="{{ transaction.id }}"> | |
<option value="-1">Not set</option> | |
{% for category in categories %} | |
<option value="{{ category.id }}">{{ category.name }}</option> | |
{% endfor %} | |
</select> |
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); |
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
def transaction(request): | |
transaction_id = request.REQUEST.get('transactionId') | |
category_id = request.REQUEST.get('categoryId') | |
t = Transaction.objects.get(pk=transaction_id) | |
m = t.merchant | |
c = Category.objects.get(pk=category_id) | |
m.category = c | |
m.save() |
OlderNewer