Skip to content

Instantly share code, notes, and snippets.

mdub / include-after.rb
Created May 16, 2013 00:37
Ruby module include order matters!
View include-after.rb
module M; end
module Soup; end
class C; include M; end
module M; include Soup; end
C.ancestors #=> [C, M, Object, Kernel, BasicObject]
mdub /
Created May 1, 2013 01:25
Redirect STDOUT and STDERR into syslog, using "logger", and bash process substitution
# Redirect STDOUT/STDERR into syslog
exec > >(logger -p 2> >(logger -p user.warn)
mdub / ssh_config
Created April 30, 2013 04:10
SSH connection sharing
View ssh_config
# (hint from
ControlMaster auto
ControlPath /tmp/ssh_mux_%h_%p_%r
ControlPersist 10m
mdub / autotest-xterm-title.rb
Last active December 16, 2015 18:20
Autotest feedback in the terminal title-bar
View autotest-xterm-title.rb
# Pop this in your ~/.autotest
def set_title(title)
if ENV["TERM"] =~ /^xterm/
puts "\e]0;#{title}\007"
Autotest.add_hook(:green) do
set_title "GREEN - all passed"
mdub / pip-install-ansible.log
Last active December 16, 2015 07:48
pip install ansible log
View pip-install-ansible.log
Downloading/unpacking ansible
Running egg_info for package ansible
DATA FILES=[('/usr/share/ansible/', ['./library/add_host', './library/apt', './library/apt_key', './library/apt_repository', './library/assemble', './library/async_status', './library/async_wrapper', './library/authorized_key', './library/bzr', './library/cloudformation', './library/command', './library/copy', './library/cron', './library/debug', './library/django_manage', './library/easy_install', './library/ec2', './library/ec2_facts', './library/ec2_vol', './library/facter', './library/fail', './library/fetch', './library/file', './library/fireball', './library/gem', './library/get_url', './library/git', './library/group', './library/group_by', './library/hg', './library/homebrew', './library/ini_file', './library/lineinfile', './library/lvg', './library/lvol', './library/macports', './library/mail', './library/mongodb_user', './library/mount', './library/mysql_db', './library/mysql_user', './library/nagios', './library/net
View subl-edit.rb
#! /usr/bin/ruby
file = ARGV.first || '.'
args = [file]
args.unshift("-w") unless
exec("subl", *args)
mdub /
Created November 16, 2012 00:03
Postgres psql connection via SSH tunnel
ssh -S $ssh_ctl -fnN -L $port:localhost:5432 $db_host
mdub / valid.rb
Created October 11, 2012 06:28 — forked from adzap/valid.rb
Testing fail?
View valid.rb
# I have a class that delegates functionality to a couple of objects that it
# constructs. I want to test this in isolation. I want to make sure that the
# objects are constructed with the right arguments. I also want to make sure
# that the results from the objects are handled correctly.
# I'm finding it hard to structure the code and test in a way that isn't
# cumbersome. What's below works, but it feels like a lot of stubbing and setup
# for something the should be simpler.
# Anyone got a better approach for this?
mdub / enum_type.rb
Created August 1, 2012 11:12
Easy enumerated types
View enum_type.rb
# Provide support for defining enumerated types.
# Example
# class Colour
# extend EnumType
# define :red do
# # ...
mdub / gist:2946149
Created June 18, 2012 00:20
ST2 custom keybindings
View gist:2946149
{ "keys": ["super+ctrl+r"], "command": "reveal_in_side_bar" },
{ "keys": ["super+shift+\\"], "command": "reindent" },
{ "keys": ["alt+m"], "command": "markdown_preview", "args": {"target": "browser"} }