Skip to content

Instantly share code, notes, and snippets.

rduplain /
Created Jun 3, 2014
Is stdin a tty? Use this to determine whether to provide prompt or just read stdin for input.
import sys
if sys.stdin.isatty():
print('you are a tty')
print('you are not a tty')
rduplain / gist:e637ac9205d7df82dff4
Last active Aug 29, 2015
python: method delegation and copy-able threading.Lock
View gist:e637ac9205d7df82dff4
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 /
Created Aug 12, 2014
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 /
Last active Aug 29, 2015
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)
rduplain / Vagrantfile
Last active Aug 29, 2015
Simple Ubuntu LTS vagrant.
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.hostname = "scratch1" = "ubuntu/trusty64" # vagrantcloud, use vagrant 1.5+
# config.vm.box_url = ""
rduplain / start_ventrilo.bat
Last active Aug 29, 2015
Wait, then launch Ventrilo, in order to include in autostart programs.
View start_ventrilo.bat
@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 -n 60 > nul
start "Ventrilo" "C:\Program Files\Ventrilo\Ventrilo.exe" -cHOST:PORT:PASSWORD
rduplain / supervisord_minimal.conf
Created Sep 2, 2010
Configuration examples for supervisord, a process control system for projects.
View supervisord_minimal.conf
rduplain /
Created Oct 5, 2010
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.
# Provides: fancontrol
# Required-Start:
# Required-Stop:
rduplain /
Created Oct 5, 2010
Instructions and configuration to get started with gitolite git hosting.

Git Hosting

  • 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 / mirror-github
Created Feb 1, 2011
Mirror a GitHub project to a local filesystem.
View mirror-github
# usage: mirror-github <account_name> <project_name>
git clone --mirror${1}/${2}.git