Skip to content

Instantly share code, notes, and snippets.

rduplain / haproxy-servers.cfg
Last active Jun 16, 2021
Rewrite haproxy configuration and reload service.
View haproxy-servers.cfg
# Edit this file then run `update-haproxy haproxy-servers.cfg`.
# Alternatively, use a shell pipeline to build server list `... | update-haproxy`.
server demo1 check cookie demo1 weight 100
server demo2 check cookie demo2 weight 100
server demo3 check cookie demo3 weight 0
server demo4 check cookie demo3 weight 0
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 / 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 /
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 /
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 Jan 28, 2020
Demo of the Python `code` module, for interaction and DSLs.

import code

This is a demonstration of the Python [code][1] module, which allows for an interactive interpreter to be embedded into a Python program.

code.interact(banner=None, readfunc=None, local=None)

Convenience function to run a read-eval-print loop. This creates a new instance of [InteractiveConsole][2] and sets readfunc to be used as the

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 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 /
Created Oct 29, 2013
Simple examples to get started with the vertigo package.
import vertigo
class EmptyGraphNode(vertigo.GraphNode):
def value(self):
return None
def key_iter(self):
return ()
rduplain / gist:6886040
Created Oct 8, 2013
Cronic - A cure for Cron's chronic email problem - by Chuck Houpt -
View gist:6886040
# Cronic v2 - cron job report wrapper
# Copyright 2007 Chuck Houpt. No rights reserved, whatsoever.
# Public Domain CC0:
set -eu