Skip to content

Instantly share code, notes, and snippets.

View tjstankus's full-sized avatar

TJ Stankus tjstankus

  • Chapel Hill, NC
View GitHub Profile
@tjstankus
tjstankus / scala.rb
Created May 2, 2012 14:31
Scala homebrew formula
require 'formula'
class ScalaDocs < Formula
homepage 'http://www.scala-lang.org/'
url 'http://www.scala-lang.org/downloads/distrib/files/scala-docs-2.9.2.zip'
md5 '48d9102789bf696d3d8621fb24ed47da'
end
class ScalaCompletion < Formula
homepage 'http://www.scala-lang.org/'
require 'test_helper'
class MyHelperTest < ActionView::TestCase
test "title" do
assert_select_in '<h1>My Awesome App</h1>', 'h1'
end
test "nav" do
html = '<div id="nav"><a href="/">Home</a></div>'
assert_select_in html, 'div' do
require 'rubygems'
require 'prawn'
require 'prawn/measurement_extensions'
require 'prawn/fast_png'
require 'RMagick'
image = Magick::Image.new(300,300) do
self.background_color = 'black'
self.depth = 8 # without this it breaks in Windows
self.format = 'PNG'
def set(value)
if # ...
# code elided for clarity
elsif tag_name == 'input' and type == 'checkbox'
# node.toggle # => JS event not fired
node.click # => JS event fired
end
end
# Hacking VoodooPad to create OpenMeta tags from VoodooPad page tags
#
# How to make this work:
# 1. Download the openmeta command line tool from here:
# http://code.google.com/p/openmeta/downloads/list
# 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/openmeta_tags.py
# 3. Quit and restart VoodooPad.
# 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'
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 = ActiveSupport::OrderedHash.new do
h2[nil] = h.delete(nil) if options[:nils_first] && h.has_key?(nil)
h2.merge!(h)
namespace :tags do
task :generate do
puts 'Generating tags...'
require 'rubygems'
require 'jekyll'
include Jekyll::Filters
options = Jekyll.configuration({})
site = Jekyll::Site.new(options)
site.read_posts('')
# 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"
# Slight modifications to code posted by Gregory Brown at http://pastie.org/515450
require 'delegate'
module Decoration
def decorator_for(*types, &block)
types.each do |type|
decorators[type] = Module.new(&block)
end
end