This file contains 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 time | |
def run_for_seconds(fun, run_seconds): | |
start_time = time.time() | |
while run_seconds > (time.time() - start_time): | |
fun() | |
def foo(): | |
print '.', |
This file contains 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 sys | |
if len(sys.argv) is not 2: | |
sys.stderr.write('Expected <python module name> as only argument\n') | |
sys.exit(1) | |
module_parts = sys.argv[1].split('.') | |
module = __import__(module_parts[0]) |
This file contains 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 rocket | |
######################################## | |
# Settings ############################# | |
######################################## | |
__all__ = ['Pysailthru'] | |
VERSION = '0.1' |
This file contains 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 glob | |
import urllib | |
import sys | |
if len(sys.argv) < 2: | |
directory_pattern = '*/*/*' | |
else: | |
directory_pattern = sys.argv[1] |
This file contains 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
>>> True = not True | |
>>> True | |
True | |
>>> def foo(): | |
... True = False | |
... print True | |
... | |
>>> True | |
True | |
>>> foo() |
This file contains 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 rec_pow(fun, n): | |
if n == 1: | |
return fun(n) | |
else: | |
return fun(n) + rec_pow(fun, (n-1)) | |
# Was curious about keyspace with hashing algorithms so this figures | |
# out the whole space below some point. Like all 6 letter hashes including | |
# 5, 4, 3, 2 and 1 letter hashes. | |
# |
This file contains 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 word(): | |
... x = 1 | |
... yield x | |
... x = x + 1 | |
... yield x | |
... x = x + 1 | |
... yield x | |
... | |
>>> for i in word(): | |
... print i |
This file contains 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 strint(int): | |
def __new__(cls, arg=0): | |
if type(arg) is int: | |
return int.__new__(cls, arg) | |
else: | |
return 0 |
This file contains 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 json | |
>>> import urllib | |
>>> tweet_json = urllib.urlopen('http://search.twitter.com/search.json?q=@j2labs').read() | |
>>> tweets = json.loads(tweet_json) | |
>>> len(tweets['results']) | |
15 | |
>>> for t in tweets['results']: | |
... print '%s :: %s' % (t['from_user'], t['text']) | |
... | |
AlrightOk :: @j2labs I'd have to agree. But they're both pretty limited in their appropriateness. They both make me throw up in my mouth a little.... |
This file contains 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 | |
# | |
# twitter - implementing with a quickness | |
__doc__ = """Python bindings for the Twitter API | |
(rtwitter - courtesy of ExtensionFM) | |
For more information, see | |
Home Page: nuttin yet. |