Skip to content

Instantly share code, notes, and snippets.

View raine's full-sized avatar

Raine Virta raine

View GitHub Profile
@raine
raine / spotify_mute_ads.rb
Created March 31, 2010 11:08
Mute Spotify ads on OS X
# coding: utf-8
#!/usr/bin/env ruby
#
# Mutes Spotify ads by monitoring Growl's output in syslog, and changing the
# system-wide audio output to dummy output when an ad is detected.
#
# == Installation
#
# 1. Install Soundflower (http://code.google.com/p/soundflower/)
# 2. Run the following command in your home directory, or wherever you prefer.
osascript <<'APPLESCRIPT'
tell application "iTerm"
activate
tell the first terminal
tell the current session
tell i term application "System Events" to keystroke (key code 126)
tell i term application "System Events" to keystroke (key code 36)
end tell
end tell
end tell
osascript <<'APPLESCRIPT'
tell application "Terminal"
activate
tell front window
tell application "System Events" to keystroke (key code 126)
tell application "System Events" to keystroke (key code 36)
end tell
end tell
tell application "TextMate"
alias gdc='git diff --cached'
alias gst='git status -s' # git >1.7.0
alias glr='git pull --rebase'
alias gl='git pull'
alias gp='git push'
alias gd='git diff'
alias gc='git commit -v'
alias gca='git commit -v -a'
alias gb='git branch'
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
alias gdc='git diff --cached'
alias gst='git status -s' # git >1.7.0
alias glr='git pull --rebase'
alias gl='git pull'
alias gp='git push'
alias gd='git diff'
alias gc='git commit -v'
alias gca='git commit -v -a'
alias gb='git branch'
#!/usr/bin/env ruby
require 'date'
log, file = ARGV
regex = Regexp.new("GET.*#{file}\s.*200\s")
lines = File.open(log).readlines
gets = lines.grep regex
totals = {}
#!/usr/bin/env ruby
#
# NIEC BENCHMARKER:
#
# == Usage
#
# 1. Create a ruby source file containing methods with arbitrary names.
# Those are the methods that will be benchmarked.
# For example, contents of my-benchmarks.rb:
#
@raine
raine / README
Created November 5, 2010 12:15
Get content and amount of rows in the last used or current terminal
FOO
RSpec::Matchers.define :respond_with_json do |expected|
match do |actual|
JSON.parse(actual.response.body) == expected
end
failure_message_for_should do |actual|
"expected the response #{actual.response.body} to be #{expected}"
end
end