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
#!/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
#!/usr/bin/env ruby | |
tag_samples = [ 'foo bar', 'foo, bar, baz', 'foo "fun times" stuff', '"fail", "foo times"', "foo 'this is fun' bar" ] | |
tag_samples.each do |tag_str| | |
tags = tag_str.scan(/(\w+)|("([^"]+)")|('([^']+)')/).map { |a, _, b, _, c| (a or b or c).strip } | |
puts "#{tag_str}:" | |
puts tags | |
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
#!/usr/bin/env python | |
import serial, time | |
ser = serial.Serial('/dev/tty.usbserial-FTFB009M', 9600, timeout=1) | |
while True: | |
for val in [ "0", "a", "c", "g", "o" ]: | |
ser.write(val) | |
for i in range(5): | |
print ser.readline(), |
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
var stuff = "p> This is some text"; | |
console.log("line: ", stuff); | |
var re = /p([<>]) (.*)/; | |
var items = re.exec(stuff); | |
console.log(items[1]); |
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
vals = { "I" : 1, "V" : 5, "X" : 10, "L" : 50, "C" : 100, "D" : 500, "M" : 1000, "_" : 0} | |
while True: | |
input = raw_input("Enter a roman numeral: ").upper() | |
if input == "QUIT": break | |
input = [ vals[v] for v in input if v in vals ] | |
value = 0 | |
for cur, next in zip(input, (input+[0])[1:]): | |
if cur >= next: value += cur | |
else: value -= cur | |
print "Value: %d" % value |
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
<%= image_tag "http://maps.google.com/maps/api/staticmap?center=#{suggestion.lat},#{suggestion.lon}&zoom=5&size=170x120&maptype=roadmap&markers=#{suggestion.lat},#{suggestion.lon}&sensor=false" %> |
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
select observations.*, rankings.* | |
from observations inner join rankings on observations.behavior = rankings.code | |
where rankings.rank = (select max(rankings.rank) | |
from observations join rankings on observations.behavior = rankings.code | |
group by brand); |
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/python | |
from pprint import pprint | |
query = "insert into observations(beach, month, date, year, observer, effortid, " + \ | |
"brand, sex, age, behavior, time, photoname, comments) values('%s', '%s', " + \ | |
"'%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');" | |
rawdata = open("UgamakBrands2010.csv").readlines() | |
for line in [ line.strip().split(",") for line in rawdata[1:] ]: | |
print query % tuple(line) |
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
Coin | Quantity | Mass | |
---|---|---|---|
pennies | $0.50 | 132 g | |
nickels | $2.00 | 201 g | |
dimes | $5.00 | 115 g | |
quarters | $10.00 | 226 g |