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 | |
# Example for reading from the Twitter streaming API using pycurl | |
# | |
# PyCurl is not installed by default so install it like this: | |
# | |
# pip install pycurl | |
# | |
# The streaming api methods are documented here: |
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 logging | |
import time | |
logging.basicConfig(level=logging.DEBUG, | |
filename='whatevz.log') | |
def log_runtime(method): | |
def wrapper(*a, **kw): |
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
/* | |
* A typical run looks like this: | |
* | |
* Dumping: | |
* JSON: 2.017 | |
* Loading: | |
* JSON: 1.93 | |
* eval(): 25.387 | |
*/ |
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 | |
# The output geneally looks like this: | |
# | |
# $ ./serialization.py | |
# Dumping: | |
# json: 6.40960884094 | |
# simplejson: 6.82945179939 | |
# cjson: 2.23045802116 | |
# ujson: 0.806604146957 |
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 | |
from tweepy.models import Model, User | |
import urllib | |
import json | |
import copy | |
general_function_map = { | |
'created_at': lambda dt: '%s' % dt.strftime('%x'), |
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
-module(amazon). | |
-include_lib("erlcloud/include/erlcloud.hrl"). | |
-include_lib("erlcloud/include/erlcloud_ec2.hrl"). | |
-export([init_ec2conn/0, | |
create_instances/2]). | |
%% | |
%% These two are required first |
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 -u | |
# Using Python 2.6 | |
# Starting json... done: 17.8986079693 | |
# Starting simplejson... done: 6.75326800346 | |
# Starting cjson... done: 2.19219493866 | |
# Starting ujson... done: 0.742480039597 | |
# Starting pickle... done: 43.2633650303 | |
# Starting cPickle... done: 6.45727396011 | |
# Starting marshal... done: 1.2130010128 |
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 -u | |
# python 3.2 | |
# Starting json... done: 17.7406787872 | |
# Starting simplejson... done: 6.82341694832 | |
# Starting cjson... done: 2.29899692535 | |
# Starting ujson... done: 0.729449987411 | |
# Starting pickle... done: 45.2784938812 | |
# Starting cPickle... done: 6.48070406914 |
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
>>> print "%0.20f" % (0.1 + 0.2) | |
0.30000000000000004441 | |
>>> print "%0.30f" % (0.1 + 0.2) | |
0.300000000000000044408920985006 | |
>>> print "%0.30f" % (0.2 + 0.2) | |
0.400000000000000022204460492503 | |
>>> print "%0.30f" % (0.3 + 0.2) | |
0.500000000000000000000000000000 | |
>>> print "%0.30f" % (0.3 + 0.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 | |
""" | |
Least-recently used (LRU) queue device | |
Clients and workers are shown here in-process | |
Author: Guillaume Aubert (gaubert) <guillaume(dot)aubert(at)gmail(dot)com> | |
""" |