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
| #!/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
| # 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
| # 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
| 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
| 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
| from django.template import Library | |
| register = Library() | |
| @register.filter_function | |
| def html5datetime(date): | |
| """Format a date or a date and time according to the HTML 5 specifications, | |
| so it may be used as the value for a datetime attribute of a time tag. | |
| Most of the date formatting could be done in the template with the built-in |
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 (c) 2009, 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 |
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
| City | Latitude | Longitude | |
|---|---|---|---|
| Autauga, AL | 32.5791817 | -86.4996546 | |
| Baldwin, AL | 30.6010744 | -87.7763333 | |
| Barbour, AL | 31.8172896 | -85.354965 | |
| Bibb, AL | 32.9562798 | -87.1422895 | |
| Blount, AL | 34.0145152 | -86.4996546 | |
| Bullock, AL | 32.0573536 | -85.7256372 | |
| Butler, AL | 32.091673 | -88.221233 | |
| Calhoun, AL | 33.7701576 | -85.80766 | |
| Chambers, AL | 32.9028048 | -85.354965 |
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 | |
| """ | |
| Copyright (c) 2009, 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. |