Skip to content

Instantly share code, notes, and snippets.

View mick's full-sized avatar

Mick Thompson mick

View GitHub Profile
"""HTTP/1.1 client library
<intro stuff goes here>
<other stuff, too>
HTTPConnection goes through a number of "states", which define when a client
may legally make another request or fetch the response for a particular
request. This diagram details these state transitions:
(null)
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="guid"
t3st15
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="count"
2
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="userid"
twistd -noy punjab.tac
/usr/local/lib/python2.6/dist-packages/punjab/httpb.py:16: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
import sha, time
/usr/local/lib/python2.6/dist-packages/punjab/session.py:18: DeprecationWarning: the md5 module is deprecated; use hashlib instead
import md5
2011-02-28 16:09:00+0000 [-] Log opened.
2011-02-28 16:09:00+0000 [-] twistd 10.2.0 (/usr/bin/python 2.6.5) starting up.
2011-02-28 16:09:00+0000 [-] reactor class: twisted.internet.selectreactor.SelectReactor.
2011-02-28 16:09:00+0000 [-] twisted.web.server.Site starting on 5280
2011-02-28 16:09:00+0000 [-] Starting factory <twisted.web.server.Site instance at 0xb704354c>
@mick
mick / gist:752353
Created December 23, 2010 00:17
simple cache
if((couchcache["popular-"+page])&&(couchcache["popular-"+page].timesaved > (Date.now() - 60000))){
res.send(couchcache["popular-"+page].docs);
}else{
//...get doc...
if(page < 10){
couchcache["popular-"+page]={"timesaved":Date.now(),"docs":docs};
}
}
@mick
mick / gist:752349
Created December 23, 2010 00:11
siege results 2
Transactions: 5000 hits
Availability: 100.00 %
Elapsed time: 67.20 secs
Data transferred: 43.10 MB
Response time: 0.12 secs
Transaction rate: 74.40 trans/sec
Throughput: 0.64 MB/sec
Concurrency: 9.16
Successful transactions: 5000
Failed transactions: 0
@mick
mick / gist:752322
Created December 22, 2010 23:54
siege results
Transactions: 5000 hits
Availability: 100.00 %
Elapsed time: 184.75 secs
Data transferred: 41.63 MB
Response time: 1.27 secs
Transaction rate: 27.06 trans/sec
Throughput: 0.23 MB/sec
Concurrency: 34.44
Successful transactions: 5000
Failed transactions: 0
@mick
mick / gist:752306
Created December 22, 2010 23:42
Proxy CouchDB queries in Node
function recent(req, res, page){
var skip = page * 10;
db.view("recent", "recent", {"limit": 10, "skip":skip, "descending": "true"}, function(er, docs) {
if (er) {
new Error('Failed to load user ' + sys.inspect(er));
}
else{
res.send(docs);
}
=INFO REPORT==== 2010-07-07 09:07:13 ===
ERROR: "I(~p:~p:~p) : The payload~n" - [<0.378.0>,
chain_urlexpand,
82,
{xmlelement,
"entry",
[{"xmlns",
"http://www.w3.org/2005/Atom"}],
[{xmlelement,
"source",
=ERROR REPORT==== 2010-07-06 20:16:33 ===
ERROR: "E(~p:~p:~p) : Bad RPC error to ~p: ~p~nrunning chain link: ~p~n" - [<0.360.0>,
chaincollecta_hook,
100,
ejabberd@localhost,
chain_urlexpand,
add_expanded_urls,
{'EXIT',
{function_clause,
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="50" yahoo:created="2010-04-22T10:52:25Z" yahoo:lang="en-US">
<diagnostics>
<publiclyCallable>false</publiclyCallable>
<url execution-time="739"><![CDATA[http://social.yahooapis.com/yosapt_mt_feeder-1.0.0/v1/search/?offset=0&hits=50]]></url>
<user-time>742</user-time>
<service-time>739</service-time>
<build-version>6242</build-version>
</diagnostics>
<results>