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 antigravity | |
>>> antigravity.start() | |
'http://xkcd.com/353/' | |
# the source of http://pypi.python.org/pypi/antigravity/0.1 | |
# is plain and there is no any magic of Python | |
#!/usr/bin/env python | |
STRIP_URL = "http://xkcd.com/353/" |
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
__doc__ = "Add fly function to namespace where module is imported" | |
class RealWorldLevitation(Exception): | |
pass | |
def expose(obj): | |
import inspect | |
frame = inspect.currentframe() | |
frame.f_back.f_back.f_globals[obj.__name__] = obj | |
return obj |
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 sys | |
import subprocess | |
import readline | |
import select | |
import os | |
class Popen(subprocess.Popen): | |
def _communicate(self, input): | |
read_set = [] |
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
>>> tasks = Task.objects.\ | |
... extra(select = {'t': "date_trunc('minute', task_task.date_created)"}).\ | |
... values('t').annotate(Count('id')).order_by('t') | |
>>> print "\n".join("%(t)s | %(id__count)d" % t for t in tasks) | |
2011-01-19 11:26:00 | 767 | |
2011-01-19 11:27:00 | 613 | |
2011-01-19 11:28:00 | 522 | |
2011-01-19 11:29:00 | 721 | |
2011-01-19 11:30:00 | 701 | |
2011-01-19 11:31:00 | 679 |
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
python << END_PATH | |
import os | |
import vim | |
walker = os.walk(os.getcwd()) | |
dir_list = ['.'] | |
for root, dirs, paths in walker: | |
dir_list += map(lambda d: os.path.join(root, d), dirs) | |
vim.command('set path=%s' % ','.join(dir_list)) | |
END_PATH |
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 SQLDebugCommand(object): | |
def __init__(self): | |
from devserver.modules.sql import SQLSummaryModule, SQLRealTimeModule | |
from devserver.logger import GenericLogger | |
from mock import Mock | |
self.modules = [ | |
#SQLRealTimeModule(GenericLogger(SQLRealTimeModule)), | |
SQLSummaryModule(GenericLogger(SQLSummaryModule)), | |
] | |
self.mock_request = Mock() |
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
Traceback (most recent call last): | |
... | |
File "ve/lib/python2.6/site-packages/celery/task/base.py", line 320, in delay | |
return self.apply_async(args, kwargs) | |
File "ve/lib/python2.6/site-packages/celery/task/base.py", line 442, in apply_async | |
**options) | |
File "ve/lib/python2.6/site-packages/celery/app/amqp.py", line 230, in delay_task | |
send(body, exchange=exchange, **extract_msg_options(kwargs)) | |
File "ve/lib/python2.6/site-packages/kombu/connection.py", line 196, in _insured | |
return fun(*args, **kwargs) |
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
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) | |
IPython 0.10 -- An enhanced Interactive Python. | |
In [1]: from django.conf import settings | |
In [2]: settings.DEBUG | |
Out[2]: False | |
In [3]: from django.db import connection |
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 sys | |
import odesk | |
from odesk import Q | |
from datetime import datetime, timedelta | |
import shelve | |
import os | |
# add your desktop app keys | |
public_key = '' | |
secret_key = '' |
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
""" | |
Script for automated analysis of profiling data in MongoDB, | |
gathered by Mongo with db.setProfilingLevel(1). | |
See <http://www.mongodb.org/display/DOCS/Database+Profiler> | |
TODO: pass collection and database with profiling data in arguments | |
TODO: make thread-safe | |
TODO: handle map-reduce operations | |
""" |
OlderNewer