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
# assuming you have UTF-8 locale | |
import pprint | |
orig_format = pprint.PrettyPrinter._format | |
def patched_format(self, object, stream, indent, allowance, context, level): | |
if isinstance(object, unicode): | |
stream.write("u\'") | |
stream.write(object.encode('utf8')) | |
stream.write("'") |
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
/* | |
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/ | |
* Better handling of scripts without supplied ids. | |
* | |
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function. | |
*/ | |
(function(doc, script) { | |
var js, | |
fjs = doc.getElementsByTagName(script)[0], |
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
(function() { | |
var transcript = ""; | |
$('#transcriptText p').each(function(i, para) { | |
if(i > 0) transcript += "\n"; | |
$('.transcriptLink', para).each(function(j, link) { | |
if(j > 0) transcript += " "; | |
transcript += link.text; | |
}); | |
}); | |
return transcript; |
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
""" | |
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 | |
""" |
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 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 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
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 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
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 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
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 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
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 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
>>> 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 |