Skip to content

Instantly share code, notes, and snippets.

@javouhey
javouhey / gist:627891
Created October 15, 2010 09:19
HTTP response when invoking GET http://api.soundcloud.com/tracks/6095809
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 15 Oct 2010 09:06:37 GMT
Content-Type: application/xml; charset=utf-8
Connection: keep-alive
X-Runtime: 21
ETag: "c1caac3666276b6bb0f67480977dd98c"
Cache-Control: private, max-age=0, must-revalidate
Content-Length: 2040
Access-Control-Allow-Origin: *
@javouhey
javouhey / gist:627932
Created October 15, 2010 09:51
HTTP response when retrieving stream url GET http://api.soundcloud.com/tracks/6095809/stream
HTTP/1.1 302 Moved Temporarily
Server: nginx
Date: Fri, 15 Oct 2010 09:43:54 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Cache-Control: no-cache
Location: http://ak-media.soundcloud.com/9Y5jQY82MWn0.128.mp3?AWSAccessKeyId=0ZD
ZC4RXJ8N15Y1R1M82&Expires=1287135854&Signature=52c%2Bvqsw%2BCM382YPE9%2BBRidNPyI
%3D&__gda__=1287135854_dbb2843578dd02702c7f1dc326df87bc
X-Runtime: 5
@javouhey
javouhey / sbt on cygwin
Created November 29, 2010 12:10
Getting sbt to work in cygwin 1.77
dir=`dirname $0`
stty -icanon min 1 -echo > /dev/null 2>&1
java -Djline.terminal=jline.UnixTerminal -Xmx512M -jar `cygpath -w $dir`/sbt-launch-0.7.4.jar "$@"
stty icanon echo > /dev/null 2>&1
@javouhey
javouhey / gist:781668
Created January 16, 2011 09:16
Producer Consumer using Semaphores
"""
Producer produces numbers 1..10
Consumer runs first & then blocks
Solution: uses semaphores
"""
from threading import Thread
from threading import Semaphore
@javouhey
javouhey / LICENSE.txt
Created May 27, 2011 13:17 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
try:
raise ValueError('babi')
except:
import sys
a = sys.exc_info()
print a
(<type 'exceptions.ValueError'>, ValueError('babi',), <traceback object at 0x95e80a4>)
@javouhey
javouhey / gist:1127218
Created August 5, 2011 09:42
The descriptor for a python LogHandler
In [21]: log.fogbugz('a44 %s', 'hello')
CRITICAL 2011-08-05 09:07:09,316 handler 11742 -1215838528 a44 hello
name=2fb
msg=a44 %s
<type 'str'>
CRITICAL a44 hello
record.__dict__=>{'threadName': 'MainThread', 'name': '2fb', 'thread': -1215838528, 'created': 1312528029.316421, 'process': 11742, 'processName': 'MainProcess', 'args': ('hello',), 'module': 'handler', 'filename': 'handler.py', 'levelno': 50, 'exc_text': None, 'pathname': '/var/www/BIS/django-sites/p/utils/logging/handler.py', 'lineno': 79, 'msg': 'a44 %s', 'exc_info': None, 'message': 'a44 hello', 'funcName': 'fogbugz', 'relativeCreated': 2657279.0589332581, 'levelname': 'CRITICAL', 'msecs': 316.4210319519043}
@javouhey
javouhey / gist:1136072
Created August 10, 2011 03:34
How to test fraud checker

Browser testing

  1. http://gavin/accounting/fraud_unit_test/
  2. http://gavin/accounting/ajax/fraud_check/
  3. http://gavin/accounting/ajax/fraud_check/?async=True

How to test on django shell:

@javouhey
javouhey / gist:1141347
Created August 12, 2011 03:06
Facing WSGI error "IOError: sys.stdout access restricted by mod_wsgi"
@javouhey
javouhey / gist:1145583
Created August 15, 2011 01:49
Python log handler
class GavinLogHandler(logging.Handler):
""" my experiment """
def emit(self, record):
print "name=" + str(record.name)
if record.exc_info:
print "exc_info=" + str(record.exc_info)
if record.exc_text:
print "exc_text=" + str(record.exc_text)