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
Copyright 2010 Aaron Bycoffe. All rights reserved. | |
Redistribution and use in source and binary forms, with or without modification, are | |
permitted provided that the following conditions are met: | |
1. Redistributions of source code must retain the above copyright notice, this list of | |
conditions and the following disclaimer. | |
2. Redistributions in binary form must reproduce the above copyright notice, this list | |
of conditions and the following disclaimer in the documentation and/or other materials |
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
import Image | |
import sys | |
def make_image(color, filename, dimensions=(1,1)): | |
"""Create a solid-color image.""" | |
im = Image.new('RGB', dimensions, color) | |
im.save(filename) | |
if __name__ == '__main__': |
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
# Testing goat. Via http://valkyrie.kwister.com/home/ascii/mygoat.html | |
______._ | |
/ / \ \ | |
/ / / / | |
\ \ | |
\ \____. | |
/ / \\ | |
/ @ \ / \, | |
/ \/ \___ _______ | |
\____/ \ `--------' `-, |
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
# http://xkcd.com/710/ | |
# An iterator for showing the Collatz Conjecture | |
""" | |
>>> [x for x in Collatz(6)] | |
[3, 10, 5, 16, 8, 4, 2, 1] | |
>>> [x for x in Collatz(11)] | |
[34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1] | |
>>> len([x for x in Collatz(27)]) |
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 | |
""" | |
Python script to allow viewing of scores of in-progress college basketball games | |
on the command line. Scores come from Yahoo Sports. | |
Requirements: | |
BeautifulSoup | |
""" | |
import re | |
import urllib2 |
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
def datechunk(start, end, days): | |
""" | |
Create a generator of (start_date, end_date) tuples | |
where the difference between start_date and end_date | |
is the number of days given. | |
>>> list(datechunk(datetime.date(2010, 01, 01), datetime.date(2010, 08, 20), 30)) | |
[(datetime.date(2010, 1, 1), datetime.date(2010, 1, 31)), | |
(datetime.date(2010, 2, 1), datetime.date(2010, 3, 3)), | |
(datetime.date(2010, 3, 4), datetime.date(2010, 4, 3)), |
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 FixedWidthParser(object): | |
"""A parser for fixed-width data files. Pass in a data file and | |
a list of field names and lengths, and get back a dictionary | |
for each row. | |
Useful for converting a fixed-width file to a CSV. | |
See tests.py for a usage example. | |
""" |
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 | |
''' | |
Python-based gift exchange randomizer. | |
Step through a list of people and, for each member of that list, | |
select someone else to be a recipient of their gift. That recipient: | |
A) Must not be themselves (no self-gifting) | |
B) Must not already have been assigned as a recipient | |
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
""" | |
First pass at scraping the FAPIIS site, just to see if it's possible. | |
This seems to work, but it's impossible to know whether the data it's | |
returning will be accurate since FAPIIS doesn't currently contain any | |
data. | |
This method requires knowing the company's DUNS number, though it's | |
likely possible to back this up a step to allow for searching by name. | |
""" | |
import urllib |
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 window.GoogleChart | |
constructor: -> | |
@width = 0 | |
@height = 0 | |
@encoded = [] | |
@data = [] | |
simpleEncoding: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' | |
extendedMap: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.', |