Skip to content

Instantly share code, notes, and snippets.

View j2labs's full-sized avatar

The Ghost Of J2 Labs j2labs

View GitHub Profile
import time
def run_for_seconds(fun, run_seconds):
start_time = time.time()
while run_seconds > (time.time() - start_time):
fun()
def foo():
print '.',
#!/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])
import rocket
########################################
# Settings #############################
########################################
__all__ = ['Pysailthru']
VERSION = '0.1'
#!/usr/bin/env python
import glob
import urllib
import sys
if len(sys.argv) < 2:
directory_pattern = '*/*/*'
else:
directory_pattern = sys.argv[1]
>>> True = not True
>>> True
True
>>> def foo():
... True = False
... print True
...
>>> True
True
>>> foo()
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.
#
>>> def word():
... x = 1
... yield x
... x = x + 1
... yield x
... x = x + 1
... yield x
...
>>> for i in word():
... print i
class strint(int):
def __new__(cls, arg=0):
if type(arg) is int:
return int.__new__(cls, arg)
else:
return 0
>>> 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....
#! /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.