Skip to content

Instantly share code, notes, and snippets.

View mattieb's full-sized avatar

Mattie B. mattieb

View GitHub Profile
@mattieb
mattieb / keybase.md
Created March 6, 2014 23:26
Keybase.io proof

Keybase proof

I hereby claim:

  • I am zigg on github.
  • I am zigg (https://keybase.io/zigg) on keybase.
  • I have a public key whose fingerprint is E043 900F 94AF E80A 7633 65F4 AB46 823F CFBF 2B13

To claim this, I am signing this object:

@mattieb
mattieb / gpgstatusfd.py
Created January 6, 2014 22:03
blocking read from gpg status-fd
#!/usr/bin/env python3.4
import os
import subprocess
fd_r, fd_w = os.pipe()
try:
p = subprocess.Popen(
[
@mattieb
mattieb / catclient.py
Last active January 2, 2016 10:09
a client for /bin/cat in Python 3.4 asyncio
#!/usr/bin/env python3.4
import asyncio
class CatClient(asyncio.SubprocessProtocol):
"""meows at /bin/cat"""
@mattieb
mattieb / object.py
Created December 19, 2013 21:54
object vs. Object
>>> o1 = object()
>>> o1.foo = True
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'object' object has no attribute 'foo'
>>> class Object(object):
... pass
...
>>> o2 = Object()
>>> o2.foo = True
@mattieb
mattieb / twistcursive.py
Last active December 31, 2015 20:49
recursive Twisted Deferreds, now with flat stack
import sys
import traceback
from twisted.internet.defer import Deferred
# a place to queue up the Deferreds we'll be generating...
defList = []
def err(s):
@mattieb
mattieb / unix_xmlrpc.py
Last active December 31, 2015 18:59
Python xmlrpclib client over Unix sockets
#!/usr/bin/env python
#
# Works for Python 2.4. Newer versions of Python changed xmlrpclib, a lot...
#
import httplib
import socket
import xmlrpclib
@mattieb
mattieb / bashing_bash_2.txt
Created November 19, 2013 16:51
bashing bash, the encore
megaweapon:foo matt$ # an encore to https://gist.github.com/zigg/7548324
megaweapon:foo matt$ rm baz/bar
megaweapon:foo matt$ bar
-bash: /tmp/foo/baz/bar: No such file or directory
megaweapon:foo matt$ which bar
/tmp/foo/bar
megaweapon:foo matt$ hash -r
megaweapon:foo matt$ bar
this isn't the bar you're looking for
@mattieb
mattieb / bashing_bash.txt
Created November 19, 2013 16:39
bashing bash
megaweapon:tmp matt$ mkdir -p foo/baz
megaweapon:tmp matt$ cd foo
megaweapon:foo matt$ PATH=/tmp/foo/baz:/tmp/foo:$PATH
megaweapon:foo matt$ cat >bar
#!/bin/sh
echo "this isn't the bar you're looking for"
megaweapon:foo matt$ chmod +x bar
megaweapon:foo matt$ bar
this isn't the bar you're looking for
megaweapon:foo matt$ cat >baz/bar
@mattieb
mattieb / vagrant.pp
Created November 11, 2013 19:48
Puppet manifest for octothorpe development in a Vagrant VM (currently broken)
class {'asterisk':
configs => false,
}
file {'/etc/asterisk':
require => Class['asterisk'],
ensure => link,
target => '/vagrant/etc/asterisk',
force => true,
}
@mattieb
mattieb / service1.apacheconf
Last active December 26, 2015 03:08
Running multiple mod_wsgi applications under different accounts
# In CentOS 5, mod_wsgi can be installed from EPEL
# <http://fedoraproject.org/wiki/EPEL>. I use mod_wsgi to run several
# independent WSGI services, each of which is contained in its own
# RPM.
#
# In addition to the LoadModule statement covering mod_wsgi itself,
# each service carries its own .conf file that is installed to
# /etc/httpd/conf.d. Because they are associated with different
# subsystems, they must be run under appropriate accounts. Determining
# how to do so took some poring over the documentation.