Skip to content

Instantly share code, notes, and snippets.

@matthewtodd
matthewtodd / .rsnapshot.conf
Created December 19, 2008 08:24
Local rsnapshot config to backup ${HOME} to external hard drive
config_version 1.2
snapshot_root /Volumes/Suspenders/
no_create_root 1
cmd_rm /bin/rm
cmd_rsync /opt/local/bin/rsync
cmd_logger /usr/bin/logger
interval nightly 3
#!/usr/bin/env ruby
#
# I have a couple of GeekTool windows at the bottom of the screen,
# where it's nice to bottom-justify their contents, but GeekTool
# doesn't seem to support this natively.
#
# Usage:
# cat TODO.rdoc | bottom-justify.rb 24
#
# It seems like there could be a nice shell command for this,
require 'rubygems'
require 'action_controller'
require 'test/unit'
class AccountsController < ActionController::Base
end
# Your mission, should you choose to accept it: Change the RouteSet (in the
# with_route_set method) so as to make both tests pass.
class RoutingTest < ActionController::TestCase
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
@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
@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 / 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 / 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 / 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 / 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