Skip to content

Instantly share code, notes, and snippets.

@alloy-d
alloy-d / mail.rb
Created May 25, 2011 06:04
Programmer requests complete data from large number of people regarding T-shirt sales.
#!/usr/bin/env ruby
require 'net/smtp'
require 'time'
require 'yaml'
size_map = {
'S' => 'small',
'M' => 'medium',
'L' => 'large',
'XL' => 'extra large',
@alloy-d
alloy-d / colemak.sh
Created July 20, 2011 21:55
Script to toggle Colemak keyboard layout properly on ThinkPad and Cr-48.
#!/bin/sh
ACTION=${1-help}
HOST=`hostname | cut -d'.' -f 1`
case "$ACTION" in
on)
setxkbmap us -variant colemak
xset r rate 255
case "$HOST" in
@alloy-d
alloy-d / 50-disable-touchpad-with-external-mouse.rules
Created July 21, 2011 05:18
udev rules and script for disabling a Synaptics touchpad when an external mouse is plugged in.
KERNEL!="hiddev[0-9]", GOTO="disable_touchpad_with_external_mouse_end"
ACTION=="add", RUN+="/usr/local/bin/touchpad off"
ACTION=="remove", RUN+="/usr/local/bin/touchpad on"
LABEL="disable_touchpad_with_external_mouse_end"
@alloy-d
alloy-d / disqus.tumblr.html
Created July 26, 2011 20:38
Disqus code, with line breaks and indents inserted so as to make it readable.
<script type="text/javascript">
var disqus_url = "{Permalink}";
var disqus_title ="{block:PostTitle}{PostTitle}{/block:PostTitle}";
</script>
{block:Permalink}
<div id="disqus_thread"></div>
<script type="text/javascript">
(function() {
var dsq = document.createElement('script');
@alloy-d
alloy-d / biggify.rb
Created August 10, 2011 05:37
Simple script to inline JS and CSS in an HTML file.
#!/usr/bin/env ruby
infile = File.new("index.html", "r")
outfile = File.new("big.html", "w")
mapfile = File.new("misc/urls", "r")
map = {}
while line = mapfile.gets do
parts = line.split(" ")
map[parts[0]] = parts[1]
@alloy-d
alloy-d / default.pdf.do
Created August 10, 2011 19:15
Generating PDFs with LaTeX and redo.
redo-ifchange $1.tex
TMPDIR="$3-dir"
TEXARGS="-output-directory $TMPDIR $1.tex"
mkdir $TMPDIR
pdflatex $TEXARGS > /dev/null
pdflatex $TEXARGS > /dev/null
mv $TMPDIR/resume.pdf $3
rm -rf $TMPDIR
@alloy-d
alloy-d / bashrc
Created October 13, 2011 04:55
It's a bashrc!
### SYSTEM DEFAULTS {{{1
if [ -f /etc/bashrc ]; then
source /etc/bashrc
fi
if [ -f /etc/bash_completion ]; then
source /etc/bash_completion
fi
### BASICS {{{1
@alloy-d
alloy-d / tmux.conf
Last active September 27, 2015 20:08
tmux.conf
set-option -g prefix C-x
unbind-key C-b
bind-key C-x send-prefix
set-window-option -g mode-keys emacs
set-option -g status-keys emacs
bind-key bspace previous-window
bind-key ' ' next-window
bind-key - last-window
state :start do
transition [
"need to log in",
"ready to post a job",
]
end
state "need to log in" do
if !body.index("log in") return false
transition [
module Stateful
class PostconditionFailed < RuntimeError; end
class NoAvailableTransition < RuntimeError; end
class State
def initialize(opts={})
@pre = opts[:pre]
@post = opts[:post]
@proc = opts[:proc]
@transitions = opts[:transitions]
end