Skip to content

Instantly share code, notes, and snippets.

@bboe
bboe / rabbit_admin.py
Created Oct 17, 2014
Tool to interact with rabbitmq queues. Depends on docopt and pika (pip install docopt pika).
View rabbit_admin.py
#!/usr/bin/env python
"""Usage: rabbit_admin [options] delete QUEUE
rabbit_admin [options] add QUEUE <KEY:VALUE>...
rabbit_admin [options] dump QUEUE
-D --not-durable don't use a durable queue
-h --help show this
-H --host HOST rabbitmq host [default: localhost]
"""
@bboe
bboe / image_attachment_downloader.py
Last active Aug 29, 2015
Email image attachment download (POP3 support only for now)
View image_attachment_downloader.py
#!/usr/bin/env python
from __future__ import print_function
from functools import wraps
from getpass import getpass
from hashlib import sha512
from poplib import POP3_SSL, error_proto
import email
import os
import socket
import sys
@bboe
bboe / umail_delete.py
Created Sep 22, 2011
Empty UCSB's umail inbox. Run via: ./umail_delete.py -u <USERNAME> -d
View umail_delete.py
#!/usr/bin/env python
import getpass, imaplib, sys
from optparse import OptionParser
def main():
parser = OptionParser()
parser.add_option('-s', '--save', help='file to save contents to')
parser.add_option('-d', '--delete', action='store_true',
help='delete contents')
@bboe
bboe / tether.sh
Created Oct 20, 2011
OSX Lion tether to Android script using Azilink and Tunnelblick
View tether.sh
#!/bin/bash
#
# azilink for OS X Lion
# based on http://pastie.org/405289 but works with Tunnelblick only
# (no need to install a separate copy of OpenVPN2 from macports
# or building from source by hand, thankfully)
# Requires:
# - azilink running on android phone (http://code.google.com/p/azilink/)
# (run the app and check the box to start the service).
# - adb on system path (comes with the Android SDK;
@bboe
bboe / job_manager.c
Created Feb 23, 2012
Process-based Job Management in C
View job_manager.c
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <sys/select.h>
#include <sys/wait.h>
#include "job_manager.h"
volatile sig_atomic_t multiprocess_running = 0;
@bboe
bboe / deploy.sh
Last active Dec 14, 2015
PyPi package deployment script. Depends on having an available pgp key to sign packages and the tag.
View deploy.sh
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $(basename $0) package_name"
exit 1
fi
package=$1
status=$(git status | head -n 1)
@bboe
bboe / github_protect_master.py
Created Dec 15, 2015
Enable master branch protection on all github repositories you are an owner of.
View github_protect_master.py
#!/usr/bin/env python
from __future__ import print_function
REPO_URL = 'git+git://github.com/sigmavirus24/github3.py.git'
import os
import sys
try:
from github3 import login
except ImportError:
@bboe
bboe / reddit_oauth.py
Created Jun 5, 2015
Create permanent reddit oauth tokens
View reddit_oauth.py
#!/usr/bin/env python
"""Script to generate permenant OAuth tokens for the desired reddit scope."""
from __future__ import print_function
import os
import praw
import sys
from pprint import pprint
View keybase.md

Keybase proof

I hereby claim:

  • I am bboe on github.
  • I am bboe (https://keybase.io/bboe) on keybase.
  • I have a public key ASCnZHoRFWpVE71FNpfWZCGn8V2Dq8V6jvoiYOz14NFOfwo

To claim this, I am signing this object:

@bboe
bboe / 01_sequential.rb
Last active Oct 11, 2017
Ruby Simple TCP Echo Servers
View 01_sequential.rb
#!/usr/bin/env ruby
require './common.rb'
require 'socket'
def main
server = server_socket('0.0.0.0', 1024)
loop do
handle_client(*server.accept)
end