Skip to content

Instantly share code, notes, and snippets.

View mithrandi's full-sized avatar

Tristan Seligmann mithrandi

View GitHub Profile
#!/usr/bin/python
from os import environ
from socket import gethostname
from boto import connect_route53
from boto.route53.record import ResourceRecordSets
IF_NAME = 'ppp0'
AWS_ACCESS_KEY = '...'
AWS_SECRET_KEY = '...'
for thing in [thing1, thing2]:
yield blahblahblah(thing)
####
for thing in [
thing1, thing2, thing3, thing4, thing5]:
yield blahblahblah(thing)
####

Keybase proof

I hereby claim:

  • I am mithrandi on github.
  • I am mithrandi (https://keybase.io/mithrandi) on keybase.
  • I have a public key whose fingerprint is DB24 E315 EDAA AC13 D646 7099 58C0 FB1C DE3B 7600

To claim this, I am signing this object:

@mithrandi
mithrandi / axiomatic
Created March 31, 2014 12:53
axiomatic smart launch script
#!/bin/zsh
source /Users/mithrandi/Library/Python/2.7/bin/virtualenvwrapper_lazy.sh
workon Fusion
BRANCH=$(hg branch --repository $HOME/code/Fusion)
STORE="dev.axiom.$BRANCH"
if [[ ! -d $STORE ]] {
if [[ -e $STORE ]] {
echo "Found unexpected $STORE, exiting."
exit 1
}
@mithrandi
mithrandi / CVE-2014-0160.patch
Created April 10, 2014 18:37
Debian CVE-2014-0160 patch
From 96db9023b881d7cd9f379b0c154650d6c108e9a3 Mon Sep 17 00:00:00 2001
From: "Dr. Stephen Henson" <[email protected]>
Date: Sun, 6 Apr 2014 00:51:06 +0100
Subject: [PATCH] Add heartbeat extension bounds check.
A missing bounds check in the handling of the TLS heartbeat extension
can be used to reveal up to 64k of memory to a connected client or
server.
Thanks for Neel Mehta of Google Security for discovering this bug and to
def _rangesOverlap(start1, end1, start2, end2):
"""
Check if [start1, end1) and [start2, end2) overlap.
@type start1: L{datetime.datetime}
@type end1: L{datetime.datetime}
@type start2: L{datetime.datetime}
@mithrandi
mithrandi / gist:11197809
Created April 22, 2014 23:24
apt-file use
mithrandi@elvandar:~> apt-file search -x '/usr/bin/python[0-9.]*$'
python-minimal: /usr/bin/python
python-minimal: /usr/bin/python2
python2.6-dbg: /usr/lib/debug/usr/bin/python2.6
python2.6-minimal: /usr/bin/python2.6
python2.7-dbg: /usr/lib/debug/usr/bin/python2.7
python2.7-minimal: /usr/bin/python2.7
python3-minimal: /usr/bin/python3
python3.2-minimal: /usr/bin/python3.2
python3.3-dbg: /usr/lib/debug/usr/bin/python3.3
@mithrandi
mithrandi / matchers.py
Created April 23, 2014 02:45
SuccessResultOf
from testtools.matchers import Mismatch
class SuccessResultOf(object):
"""
Match if a Deferred has fired with a result.
"""
def __init__(self, resultMatcher=None):
self.resultMatcher = resultMatcher
@mithrandi
mithrandi / sha256sum.py
Created April 26, 2014 02:55
Quick sha256sum implementation in Python
from hashlib import sha256
from sys import argv
for fn in argv[1:]:
if fn == '-':
f = sys.stdin
else:
f = open(fn, 'rb')
with f:
print '%s *%s' % (sha256(f.read()).hexdigest(), fn)
suffixes = ('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB')
def saneDataSize(size):
index = int(floor(log(abs(size), 1024)))
index = min(index, len(suffixes) - 1)
index = max(index, 0)
factor = 1024 ** index
return '%0.3f %s' % (float(size) / factor, suffixes[index])