Skip to content

Instantly share code, notes, and snippets.

View skimbrel's full-sized avatar

Sam Kimbrel skimbrel

View GitHub Profile
In [1]: def do_a_nasty(oops=[]):
...: oops.append(3)
...: print oops
...:
In [2]: do_a_nasty()
[3]
In [3]: do_a_nasty()
[3, 3]
2079 Safari::Application::tryToTerminateWhenReady() (in Safari) + 323 [0x7fff991a0b09]
+ 2079 -[BrowserApplication tryToTerminate] (in Safari) + 56 [0x7fff991eb2eb]
+ 2079 -[NSApplication terminate:] (in AppKit) + 1604 [0x7fff906bc3e4]
+ 2079 -[NSNotificationCenter postNotificationName:object:userInfo:] (in Foundation) + 68 [0x7fff96a2c4aa]
+ 2079 _CFXNotificationPost (in CoreFoundation) + 2893 [0x7fff91075c5d]
+ 2079 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ (in CoreFoundation) + 12 [0x7fff91181fcc]
+ 2079 -[AppController _savePendingData:] (in Safari) + 153 [0x7fff9919d1ca]
+ 2079 -[GlobalHistoryObjC savePendingChangesBeforeTermination] (in Safari) + 46 [0x7fff9934cf6c]
+
@skimbrel
skimbrel / large-type.scpt
Last active December 31, 2015 02:39
a stupid hack to get at alfred's large-type feature from the shell, now with less paste buffer clobbering
on run argv
tell application "Alfred 2"
search item 1 of argv
tell application "System Events"
keystroke "l" using {command down}
end tell
end tell
end run
from foo import (bar,
baz,
quux
)
# or
from foo import bar
from foo import baz
from foo import quux
$ curl -i https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=sfmta_muni
HTTP/1.1 400 Bad Request
content-length: 61
content-type: application/json; charset=utf-8
date: Wed, 13 Nov 2013 22:04:41 UTC
server: tfe
set-cookie: guest_id=v1%3A138438028115535261; Domain=.twitter.com; Path=/; Expires=Fri, 13-Nov-2015 22:04:41 UTC
strict-transport-security: max-age=631138519
{"errors":[{"message":"Bad Authentication data","code":215}]}
{"res":0,"hash":"52829d29e9a09","btype":0,"barg":0,"fp":10,"waves":[{"seq":"1","monsters":[{"type":0,"num":"476","lv":3,"item":"476","inum":3,"pval":0},{"type":0,"num":"479","lv":3,"item":0,"inum":0,"pval":0}]},{"seq":"2","monsters":[{"type":0,"num":"220","lv":8,"item":0,"inum":0,"pval":0}]},{"seq":"3","monsters":[{"type":0,"num":"412","lv":3,"item":0,"inum":0,"pval":0}]},{"seq":"4","monsters":[{"type":0,"num":"284","lv":5,"item":0,"inum":0,"pval":0}]},{"seq":"5","monsters":[{"type":0,"num":"215","lv":5,"item":"33","inum":5,"pval":0}]},{"seq":"6","monsters":[{"type":0,"num":"596","lv":4,"item":"596","inum":4,"pval":0}]}]}
In [1]: class Foo(object):
...: def bar(self):
...: print 'hi'
...:
In [2]: f = Foo()
In [3]: f.__dict__['bar']()
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
>>> def create_counter():
... count = 0
... def _counter():
... nonlocal count
... count += 1
... return count
... return _counter
...
>>> f = create_counter()
>>> f()
In [31]: def create_counter():
....: def _counter():
....: global count
....: count += 1
....: return count
....: return _counter
....:
In [32]: f = create_counter()
In [13]: def counter_factory():
....: count = 0
....: def _counter():
....: count += 1
....: return _counter
....:
In [14]: f = counter_factory()
In [15]: f()