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 isinteger(n): | |
return n == int(n) | |
def divisors(n): | |
result = [] | |
for x in xrange(1, n+1): | |
if isinteger(n / (x + 0.0)): | |
result.append(x) | |
return result |
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
super-simple: | |
from IPython.core.debugger import Tracer | |
set_trace = Tracer() | |
partial ipdb __main__ patch: | |
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
diff --git a/django/db/backends/postgresql/creation.py b/django/db/backends/postgresql/creation.py | |
index 8f329fe..f1102ed 100644 | |
--- a/django/db/backends/postgresql/creation.py | |
+++ b/django/db/backends/postgresql/creation.py | |
@@ -31,6 +31,9 @@ class DatabaseCreation(BaseDatabaseCreation): | |
def sql_table_creation_suffix(self): | |
assert settings.TEST_DATABASE_COLLATION is None, "PostgreSQL does not support collation setting at database creation time." | |
+ result = [] | |
if settings.TEST_DATABASE_CHARSET: |
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
commit 8cec2da1cbefa56e3cb8646ce97024cdc50e1379 | |
Author: Travis Cline <travis.cline@gmail.com> | |
Date: Wed Dec 16 10:33:35 2009 -0600 | |
Added get_models caching for test performance. In my tests I see about a 30% speedup in Django's testsuite and closer to 40% in a large commercial testsuite. | |
diff --git a/django/db/models/loading.py b/django/db/models/loading.py | |
index 4ab1d50..e8ab590 100644 | |
--- a/django/db/models/loading.py | |
+++ b/django/db/models/loading.py |
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 print_name(user): | |
print "name is %s" % user | |
print_name("Travis Cline") |
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 os | |
import sys | |
import subprocess | |
def simplify_pg_index_line(line): | |
""" | |
Given a postgres index file line returns it's simplified form. | |
Returns None for comments |
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
reposting as public: | |
If you get this error: | |
"Error: cannot import name gqn" | |
Then: | |
git clean -df |
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 | |
from IPython.Debugger import Pdb | |
from IPython.Shell import IPShell | |
from IPython import ipapi | |
import pprint | |
shell = IPShell(argv=['']) | |
class PdbWithWatch(Pdb): |
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
komodo.assertMacroVersion(2); | |
if (komodo.view) { komodo.view.setFocus(); } | |
var cmdName = 'command_name_here'; | |
var part = ko.toolbox2.getToolsByTypeAndName('command', cmdName); | |
if (!part.length) { | |
alert("Couldn't find a command called '" | |
+ cmdName | |
+ "'when executing macro."); | |
return; | |
} |
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
from flask import Flask, request | |
from gevent.event import AsyncResult | |
from gevent.wsgi import WSGIServer | |
app = Flask(__name__) | |
waiters = [] | |
@app.route("/") | |
def main(): |