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
administrator@ubuntu:~/projects/sandbox$ ve-cpython/bin/python json-bench.py && ve-pypy/bin/pypy json-bench.py | |
Running: json-bench.py | |
test_cpickle | |
test_cpickle warmup: 3.89885687828 | |
test_cpickle RUN: 4.03457689285 | |
test_demjson | |
test_demjson warmup: 143.255517006 | |
test_demjson RUN: 156.608139992 | |
test_cjson | |
test_cjson warmup: 3.51447200775 |
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 -c "import SimpleHTTPServer, SocketServer, BaseHTTPServer; SimpleHTTPServer.test(SimpleHTTPServer.SimpleHTTPRequestHandler, type('Server', (BaseHTTPServer.HTTPServer, SocketServer.ThreadingMixIn, object), {}))" 9090 | |
# short | |
python -c "from SimpleHTTPServer import test, BaseHTTPServer as b, SimpleHTTPRequestHandler as h; from SocketServer import ThreadingMixIn as t; test(h, type('Server', (b.HTTPServer, t, object), {}))" 9090 | |
# shorter | |
python -c "import SimpleHTTPServer as h, SocketServer as s, BaseHTTPServer as b; h.test(h.SimpleHTTPRequestHandler, type('S', (b.HTTPServer, s.ThreadingMixIn, object), {}))" 9090 | |
# this variant disables dns reverse lookups | |
python -c "import SimpleHTTPServer as h, SocketServer as s, BaseHTTPServer as b; h.test(type('H', (h.SimpleHTTPRequestHandler, object), {'address_string': lambda self: str(self.client_address[0])}), type('S', (b.HTTPServer, s.ThreadingMixIn, object), {}))" 9090 |
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 tornado.httpserver | |
import tornado.ioloop | |
import tornado.web | |
import subprocess | |
import shlex | |
import fcntl | |
import errno | |
from cStringIO import StringIO |
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
find src -name \*.py | sed 's/\//./g;s/\.py$//g;s/\.__init__$//;s/^src\.//' | while read -r line; do | |
echo Importing $line '\033[1;31m' | |
PYTHONPATH=src DJANGO_SETTINGS_MODULE=xxx.settings python -c "import $line" | |
echo -n '\033[0m' | |
done |
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 django.contrib import admin | |
from .models import SomeModel, OtherModelWithFKToSomeModel | |
def register(model): | |
def decorator(klass): | |
admin.site.register(model, klass) | |
return klass | |
return decorator | |
def inline(model, klass=admin.TabularInline, **options): | |
return type( |
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
#!/bin/bash -xe | |
# source: http://www.ducea.com/2009/01/19/running-multiple-instances-of-mysql-on-the-same-machine/ | |
i=$1 | |
port=$[3306+$i] | |
#mysqladmin -S /var/run/mysqld/mysqld$i.sock shutdown || true | |
kill -9 `cat /var/run/mysqld/mysqld$i.pid` || true | |
umount /var/lib/mysql$i || true | |
rm -rf /var/lib/mysql$i | |
mkdir /var/lib/mysql$i |
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 RegistrationBackend(SimpleBackend): | |
def register(self, request, **kwargs): | |
name, email, password = kwargs['name'], kwargs['email'], kwargs['password1'] | |
username = generate_id(name, '', email) | |
UserProfile.objects.create( | |
user=User.objects.create_user(username, email, password), | |
name=name | |
) |
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 django.template import Library | |
register = Library() | |
@register.simple_tag(takes_context=True) | |
def active_page(context, page_name): | |
active = active_class(context, page_name) | |
return ' class="%s" ' % active if active else active | |
@register.simple_tag(takes_context=True) | |
def active_class(context, page_name): |
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 win32com.client | |
NETWORK_CATEGORIES = { | |
1: "PRIVATE", | |
0: "PUBLIC", | |
2: "DOMAIN" | |
} | |
m = win32com.client.Dispatch("{DCB00C01-570F-4A9B-8D69-199FDBA5723B}") | |
more = 1 | |
pos = 1 | |
connections = m.GetNetworkConnections() |
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 -c "while 1:import sys,random;sys.stdout.write(random.choice('\/'))" |
OlderNewer