Skip to content

Instantly share code, notes, and snippets.

@rduplain
rduplain / gist:e637ac9205d7df82dff4
Last active August 29, 2015 14:02
python: method delegation and copy-able threading.Lock
from threading import Lock
def build_delegating_method(delegate_name, method_name):
def delegating_method(self, *a, **kw):
delegate = getattr(self, delegate_name)
method = getattr(delegate, method_name)
return method(*a, **kw)
doc_format = "Calls self.{}.{}."
delegating_method.__name__ = method_name
@rduplain
rduplain / receipt.py
Created August 12, 2014 03:09
Simple project to print text to Epson receipt.
# Print text to serial Epson printer. Escape codes are Epson ESC/POS.
#
# pip install pyserial jeni # Developed on Python 3.4.
import struct
import serial
from jeni import annotate, partial
from jeni import Injector
@rduplain
rduplain / wait.py
Last active August 29, 2015 14:06
Avoid race conditions by waiting for 200 OK on a URL.
import datetime as dt
import time
import requests # pip install requests
def get_ok(url):
"GET url and raise an exception if not 200 OK."
r = requests.get(url)
r.raise_for_status()
@rduplain
rduplain / Vagrantfile
Last active August 29, 2015 14:07
Simple Ubuntu LTS vagrant.
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.hostname = "scratch1"
config.vm.box = "ubuntu/trusty64" # vagrantcloud, use vagrant 1.5+
# config.vm.box_url = "http://domain.com/path/to/above.box"
@rduplain
rduplain / start_ventrilo.bat
Last active August 29, 2015 14:12
Wait, then launch Ventrilo, in order to include in autostart programs.
@echo off
title Waiting to Launch Ventrilo
rem Delayed launch ventrilo, since it does not as executable in Startup.
rem Sleep for 60s using a dummy ping.
ping 127.0.0.1 -n 60 > nul
start "Ventrilo" "C:\Program Files\Ventrilo\Ventrilo.exe" -cHOST:PORT:PASSWORD
@rduplain
rduplain / fancontrol-init.sh
Created October 5, 2010 16:33
SysV init script for fancontrol to keep deskside servers quiet (USE WITH CAUTION).
#! /bin/sh
# Save as /etc/init.d/fancontrol
# update-rc.d fancontrol defaults 90 10
#
# Based on /etc/init.d/skeleton
# Tested on a Supermicro 1U box running Ubuntu 10.04 x86_64.
### BEGIN INIT INFO
# Provides: fancontrol
# Required-Start:
# Required-Stop:
@rduplain
rduplain / .bootstrap.md
Created October 5, 2010 21:17
Instructions and configuration to get started with gitolite git hosting.

Git Hosting

  • GitHub.com provides great public repository hosting.
  • vanilla git over ssh works for simple project structures.
  • gitosis works well where you'd like to use ssh pubkeys without shell access.
  • gitolite works well where you'd like gitosis to have finer access control.

How I setup our gitolite server

@rduplain
rduplain / mirror-github
Created February 1, 2011 17:21
Mirror a GitHub project to a local filesystem.
#!/bin/bash
# usage: mirror-github <account_name> <project_name>
git clone --mirror git@github.com:${1}/${2}.git
@rduplain
rduplain / README.md
Created February 17, 2011 20:02
Sample prototyping schema for use with vanilla Apache Solr 1.4.1 download.

Sample prototyping schema for use with vanilla Apache Solr 1.4.1 download.

tar -xvzf ~/download/apache-solr-1.4.1.tgz
cd apache-solr-1.4.1/example/
vi solr/conf/schema.xml # edit into something like the schema here
java -jar start.jar # look for errors, otherwise have fun!

Start prototyping! To clean out the data index and start over, interrupt the Jetty server (Control-C) and:

@rduplain
rduplain / dropbox.conf
Created April 21, 2011 21:07
Dropbox Upstart
description "Sync Dropbox web-based file share on local system."
author "Ron DuPlain <ron.duplain@willowtreeapps.com>"
start on (net-device-up
and local-filesystems
and runlevel [2345])
stop on runlevel [!2345]
respawn
env LANG=en_US.UTF-8