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
{"accuracy":20,"altitude":null,"altitude_accuracy":null,"created_at":"2011-10-06T00:14:33Z","heading":"","id":13053,"latitude":48.0516098,"longitude":-123.6075554,"note_id":null,"recorded_at":"2011-10-14T09:17:13Z","speed":null,"updated_at":"2011-10-14T09:17:13Z","user_id":91,"notes":[{"created_at":"2011-10-06T03:35:39Z","id":94,"latitude":null,"location_id":13053,"longitude":null,"network_id":null,"recorded_at":"2011-10-06T03:35:39Z","subject":"asdfasdf","text":"This is a test.","updated_at":"2011-10-06T03:35:39Z","user_id":91},{"created_at":"2011-10-14T09:19:01Z","id":95,"latitude":null,"location_id":13053,"longitude":null,"network_id":null,"recorded_at":"2011-10-14T09:19:01Z","subject":"blargle","text":"wheeeee","updated_at":"2011-10-14T09:19:01Z","user_id":91}],"tasks":[{"created_at":"2011-10-15T22:17:16Z","date":null,"description":"bar","form_id":null,"groups":null,"id":4,"location_id":13053,"name":"foo","network_id":null,"priority":null,"updated_at":"2011-10-15T22:19:44Z","user_id":91,"users":[]}],"hasN |
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
module AssociationIds | |
def ids_for name | |
name = name.to_s | |
define_method (name + '_ids=').to_sym do |ids| | |
values = ids.collect { |id| Kernel.const_get(name.classify).find id } | |
self.send(name + '=', values) | |
end | |
define_method (name + '_ids').to_sym do | |
self.send(name).collect { |obj| obj.id } |
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
#!/usr/bin/env python | |
class TreeNode(object): | |
def __init__(self, parent, x_min, y_min, x_max, y_max, items = []): | |
(self.x_min, self.y_min) = (x_min, y_min) | |
(self.x_max, self.y_max) = (x_max, y_max) | |
self.x_mid = (x_min + x_max) / 2 | |
self.y_mid = (y_min + y_max) / 2 |
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
#define cycleTime 150 | |
void setup() { | |
for(int i = 2; i < 13; i++) | |
pinMode(i, OUTPUT); | |
} | |
void usePin(int pin) { | |
for(int i = 2; i < 13; i++) | |
digitalWrite(i, LOW); |
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
add_index "locations", ["accuracy"], :name => "index_locations_on_accuracy" | |
add_index "locations", ["altitude"], :name => "index_locations_on_altitude" | |
add_index "locations", ["latitude"], :name => "index_locations_on_latitude" | |
add_index "locations", ["longitude"], :name => "index_locations_on_longitude" | |
add_index "locations", ["recorded_at"], :name => "index_locations_on_recorded_at" | |
add_index "locations", ["user_id"], :name => "index_locations_on_user_id" |
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
<html> | |
<head> | |
<title>Color Tests</title> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(function() { | |
// Do Awesome Things With Colors! | |
function makeColor(index) { | |
function color(i) { | |
// Wrap around using modulus |
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
#!/usr/bin/env python | |
def chunk(s): | |
if s == "": return [] | |
elif len(s) < 8: return [s] | |
else: return [s[:8]] + chunk(s[8:]) | |
def decode(bin): | |
chars = [ chr(int(x, 2)) for x in chunk(bin) ] | |
return "".join(chars) |
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
class HashTable(object): | |
def __init__(self, size=100): | |
self.data = [ list() for x in range(size) ] | |
def add(self, key, item): | |
l = self.data[hash(key)] | |
for i, tup in enumerate(l): | |
if tup[0] == key: | |
del l[i] | |
break |
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
public class SampleSingleton { | |
private static SampleSingleton instance; | |
private SampleSingleton() { | |
instance = this; | |
} | |
public static synchronized SampleSingleton getInstance() { | |
if(instance) | |
return instance; | |
else | |
return new SampleSingleton(); |
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
class Search < MongoObject | |
def coords=(x) | |
if String === x | |
super(x.split(",")) | |
else | |
super(x) | |
end | |
end | |
end |