Skip to content

Instantly share code, notes, and snippets.

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
@tmc
tmc / ipdb.py
Created December 3, 2009 06:10
ipdb for ipython 0.11
super-simple:
from IPython.core.debugger import Tracer
set_trace = Tracer()
partial ipdb __main__ patch:
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:
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
def print_name(user):
print "name is %s" % user
print_name("Travis Cline")
#!/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
reposting as public:
If you get this error:
"Error: cannot import name gqn"
Then:
git clean -df
import sys
from IPython.Debugger import Pdb
from IPython.Shell import IPShell
from IPython import ipapi
import pprint
shell = IPShell(argv=[''])
class PdbWithWatch(Pdb):
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;
}
from flask import Flask, request
from gevent.event import AsyncResult
from gevent.wsgi import WSGIServer
app = Flask(__name__)
waiters = []
@app.route("/")
def main():