Skip to content

Instantly share code, notes, and snippets.

View vortec's full-sized avatar

Fabian Kochem vortec

View GitHub Profile
import random
import sys
import time
runs = 5
items = 100000
str_length = 12
if sys.version_info.major == 2:
def genBytestrings():
@vortec
vortec / serve.py
Created August 1, 2012 20:05
Heavy calculation using multiple core and Tornado
from random import random
from time import time
def vectable(runs=25000):
""" """
test = []
for i in range(0, 1024):
x, y, z, w = random(), random(), random(), random()
test.append((x, y, z, w))
$ ./python serve.py
[I 120801 22:09:56 process:101] Starting 8 processes
[I 120801 22:09:56 serve:59] Starting Tornado on port 9000
[I 120801 22:09:56 serve:59] Starting Tornado on port 9002
[I 120801 22:09:56 serve:59] Starting Tornado on port 9001
Traceback (most recent call last):
File "serve.py", line 60, in <module>
tornado.httpserver.HTTPServer(application).listen(options.port, '0.0.0.0')
File "/Users/fabian 1/workspace/tornado/lib/python2.7/site-packages/tornado/netutil.py", line 103, in listen
sockets = bind_sockets(port, address=address)
upstream zope {
server 127.0.0.1:8080;
server 127.0.0.1:8081;
}
server {
listen 8000;
server_name 192.168.2.53;
location / {
proxy_pass_header Server;
@vortec
vortec / gist:3653345
Created September 6, 2012 09:00
Zopes dispatch method
def traverse(self, path, response=None, validated_hook=None):
"""Traverse the object space
The REQUEST must already have a PARENTS item with at least one
object in it. This is typically the root object.
"""
request=self
request_get=request.get
if response is None: response=self.response
drwx------ 2 www-data root 4096 Sep 7 15:55 nginx-cache
drwx------ 2 www-data root 4096 Sep 7 15:55 nginx-temp
<html>
<head>
<title>HTML5 File example</title>
<STYLE TYPE="text/css">
<!--
TD{font-family: Arial, Helvetica, sans-serif; font-size: 8pt;}
--->
</STYLE>
beep -f 659 -l 460 -n -f 784 -l 340 -n -f 659 -l 230 -n -f 659 -l 110 -n -f 880 -l 230 -n -f 659 -l 230 -n -f 587 -l 230 -n -f 659 -l 460 -n -f 988 -l 340 -n -f 659 -l 230 -n -f 659 -l 110 -n -f 1047-l 230 -n -f 988 -l 230 -n -f 784 -l 230 -n -f 659 -l 230 -n -f 988 -l 230 -n -f 1318 -l 230 -n -f 659 -l 110 -n -f 587 -l 230 -n -f 587 -l 110 -n -f 494 -l 230 -n -f 740 -l 230 -n -f 659 -l 460
from pdb import set_trace
def wrap1(name):
print('wrap 1: {}'.format(str(locals())))
def inner(): ## no reference to name in inner function
set_trace()
inner()
def wrap2(name):
FK-MBP:Debug fabian$ mono test2.exe
Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for com.trolltech.qt.gui.QApplication ---> System.TypeInitializationException: An exception was thrown by the type initializer for com.trolltech.qt.core.QCoreApplication ---> System.TypeInitializationException: An exception was thrown by the type initializer for com.trolltech.qt.core.QObject ---> System.TypeInitializationException: An exception was thrown by the type initializer for com.trolltech.qt.QtJambiObject ---> System.TypeInitializationException: An exception was thrown by the type initializer for com.trolltech.qt.QtJambi_LibraryInitializer ---> System.TypeInitializationException: An exception was thrown by the type initializer for com.trolltech.qt.Utilities ---> System.TypeLoadException: A type load exception has occurred.
at com.trolltech.qt.Utilities..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at com.trolltech