Skip to content

Instantly share code, notes, and snippets.

@matthewtodd
matthewtodd / tmux
Created January 27, 2011 11:30
script/tmux
#!/bin/sh
tmux start-server
if ! $(tmux has-session -t grow); then
tmux new-session -d -s grow -n foreground
tmux send-keys 'cd .' C-m C-l
tmux send-keys 'AUTOFEATURE=true autotest --quiet' C-m
tmux split-window -h
tmux send-keys 'cd .' C-m C-l
@matthewtodd
matthewtodd / gist:728014
Created December 4, 2010 07:34
Resize an OSX display with RubyCocoa.
require 'osx/cocoa'
class Screen
class << self
def resize(width, height, &block)
new.resize(width, height, &block)
end
end
def initialize(screen = OSX::CGMainDisplayID())
@matthewtodd
matthewtodd / database.rb
Created August 6, 2010 12:05
heroku rake db:pull --remote staging
require 'heroku'
require 'taps/operation'
class Database
def self.pull(*args)
new.pull(*args)
end
def initialize(uri=ENV['DATABASE_URL'])
@uri = uri
@matthewtodd
matthewtodd / asset_tag_helper.rb
Created July 12, 2010 04:57
Rails + Sass + Asset Fingerprints + Heroku
# Ensure AssetTagHelper has been loaded before we try to monkey-patch it.
require 'action_view/helpers/asset_tag_helper'
module ActionView::Helpers::AssetTagHelper
# Insert the asset id in the filename, rather than in the query string. In
# addition to looking nicer, this also keeps any other static file handlers
# from preempting our Rack::StaticCache middleware, since these
# version-numbered files don't actually exist on disk.
def rewrite_asset_path(source)
source.insert source.rindex('.'), "-#{rails_asset_id(source)}"
@matthewtodd
matthewtodd / GoogleVoiceDialerAction.scpt
Created December 9, 2009 09:05
Command-line Google Voice dialer and Mac OSX Address Book Plug-In
-- Drop this script in ~/Library/Address Book Plug-Ins
-- Edit the path in the "do shell script" line
using terms from application "Address Book"
on action property
return "phone"
end action property
on action title for aPerson with aNumber
return "Dial with Google Voice"
end action title
@matthewtodd
matthewtodd / gist:231767
Created November 11, 2009 07:55
Handy Heroku credentials switcher.
#!/usr/bin/env ruby -wKU
# I use 2 different Heroku accounts, one for my own apps and one for Amani's.
# This script givens me a reasonable way to switch between them, with a little
# less typing than moving a symlink around. And I get to use abbrev!
require 'abbrev'
require 'pathname'
require 'yaml'
credentials = Pathname.new(ENV['HOME']).join('.heroku', 'credentials')
@matthewtodd
matthewtodd / gist:144392
Created July 10, 2009 10:19
Rake task to build rdoc exactly as `gem install` would
# I've folded this idea into http://github.com/matthewtodd/shoe
# See what you think!
require 'rubygems'
require 'rubygems/doc_manager'
spec = Gem::Specification.new do |spec|
# ...
end
@matthewtodd
matthewtodd / gist:135069
Created June 24, 2009 07:21
iChat-spam Bonjour accounts by name
require 'appscript'
class DeployNotifier
include Appscript
def initialize(*names)
@ichat = app('iChat')
@accounts = names.map { |name| bonjour_account(name) }
end
@matthewtodd
matthewtodd / Schedule Waiting For Action in Things.scpt
Created June 15, 2009 09:51
Mail Act-On applescript to schedule a Waiting For reminder in Things.
using terms from application "Mail"
on extractName from theRecipient
if the name of theRecipient exists then
return the name of theRecipient
else
return the address of theRecipient
end if
end extractName
QEMU_IMG = '/Applications/Q.app/Contents/MacOS/qemu-img'
QEMU = '/Applications/Q.app/Contents/MacOS/i386-softmmu.app/Contents/MacOS/i386-softmmu'
directory 'tmp'
file '/tmp/ubuntu-cdrom' do
sh 'hdiutil attach vendor/ubuntu-8.10-server-i386.iso -mountpoint /tmp/ubuntu-cdrom'
end
file 'tmp/netboot' => ['config/preseed.cfg', 'config/pxelinux.cfg', 'tmp', '/tmp/ubuntu-cdrom'] do