Skip to content

Instantly share code, notes, and snippets.

@russss
russss / grab_mjpeg_frame.py
Created August 13, 2011 12:26
Grab a single frame from an MJPEG stream
#!/usr/bin/env python
import socket
import sys
if len(sys.argv) != 3:
print "Usage: %s host:port destfile.jpg" % sys.argv[0]
sys.exit(1)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host, port = sys.argv[1].split(':')
@russss
russss / paypal2ofx.py
Created August 7, 2011 22:15
Convert a paypal CSV export to an OFX file
import csv
import sys
from collections import namedtuple
rows = csv.reader(sys.stdin)
fields = [field.strip().lower().replace(' ', '_').replace('/', '_')
for field in rows.next() if field.strip() != '']
PaypalRecord = namedtuple('PaypalRecord', fields)
@russss
russss / gist:1064891
Created July 5, 2011 14:04
Git post-receive hook to post commit details to an AMQP topic
#!/usr/bin/env python
""" Git post-receive hook to publish commit data to an AMQP topic.
apt-get install python-git python-amqplib
or:
easy_install amqplib gitpython
"""
import os, sys, json
from datetime import datetime
from git import *
@russss
russss / build-tblk.rb
Created May 31, 2011 16:46
Easily generate a .tblk Tunnelblick package
#!/usr/bin/env ruby
require 'fileutils'
CA_DIR = '/path/to/ca/keys/'
HOST = '1.2.3.4'
if not ARGV[0]:
raise "Provide a certificate name as an argument"
end
@russss
russss / mirrordir.py
Created January 19, 2011 12:34
Mirror new files in a directory to another machine
# usage: python mirrordir.py ./directory myuser@host:/path
import sys, pyinotify, subprocess
class Handler(pyinotify.ProcessEvent):
def process_IN_CLOSE_WRITE(self, event):
subprocess.call(("scp", event.pathname, sys.argv[2]))
if __name__ == '__main__':
wm = pyinotify.WatchManager()
notifier = pyinotify.Notifier(wm, default_proc_fun=Handler())
#!/usr/bin/ruby
# Download NASA MODIS imagery and use it as a desktop background.
# You'll need ImageMagick installed for this to work.
require 'date'
require 'net/http'
# Screen width/height
X = 2580
Y = 1024
#0 0x00014883 in Resolver::dispatch (this=0xa06950, rq=@0xb0080424, local_only=false) at /Users/russ/playdar/playdar-daemon/src/resolvers/resolver.cpp:75
#1 0x0008a98b in playdar_request_handler::handle_rest_api (this=0xb0184ee4, qs=@0xb00806b4, req=@0x100b628, rep=@0x100b650) at /Users/russ/playdar/playdar-daemon/src/playdar/playdar_request_handler.cpp:173
#2 0x00091937 in playdar_request_handler::handle_request (this=0xb0184ee4, req=@0x100b628, rep=@0x100b650) at /Users/russ/playdar/playdar-daemon/src/playdar/playdar_request_handler.cpp:78
#3 0x00186b16 in moost::http::connection<playdar_request_handler>::handle_read (this=0x1009600, e=@0xa06950, bytes_transferred=477) at request_handler_base.hpp:27
#4 0x00160006 in boost::asio::asio_handler_invoke<boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, moost::http::connection<playdar_request_handler>, boost::system::error_code const&, unsigned long>, boost::_bi::list3<boost::_bi::value<boost::shared_ptr<moost::http::connection