Skip to content

Instantly share code, notes, and snippets.

View skimbrel's full-sized avatar

Sam Kimbrel skimbrel

View GitHub Profile
@skimbrel
skimbrel / silly.java
Created July 23, 2015 17:34
AWS client code. Ah, yes, the "dispatch async error handler then throw the exception anyway" pattern.
public Future<DeleteMessageBatchResult> deleteMessageBatchAsync(
final DeleteMessageBatchRequest deleteMessageBatchRequest,
final AsyncHandler<DeleteMessageBatchRequest, DeleteMessageBatchResult> asyncHandler)
throws AmazonServiceException, AmazonClientException {
return executorService.submit(new Callable<DeleteMessageBatchResult>() {
public DeleteMessageBatchResult call() throws Exception {
DeleteMessageBatchResult result;
try {
result = deleteMessageBatch(deleteMessageBatchRequest);
} catch (Exception ex) {
def footgun(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
if f(*args, **kwargs):
return frobnicate(f(*args, **kwargs))
return wrapper
@footgun
def side_effecting():
@skimbrel
skimbrel / keybase.md
Created March 7, 2014 18:37
keybase proof

Keybase proof

I hereby claim:

  • I am skimbrel on github.
  • I am skimbrel (https://keybase.io/skimbrel) on keybase.
  • I have a public key whose fingerprint is AD27 EF34 B9F1 96DF 5D34 4151 9F11 A7A8 DECD 30AA

To claim this, I am signing this object:

In [1]: import re
In [2]: p = re.compile('foo.*bar')
In [3]: s = 'foo' + 'a' * 2**16 + 'bar'
In [4]: len(s)
Out[4]: 65542
In [5]: p.
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}]}