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 | |
| import ID3, os | |
| for fname in [ x for x in os.listdir(".") if x.lower().endswith(".mp3") ]: | |
| print "handling: %s" % fname | |
| tag = ID3.ID3(fname) | |
| new_name = "%0.2d %s.mp3" % (tag.track, tag.title) | |
| if fname and tag and new_name: | |
| os.rename(fname, new_name) |
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
| for i in range(ord('a'), ord('z')): | |
| print "{0:d}\t{0:b}".format(i) |
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 |
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 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
| #!/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
| <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
| 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
| #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
| #!/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 |