Skip to content

Instantly share code, notes, and snippets.

I put the shotgun in an Adidas bag and padded it out with four pairs of tennis
socks, not my style at all, but that was what I was aiming for: If they think
you're crude, go technical; if they think you're technical, go crude. I'm
a very technical boy. So I decided to get as crude as possible. These days,
thought, you have to be pretty technical before you can even aspire to
crudeness.
mkb@counterpost ~/code/tainted
% rvm use 1.9.3
Using /Users/mkb/.rvm/gems/ruby-1.9.3-p125
mkb@counterpost ~/code/tainted
% irb
1.9.3p125 :001 > require 'etc.so'
=> true
1.9.3p125 :002 > Etc.systmpdir.tainted?
=> false
1.9.3p125 :003 > exit
class SimpleInstrumentor
class << self
attr_accessor :events
def instrument(name, params = {}, &block)
puts "#{name} just happened."
yield if block_given?
end
end
end
connection = Excon.new('http://icanhascheezburger.com/',
:instrumentor => ActiveSupport::Notifications,
:instrumentor_name => 'myapp.excon')
# Elsewhere...
ActiveSupport::Notifications.subscribe(/myapp.excon/) do |*args|
puts "Excon did stuff!"
end
ActiveSupport::Notifications.subscribe(/cheezburger/) do |*args|
puts "K THX BAI"
end
ActiveSupport::Notifications.instrument("cheezburger", :extra => :information) do
# Do stuff.
end
mkb@chongo ~ % rvm install 1.8.7
Installing Ruby from source to: /Users/mkb/.rvm/rubies/ruby-1.8.7-p352, this may take a while depending on your cpu(s)...
ruby-1.8.7-p352 - #fetching
ruby-1.8.7-p352 - #extracting ruby-1.8.7-p352 to /Users/mkb/.rvm/src/ruby-1.8.7-p352
mv: rename /Users/mkb/.rvm/tmp/rvm_src_59540/\033[34mruby-1.8.7-p352\033[39;49m\033[0m to /Users/mkb/.rvm/src/ruby-1.8.7-p352: No such file or directory
ruby-1.8.7-p352 - #extracted to /Users/mkb/.rvm/src/ruby-1.8.7-p352
/Users/mkb/.rvm/scripts/functions/manage/base: line 163: cd: /Users/mkb/.rvm/src/ruby-1.8.7-p352: No such file or directory
ERROR: Source directory is missing.
Did the download or extraction fail?
@mkb
mkb / gist:1218376
Created September 15, 2011 02:31
#!/usr/bin/env ruby -wKU
LOG = 'eventcmd.log'
event = ARGV.first
@message = 'Gug.'
def ichat_message
%Q{set status message to "#{@message}"}
end
@mkb
mkb / end.scpt
Created August 2, 2011 06:58
Colloquy away/back scripts for Pomodoro.app
tell application "System Events" to if exists process "Colloquy" then
tell application "Colloquy"
set aC to every connection
repeat with c in aC
set aR to (every chat room of c)
repeat with r in aR
set away message of c to ""
end repeat
end repeat
end tell
@mkb
mkb / gist:1119690
Created August 2, 2011 06:27
Using an unreleased gem version with Bundler

TL;DR

Do this:

gem 'nokogiri'
gem 'w3c_validators', "1.1.1", :git => 'git://github.com/alexdunae/w3c_validators.git'

Why?

After experiencing trouble with the w3c_validators gem, I discovered that the problem was a known bug. A fix has been committed, but not yet released in gem form. I could have gone with an older version of the gem, but instead tweaked my Gemfile (ie, Bundler) to use the latest and greatest code.