Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mdub
mdub / include-after.rb
Created May 16, 2013 00:37
Ruby module include order matters!
module M; end
module Soup; end
class C; include M; end
module M; include Soup; end
C.ancestors #=> [C, M, Object, Kernel, BasicObject]
@mdub
mdub / syslog-injection.sh
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 user.info) 2> >(logger -p user.warn)
@mdub
mdub / ssh_config
Created April 30, 2013 04:10
SSH connection sharing
# (hint from http://blogs.perl.org/users/smylers/2011/08/ssh-productivity-tips.html)
ControlMaster auto
ControlPath /tmp/ssh_mux_%h_%p_%r
ControlPersist 10m
@mdub
mdub / autotest-xterm-title.rb
Last active December 16, 2015 18:20
Autotest feedback in the terminal title-bar
# Pop this in your ~/.autotest
def set_title(title)
if ENV["TERM"] =~ /^xterm/
puts "\e]0;#{title}\007"
end
end
Autotest.add_hook(:green) do
set_title "GREEN - all passed"
@mdub
mdub / pip-install-ansible.log
Last active December 16, 2015 07:48
pip install ansible log
Downloading/unpacking ansible
Running setup.py 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
#! /usr/bin/ruby
file = ARGV.first || '.'
args = [file]
args.unshift("-w") unless File.directory?(file)
exec("subl", *args)
@mdub
mdub / ssh-psql.sh
Created November 16, 2012 00:03
Postgres psql connection via SSH tunnel
#!/bin/sh
db_host=db-server
db_user=supersecret
db_name=myapp_production
port=65432
ssh_ctl=/tmp/$$-ssh-ctl-sock
ssh -S $ssh_ctl -fnN -L $port:localhost:5432 $db_host
@mdub
mdub / valid.rb
Created October 11, 2012 06:28 — forked from adzap/valid.rb
Testing fail?
# 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
mdub / enum_type.rb
Created August 1, 2012 11:12
Easy enumerated types
# Provide support for defining enumerated types.
#
# Example
#
# class Colour
#
# extend EnumType
#
# define :red do
# # ...
@mdub
mdub / gist:2946149
Created June 18, 2012 00:20
ST2 custom keybindings
[
{ "keys": ["super+ctrl+r"], "command": "reveal_in_side_bar" },
{ "keys": ["super+shift+\\"], "command": "reindent" },
{ "keys": ["alt+m"], "command": "markdown_preview", "args": {"target": "browser"} }
]