Skip to content

Instantly share code, notes, and snippets.

"""
Simple preforking echo server in Python.
Python port of http://tomayko.com/writings/unicorn-is-unix.
"""
import os
import sys
import socket
from sauce import application, get, post, delete, put, urls
import web
@get("/")
def index():
return "Hello from /6"
@get("/login")
def login():
raise web.seeother("/")
[jzellman@fozzie ~]$ ping -c 20 steadfast.net
PING steadfast.net (67.202.100.2): 56 data bytes
64 bytes from 67.202.100.2: icmp_seq=0 ttl=55 time=15.890 ms
64 bytes from 67.202.100.2: icmp_seq=1 ttl=55 time=14.084 ms
64 bytes from 67.202.100.2: icmp_seq=2 ttl=55 time=11.348 ms
64 bytes from 67.202.100.2: icmp_seq=3 ttl=55 time=12.152 ms
64 bytes from 67.202.100.2: icmp_seq=4 ttl=55 time=13.201 ms
64 bytes from 67.202.100.2: icmp_seq=5 ttl=55 time=12.352 ms
64 bytes from 67.202.100.2: icmp_seq=6 ttl=55 time=13.464 ms
64 bytes from 67.202.100.2: icmp_seq=7 ttl=55 time=11.204 ms
class Company
def zipcode
Zipcode.parse(get_attribute(:zipcode), self.country)
end
end
# example zipcode interface
class Zipcode
def self.parse(zipcode, country)
Object.const_get("Zipcode::#{country.upcase}").new(zipcode)
#! /usr/bin/env python
# Reads in a file from stdin and converts its encoding from 8859 to utf-8
# Writes to stdout and lines that fail to stderr
# Example usage ./convert.py < in.txt 1> out.txt 2> errors.txt
import sys
for line_number, line in enumerate(sys.stdin.readlines()):
try:
sys.stdout.write(unicode(line, "8859").encode("utf-8"))
except UnicodeDecodeError as e:
def current_brand
@_cached_brand ||= current_user.nil? ? look_up_from_reseller :
current_user.company.reseller.brand
end
starting vacuum...end.
transaction type: TPC-B (sort of)
scaling factor: 50
number of clients: 25
number of transactions per client: 100000
number of transactions actually processed: 2500000/2500000
tps = 319.300264 (including connections establishing)
tps = 319.306314 (excluding connections establishing)
[beaker:~/dev/mastermind] jzellman> git status
# On branch master
# Your branch is ahead of 'origin/master' by 322 commits.
#
nothing to commit (working directory clean)
[beaker:~/dev/mastermind] jzellman> git push origin master
git Everything up-to-date
[beaker:~/dev/mastermind] jzellman> git status
# On branch master
nothing to commit (working directory clean)
[beaker:~/dev/mastermind] jzellman> git fetch origin
git statusFrom [email protected]:frogmetrics/mastermind
b27a181..62304b8 master -> origin/master
[beaker:~/dev/mastermind] jzellman> git status
# On branch master
nothing to commit (working directory clean)
[beaker:~/dev/mastermind] jzellman> git pull
From [email protected]:frogmetrics/mastermind
+ 62304b8...b27a181 HEAD -> origin/HEAD (forced update)
Already up-to-date.
[beaker:~/dev/mastermind] jzellman> git pull
From [email protected]:frogmetrics/mastermind
b27a181..62304b8 master -> origin/master
Already up-to-date.
[beaker:~/dev/mastermind] jzellman> git status
# On branch master
nothing to commit (working directory clean)
[beaker:~/dev/mastermind] jzellman> git pull
From [email protected]:frogmetrics/mastermind
+ 62304b8...b27a181 HEAD -> origin/HEAD (forced update)