Skip to content

Instantly share code, notes, and snippets.

View skimbrel's full-sized avatar

Sam Kimbrel skimbrel

View GitHub Profile
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.
@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:

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 / 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) {
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
#!/bin/sh
SSHV="SSH_CLIENT SSH_TTY SSH_AUTH_SOCK SSH_CONNECTION DISPLAY"
for x in ${SSHV} ; do
(eval echo $x=\$$x) | sed 's/=/="/
s/$/"/
s/^/export /'
done 1>$HOME/.bash_helpers/fixssh
return {
'hosts': list(set(chain.from_iterable(
[app.hosts for (name,app) in self.apps.iteritems()]
)))
}
@skimbrel
skimbrel / gist:3443536
Created August 23, 2012 23:34
ERMAHGERD, PERTHERN
DERF FERLER_QERLERFER_HDFS_PERTH(PERTH):
"""ERF PERTH ERSNT ERN ``HDFS://`` ERL, TERN ERT ERNT ERN."""
ERF PERTH.STERTSWERTH('HDFS://') ER PERTH.STERTSWERTH('S3N:/'):
RERTERN PERTH
ERLERF PERTH.STERTSWERTH('/'):
RERTERN 'HDFS://' + PERTH
ERLS:
RERTERN 'HDFS:///ERSER/%S/%S' % (GERTPERS.GERTERSER(), PERTH)
@skimbrel
skimbrel / gist:3555464
Created August 31, 2012 16:31
git runs on trekbabble
$ git push origin foo
Counting objects: 16, done.
Delta compression using up to 24 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 728 bytes, done.
Total 6 (delta 5), reused 0 (delta 0)
Auto packing the repository for optimum performance.
fatal: protocol error: bad line length character: Remo
error: error in sideband demultiplexer