Skip to content

Instantly share code, notes, and snippets.

View thurloat's full-sized avatar

Adam Thurlow thurloat

View GitHub Profile
@thurloat
thurloat / mvp.coffee
Created May 26, 2011 19:05
Coffeescript MVP?
class Injector
register: (name, factory) ->
@[name] = factory
INJECTOR = new Injector
class EventBus
constructor: () ->
fire: (event_name, data) ->
@thurloat
thurloat / coffee.json
Created June 17, 2011 14:08 — forked from minichate/coffee.json
Timmys Run
{
"Christopher Troup": [
{
item: "Coffee",
modifiers: [
cream: 2,
sugar: 2
],
amount: 1
},
@thurloat
thurloat / cofee.coffee
Created June 17, 2011 14:22
adam's order in coffeescript?
class Modifier
constructor: (@name, @amount) ->
class Item
constructor: (@item_name) ->
addModifier: (modifier) ->
@modifiers.push(modifier)
class Order
@thurloat
thurloat / stupidcal.py
Created July 4, 2011 14:26
Stupid Calendar
"""
GData Python doesn't pick up the calendar color entry, and clobbers the namespace somehow, so manual parsing is required for now :(
"""
cal = client.GetCalendarEntry(cal_href)
blacklist_color = cal.color.value
if not blacklist_color:
for child in cal.FindChildren():
xmlstr = child.to_string()
@thurloat
thurloat / testfile.js
Created July 14, 2011 11:32
testfile.js
var myauthclass = function(rsa_key) {
var private_key = rsa_key;
var send_request = function(url) {
var final_url = sign(url, private_key);
gadgets.io.makeRequest(final_url);
}
return {
'send_request': send_request
@thurloat
thurloat / style.css
Created August 2, 2011 14:42
Nyandoginc.ca
body{
background: #002a54;
color: #FFF !important;
}
#clouds {
background-image: url('http://gtrax.s3.amazonaws.com/nyan-sub.png') !important;
}
div#header {
background: #00162d !important;
}
@thurloat
thurloat / api.py
Created September 15, 2011 14:43
How not to implement an API
def api_object_update(request):
try:
Model.update(request.POST)
except Exception, e:
pass # This should never happen.
return HttpResponse(status_code=200)
@thurloat
thurloat / form.html
Created September 27, 2011 14:58
Too evil?
{% extends base.html %}
<form action="">
{% for vote in votes %}
{{ vote.position }}:
{% for position in vote.possible_positions %}
<input type="radio" name="vote_{{vote.pk}}" value="{{position}}" />
{% endfor %}
{% endfor %}
<input type="hidden" name="voting_on" value="{% for vote in votes %}vote.pk,{% endfor %}" />
@thurloat
thurloat / output
Created September 28, 2011 13:26 — forked from minichate/output
Metaclasses
class M(object):
def __init__(self, *args, **kwargs):
super(M, self).__init__()
setattr(self, "foo", self.baz)
setattr(self, "other_long_name", self.baz)
setattr(self, "metatastic", True)
@classmethod
def baz(cls):
return "FooBaz -- Base class %s" % cls
@thurloat
thurloat / CartSQL.vb
Created September 28, 2011 14:09
Shopping Cart Classes (thurloat & joeuttaro - March 31st 2006)
Imports System.Data.SqlClient
Public Enum updateType
add1
realupdate
End Enum
Public Class CartSQL
Public Function getCart(ByVal cartid As String) As DataTable
Dim objdal As New DAL
Dim mycmd As New SqlCommand
mycmd.Parameters.Clear()