Skip to content

Instantly share code, notes, and snippets.

View meejah's full-sized avatar

meejah meejah

View GitHub Profile
@meejah
meejah / blam.py
Created April 3, 2014 03:05
"tail -f" style file-reading in Twisted
#!/usr/bin/env python
import sys
from twisted.internet.interfaces import IReadDescriptor
from twisted.internet.fdesc import setNonBlocking
from twisted.internet import reactor
from zope.interface import implementer
@implementer(IReadDescriptor)
class Blam(object):
@meejah
meejah / keybase.md
Created August 4, 2014 17:55
keybase.md

Keybase proof

I hereby claim:

  • I am meejah on github.
  • I am meejah (https://keybase.io/meejah) on keybase.
  • I have a public key whose fingerprint is 9D5A 2BD5 688E CB88 9DEB CD3F C260 2803 1280 69A7

To claim this, I am signing this object:

@meejah
meejah / rc4-min.py
Created October 22, 2014 19:47
Attempt at a Twitter-sized RC4 implementation
# attempt to make a tweet-sized RC4
# this is 241 characters... :/
# return value comes in "z" which must be an empty array to start
def R(k,C,z):
r=range;o=ord;x=256;l=len
def s(A,x,y):A[x],A[y]=A[y],A[x]
S=r(x);j=0
for i in r(x):j=(j+S[i]+o(k[i%l(k)]))%x;s(S,i,j)
i=j=0
@meejah
meejah / asyncio_testing.py
Last active August 29, 2015 14:17
Isn't there a nice way to write tests for asyncio-based code?
from __future__ import print_function
import asyncio
import asyncio.test_utils
import unittest
class Other(object):
def __init__(self):
self.future = asyncio.Future()
@meejah
meejah / README
Created March 25, 2015 18:50
sub (sub) process coverage
nothing, trying to make bare repo.
-*- mode:outline -*-
* customization notes
. there's a pre-configured "debian-forensics" one (for "lb config -p
debian-forensics")
. it seems that there's a problem building, e.g., stable on a wheezy
system -- maybe you can only go "forwards"? For now, just building
wheezy-on-wheezy.
@meejah
meejah / gist:d27e9059e9cb54f1d00a
Created October 20, 2015 08:16
twisted: mixed @inlineCallbacks + Deferred
from twisted.internet.defer import Deferred, inlineCallbacks, returnValue
d0 = Deferred()
d1 = Deferred()
d2 = Deferred()
@inlineCallbacks
def foo(arg):
print 'foo', arg
from twisted.internet.defer import Deferred, inlineCallbacks, returnValue
d0 = Deferred()
d1 = Deferred()
d2 = Deferred()
def check_value(arg, gold):
print "check_value", arg, gold
assert gold == arg
@meejah
meejah / twisted3.py
Created October 20, 2015 08:46
twisted3.py
from twisted.internet.defer import Deferred, inlineCallbacks, returnValue
d0 = Deferred()
d1 = Deferred()
d2 = Deferred()
def check_value(arg, gold):
print "check_value", arg, gold
assert gold == arg
@meejah
meejah / make-at-branch.sh
Created June 3, 2013 20:25
Create a SVN repository that has @NNN branches when using "git svn clone"
#!/bin/bash
## create @nnn branches by simulating a re-organization on the server
mkdir /tmp/svnplay
pushd /tmp/svnplay
svnadmin create svnrepo
mkdir svninit
mkdir svninit/foo