Skip to content

Instantly share code, notes, and snippets.


TJ Stankus tjstankus

View GitHub Profile
tjstankus / scala.rb
Created May 2, 2012
Scala homebrew formula
View scala.rb
require 'formula'
class ScalaDocs < Formula
homepage ''
url ''
md5 '48d9102789bf696d3d8621fb24ed47da'
class ScalaCompletion < Formula
homepage ''
View my_helper_test.rb
require 'test_helper'
class MyHelperTest < ActionView::TestCase
test "title" do
assert_select_in '<h1>My Awesome App</h1>', 'h1'
test "nav" do
html = '<div id="nav"><a href="/">Home</a></div>'
assert_select_in html, 'div' do
View pdf_png_transparency.rb
require 'rubygems'
require 'prawn'
require 'prawn/measurement_extensions'
require 'prawn/fast_png'
require 'RMagick'
image =,300) do
self.background_color = 'black'
self.depth = 8 # without this it breaks in Windows
self.format = 'PNG'
View selenium_driver.rb
def set(value)
if # ...
# code elided for clarity
elsif tag_name == 'input' and type == 'checkbox'
# node.toggle # => JS event not fired # => JS event fired
# Hacking VoodooPad to create OpenMeta tags from VoodooPad page tags
# How to make this work:
# 1. Download the openmeta command line tool from here:
# Unzip the executable and install it to /usr/local/bin.
# If you choose a different directory, change the cmd string below.
# 2. Save the below Python code into
# ~/Library/Application Support/VoodooPad/Script Plugins/
# 3. Quit and restart VoodooPad.
View acts_as_taggable_on_example.rb
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
# Examples:
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Major.create(:name => 'Daley', :city => cities.first)
require 'faker'
View gist:227103
require 'active_support/ordered_hash'
require 'active_support/core_ext/enumerable'
module Enumerable
def group_by_attribute(attr, options={:nils_first => true})
raise "attr parameter must by a symbol" unless attr.is_a?(Symbol)
h = group_by(&attr)
returning h2 = do
h2[nil] = h.delete(nil) if options[:nils_first] && h.has_key?(nil)
View generate_tags.rb
namespace :tags do
task :generate do
puts 'Generating tags...'
require 'rubygems'
require 'jekyll'
include Jekyll::Filters
options = Jekyll.configuration({})
site =
View gist:182660
# mongo_template.rb
# remove unneeded defaults
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm public/javascripts/controls.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/prototype.js"
View gist:131482
# Slight modifications to code posted by Gregory Brown at
require 'delegate'
module Decoration
def decorator_for(*types, &block)
types.each do |type|
decorators[type] =