Skip to content

Instantly share code, notes, and snippets.

Avatar

Marko Anastasov markoa

View GitHub Profile
View find_unused_helpers.rb
#!/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
markoa / ar_mysql_vs_tc_table.rb
Created May 1, 2009
Benchmarking ActiveRecord + MySQL vs Tokyo Cabinet tables. Sample results at http://gist.github.com/105516
View ar_mysql_vs_tc_table.rb
#!/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'
View ar_mysql_vs_tc_table.log
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
markoa / tumblr-json-parser.rb
Created Jan 4, 2010
Sketch for parsing JSON representation of a Tumblr blog.
View tumblr-json-parser.rb
#!/usr/bin/env ruby
# Parse Tumblr JSON.
require 'rubygems'
require 'json'
require 'net/http'
class String
View git-svn-commands.txt
# Clone a repo (like git clone):
git-svn clone svn+ssh://markoa@svn.gnome.org/svn/paperbox
# 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
markoa / post-receive-for-jekyll.sh
Created Jan 24, 2010
Example git post-receive hook for a Jekyll web site repository
View post-receive-for-jekyll.sh
#!/bin/sh
#
# 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
markoa / rainbows.sh
Created Feb 8, 2010
Infinite rainbow in terminal
View rainbows.sh
#!/bin/bash
# Infinite rainbow in terminal
yes "$(seq 1 255)" | while read i; do printf "\x1b[48;5;${i}m\n"; sleep .01; done
@markoa
markoa / newpost.rb
Created May 19, 2010
Creates a blank textile file with basic YAML front matter for a Jekyll blog, launches editor.
View newpost.rb
#!/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?
View gist:423640
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
markoa / ruby-dbus-and-banshee.rb
Created Jan 7, 2010
ruby-dbus play with Banshee
View ruby-dbus-and-banshee.rb
#!/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