Skip to content

Instantly share code, notes, and snippets.

@rduplain
rduplain / supervisord_minimal.conf
Created September 2, 2010 18:16
Configuration examples for supervisord, a process control system for projects.
[supervisord]
nodaemon=true
[supervisorctl]
serverurl=unix://supervisor.sock
[unix_http_server]
file=supervisor.sock
[rpcinterface:supervisor]
@rduplain
rduplain / xscreensaver-watch.sh
Created October 8, 2012 15:02
Watch xscreensaver lock/unlock events and act on them.
#!/bin/sh
# Watch xscreensaver and react to status changes.
#
# Replaced my previous perl-based recipe with this:
# http://semicomplete.googlecode.com/svn/tools/xscreensaver-watch.sh
#
# Include somewhere in X session startup with:
#
# xscreensaver-watch &
@rduplain
rduplain / haproxy-servers.cfg
Last active June 10, 2022 13:23
Rewrite haproxy configuration and reload service.
# Edit this file then run `update-haproxy haproxy-servers.cfg`.
# Alternatively, use a shell pipeline to build server list `... | update-haproxy`.
server demo1 127.0.0.1:8001 check cookie demo1 weight 100
server demo2 127.0.0.1:8002 check cookie demo2 weight 100
server demo3 127.0.0.1:8003 check cookie demo3 weight 0
server demo4 127.0.0.1:8004 check cookie demo3 weight 0
@rduplain
rduplain / vpn
Last active October 10, 2021 10:11
OpenVPN rc.d script for VPN client on BSD (i.e. jail): connect to VPN, start another service once VPN is connected.
#!/bin/sh
# PROVIDE: vpn
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# vpn: connect to VPN, start another service once VPN is connected.
#
# Uses OpenVPN and assumes the configuration does not need any authentication
# beyond the given .conf file. Consider an approach using `expect` if needed:
#
@rduplain
rduplain / grub_iso.sh
Last active July 23, 2021 21:14
Bootloader configuration for multiple .iso files on a USB drive.
#!/bin/sh
# Use grub to boot .iso files directly from /boot/iso.
#
# This file lives at /etc/grub.d/25_iso and is executable.
#
# Open .iso files to inspect internal /boot files for grub config hints.
# /boot is on the third partition of a gpt-partitioned USB drive.
ISO_PART_UUID="0a5086cd-8fdf-4ae0-a248-67411ebbbb18" # UUID of /boot `blkid`.
ISO_PART_NUMBER=3
@rduplain
rduplain / app.py
Created January 19, 2012 17:28
Plot a PNG using matplotlib in a web request, using Flask.
"Plot a PNG using matplotlib in a web request, using Flask."
# Install dependencies, preferably in a virtualenv:
#
# pip install flask matplotlib
#
# Run the development server:
#
# python app.py
#
@rduplain
rduplain / Makefile
Created April 27, 2013 02:06
Makefile for key interactions on a Flask project deployed on heroku.
# Key project interactions, but not all dependencies are resolved by make.
help:
@heroku help
run:
python manage.py runserver
shell:
python manage.py shell
@rduplain
rduplain / match.hy
Last active December 22, 2020 06:22
Getting started with hy (hylang.org), a simple example.
#!/usr/bin/env hy
;; match.hy - Getting started with hy (hylang.org), a simple example.
;;
;; As executable, `chmod +x match.hy`:
;;
;; $ ./match.hy '(.*), (.*)!' 'Hello, world!'
;; ('Hello', 'world')
;;
;; Developed on hy master 14c412c (after 0.11.1) on Python 3.5.
;;
@rduplain
rduplain / gist:1249199
Created September 28, 2011 20:41
Get a module's docstring in Python without executing it.
import code
def get_module_docstring(filepath):
"Get module-level docstring of Python module at filepath, e.g. 'path/to/file.py'."
co = compile(open(filepath).read(), filepath, 'exec')
if co.co_consts and isinstance(co.co_consts[0], basestring):
docstring = co.co_consts[0]
else:
docstring = None
return docstring
@rduplain
rduplain / keybase.md
Created June 10, 2020 05:03
keybase.io GitHub identity

Keybase proof

I hereby claim:

  • I am rduplain on github.
  • I am rduplain (https://keybase.io/rduplain) on keybase.
  • I have a public key ASBpT-VcyhSXJu1CXyxN0b1TgOZANozAJFVXKVeZSPaxjQo

To claim this, I am signing this object: