Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
# Shotgun approach (read: slow and dirty hack) to help find unused helpers in a Rails application
puts "Loading all source files into memory :("
source = {}
Dir["app/**/**/*.*"].each do |f|
next if f.include?("app/assets")
markoa / ar_mysql_vs_tc_table.rb
Created May 1, 2009 23:13
Benchmarking ActiveRecord + MySQL vs Tokyo Cabinet tables. Sample results at
#!/usr/bin/env ruby
# Script to benchmark ActiveRecord + MySQL vs Tokyo Cabinet tables
require 'rubygems'
require 'benchmark'
require 'faker'
require 'date'
require 'fileutils'
require 'activerecord'
Sat May 02 13:20:05 +0200 2009
N is 1000
ruby is 1.8.7
Preparing data...
== PeopleMigration: reverting ================================================
-- drop_table(:people)
-> 0.0447s
== PeopleMigration: reverted (0.0450s) =======================================
markoa / tumblr-json-parser.rb
Created January 4, 2010 11:44
Sketch for parsing JSON representation of a Tumblr blog.
#!/usr/bin/env ruby
# Parse Tumblr JSON.
require 'rubygems'
require 'json'
require 'net/http'
class String
markoa / git-svn-commands.txt
Created January 7, 2010 17:49
git-svn commands
# Clone a repo (like git clone):
git-svn clone svn+ssh://
# You should be on master branch (check with git branch)
# After compiling, append svn:ignore settings to
# the default git exclude file:
git-svn show-ignore >> .git/info/exclude
# Do some work and commit locally to git:
git commit ...
markoa /
Created January 24, 2010 16:21
Example git post-receive hook for a Jekyll web site repository
# A hook script for the git post-receive event of a Jekyll web site's repository.
# It needs to unset the GIT_DIR environment variable which is otherwise fixed
# to siterepo/.git. Remember to chmod +x post-receive.
echo "Running post-receive hook..."
cd /var/siteroot && env -i git pull && jekyll
markoa /
Created February 8, 2010 23:46
Infinite rainbow in terminal
# Infinite rainbow in terminal
yes "$(seq 1 255)" | while read i; do printf "\x1b[48;5;${i}m\n"; sleep .01; done
markoa / newpost.rb
Created May 19, 2010 11:30
Creates a blank textile file with basic YAML front matter for a Jekyll blog, launches editor.
#!/usr/bin/env ruby
# Creates a blank textile file with basic YAML front matter for
# your Jekyll blog. Then it launches gvim so that you can start
# writing immediately.
# Assumes your posts are in ./blog/_posts and that you're using a layout
# called 'post'.
if ARGV.empty?
Missing rack.input (RuntimeError)
./vendor/plugins/facebooker/lib/facebooker/rails/facebook_url_rewriting.rb:47:in `rewrite_url'
(eval):17:in `reserve_patron_restaurant_path'
./features/support/paths.rb:15:in `path_to'
./features/step_definitions/web_steps.rb:24:in `/^(?:|I )go to (.+)$/'
features/lander.feature:8:in `And I go to lander reserve path'
markoa / ruby-dbus-and-banshee.rb
Created January 7, 2010 17:30
ruby-dbus play with Banshee
#!/usr/bin/env ruby
require 'dbus'
bus = DBus::SessionBus.instance
banshee_service = bus.service("org.bansheeproject.Banshee")
banshee = banshee_service.object("/org/bansheeproject/Banshee/PlayerEngine")
puts banshee.introspect