Skip to content

Instantly share code, notes, and snippets.

View lucaswiman's full-sized avatar

[object Object] lucaswiman

View GitHub Profile
@lucaswiman
lucaswiman / .bash_profile
Created June 2, 2012 23:05
Extract link urls from Facebook App Urls
alias fix_facebook_url="pbpaste | python -c \"import sys, urlparse, cgi; print cgi.parse_qs(urlparse.urlparse(sys.stdin.read()).query)['redirect_uri'][0]\" | pbcopy"
======================================================================
ERROR: testSQL (tests.test_convert.TestConvertPyx12)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests/test_convert.py", line 78, in testSQL
db.execute( stmt )
OperationalError: table X278_2000E already exists
======================================================================
ERROR: testDjangoAdmin (tests.test_parse.TestDjangoVisitors)
@lucaswiman
lucaswiman / contextmanager_example.py
Last active December 23, 2015 23:19
Example of use of `contextlib.contextmanager`.
from time import sleep
def setup():
print 'setup'
def cleanup():
print 'cleanup'
from contextlib import contextmanager
nose==1.1.2
selenium==2.35.0
wsgiref==0.1.2
@lucaswiman
lucaswiman / gist:34b77989faa1c6316098
Created September 1, 2014 08:14
Random permutations problem.
import random
def random_permutation(n):
x = range(n)
random.shuffle(x)
return x
def cycle_decomposition(permutation):
unused = set(permutation)
@lucaswiman
lucaswiman / gist:dd8cddd0be68f58b89dc
Created January 26, 2015 02:32
Failures from django test run
======================================================================
ERROR: test_render_with_current_app (shortcuts.tests.ShortcutTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/lucaswiman/opensource/django/django/test/utils.py", line 455, in inner
return decorated(*args, **kwargs)
File "/Users/lucaswiman/opensource/django/tests/shortcuts/tests.py", line 84, in test_render_with_current_app
self.assertEqual(response.context.request.current_app, "foobar_app")
AttributeError: 'WSGIRequest' object has no attribute 'current_app'
?- [foo].
% foo compiled 0.00 sec, 3 clauses
true.
?- load_test_files(foo).
% /tmp/example/foo.plt compiled into plunit 0.00 sec, 6 clauses
true.
?- run_tests.
% PL-Unit: foo
@lucaswiman
lucaswiman / gist:5a79d06c309f12268e6e
Created November 27, 2015 21:52
example unicode handling
>>> from parsimonious.grammar import Grammar
>>>
>>> QUOTE_UNQUOTE_GRAMMAR = Grammar(u'''
... text = (unquoted / quoted)+
...
... unquoted = ~u"[^\u201c\u201d]+"
... quoted = ldquo text rdquo
... ldquo = ~u"\u201c"
... rdquo = ~u"\u201d"
... ''')
@lucaswiman
lucaswiman / Description.md
Created February 11, 2016 07:32
Output from diagnosing a race condition

This gist contains the output from validating that this commit: actually fixes the race condition manifested in the unpatched.output file. See the commit message for more information.

The outputs were generated using the following bash commands:

(for i in `seq 1 10`;
do
    java -jar /tmp/bad-jar.jar text1.png text1-symlink.png --multi
done) > /tmp/unpatched.output

(for i in `seq 1 10`;
file:///Users/lucaswiman/opensource/zxing/javase/text1.png (format: QR_CODE, type: TEXT):
Raw result:
text1
Parsed result:
text1
Found 3 result points.
Point 0: (44.0,156.0)
Point 1: (44.0,44.0)
Point 2: (156.0,44.0)
file:///Users/lucaswiman/opensource/zxing/javase/text1-symlink.png (format: QR_CODE, type: TEXT):