Skip to content

Instantly share code, notes, and snippets.

@jacobh
jacobh / CPython Time
Created July 27, 2011 13:16
PyPy & CPython speeds
jacob@debian:~/Projects/Euler$ time python 005.py
smallest number: 232792560
real 5m24.439s
user 5m24.200s
sys 0m0.220s
@jacobh
jacobh / gist:1223927
Created September 17, 2011 13:20
Gunicorn launch error
root@vps:/var/www/weldr.me/Pyzer# python pyzer.py
Bottle server starting up (using GunicornServer())...
Listening on http://0.0.0.0:9998/
Use Ctrl-C to quit.
2011-09-17 17:20:02 [9695] [INFO] Starting gunicorn 0.13.1
2011-09-17 17:20:02 [9695] [INFO] Listening at: http://127.0.0.1:8000 (9695)
2011-09-17 17:20:02 [9695] [INFO] Using worker: sync
2011-09-17 17:20:02 [9702] [INFO] Booting worker with pid: 9702
2011-09-17 17:20:02 [9702] [ERROR] Exception in worker process:
@jacobh
jacobh / 1 processing server
Created September 19, 2011 15:01
Rackspace Load Balancing
Server Software: nginx/0.7.67
Server Hostname: rackspace.weldr.me
Server Port: 80
Document Path: /profile/jacobh/
Document Length: 12472 bytes
Concurrency Level: 128
Time taken for tests: 67.230 seconds
Complete requests: 2000
@jacobh
jacobh / error
Created October 9, 2011 14:46
template class
Exception:
NameError("global name 'render' is not defined",)
@jacobh
jacobh / error
Created October 9, 2011 17:42
bottle includes
Traceback (most recent call last):
File "main.py", line 24, in <module>
app.mount('/static/', default_views)
File "/usr/local/lib/python2.6/dist-packages/bottle.py", line 430, in mount
raise TypeError('Only Bottle instances are supported for now.')
TypeError: Only Bottle instances are supported for now.
@jacobh
jacobh / gist:1293202
Created October 17, 2011 17:35
regex master~
>>> string = "GM.SetupCar(VEHICLE_SPEEDO, 'Speedo', 'speedo', 'models/sickness/speedodr.mdl', 'Make: Ford, Model: Speedo', 50000, 3750, 1.29);"
>>> re.search(r"GM.SetupCar\(.*?, '(?P<name>.*?)',.*'Make: (?P<make>.*), Model: (?P<model>.*)'", string).groupdict()
{'model': 'Speedo', 'make': 'Ford', 'name': 'Speedo'}
@jacobh
jacobh / gist:1302166
Created October 20, 2011 20:01
"Pseudocode"
# set prices
adult_prices = {
1: 46,
2: 84,
3: 120,
4: 150,
5: 175
}
child_prices = {
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import *
base= declarative_base()
class Item_information(base):
__tablename__= 'cpanel_item_information'
id= Column(Integer, primary_key= True)
name= Column(String(255))
description= Column(Text)
@jacobh
jacobh / gist:1316265
Created October 26, 2011 12:57
Tumblr Theme
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<!-- ----------------------------------
Theme Urban by Max Davis, 2011.
http://themes.themaxdavis.com
---------------------------------- -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@jacobh
jacobh / photos.models.py
Created November 6, 2011 10:17
django-imagekit
from django.db import models
from django.contrib.auth.models import User
from imagekit.models import ImageSpec
from imagekit.processors import resize, Adjust
from django.db.models.signals import post_save
from django.dispatch import receiver
from celery.task import task
from celery.execute import send_task