This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# A better open: with stdin. | |
if tty -s | |
then | |
/usr/bin/open $@ | |
else | |
while read input | |
do | |
/usr/bin/open $input | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bare bones Gemfile for Rails 3.0.pre. | |
# | |
# Throw in a directory for a new application, `gem bundle && bin/rails . -s`. | |
gem "rails", "3.0.pre", :git => "git://github.com/rails/rails.git" | |
gem "arel", :git => "git://github.com/rails/arel.git" | |
gem "rack-mount", :git => "git://github.com/rails/rack-mount.git" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "optparse" | |
require "erb" | |
module Script | |
class Nginx | |
TEMP_PATH = "tmp/nginx.conf" | |
def initialize | |
@host = "0.0.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/label_with_block.rb | |
class ActionView::Helpers::FormBuilder #:nodoc: | |
def label_with_block(method, *args, &block) | |
if block_given? | |
options = args.extract_options! | |
text = @template.capture(&block) | |
@template.concat label_without_block(method, text, options) | |
else | |
label_without_block(method, *args) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# factory_girl for minitest | |
# | |
# Factory.define :user do |f| | |
# f.login 'johndoe%d' # Sequence. | |
# f.email '%{login}@example.com' # Interpolate. | |
# f.password f.password_confirmation('foobar') # Chain. | |
# end | |
# | |
# Factory.define :post do |f| | |
# f.user { Factory :user } # Blocks, if you must. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# More "proper" than a miniskirt (http://gist.github.com/273579). | |
class Minidress | |
@@factories = {} | |
class << self | |
def define(name, &block) | |
@@factories[name.to_s] = block | |
end | |
def build(name, attrs = {}) | |
new(name.to_s.classify.constantize.new, &@@factories[name.to_s]).record |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adds a fallback <tt>:is</tt> option to +validates+. | |
# | |
# # validates :preferences, class: Hash | |
# class ClassValidator < ActiveModel::EachValidator | |
# def validate_each(record, attribute, value) | |
# record[attribute].is_a?(options[:is]) || | |
# record.errors.add attribute, options[:message] || | |
# record.errors.generate_message(attribute, :class) | |
# end | |
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActionView::Helpers::AssetTagHelper.register_javascript_expansion({ | |
html5shiv: "http://html5shiv.googlecode.com/svn/trunk/html5.js", | |
ie7js: "http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE7.js", | |
ie8js: "http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE8.js", | |
jquery: "http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js" | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define application-level configuration using a simple DSL. | |
# | |
# class App < Configuration | |
# config.key = "value" | |
# config.lazy = lambda { |load| load } | |
# end | |
# | |
# App.key # => "value" | |
# App.key? # => true | |
# App.lazy("load") # => "load" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .( screenrc ). for _why :: * supports xterm/rxvt titles | |
# * default encoding is utf-8 (i use urxvt with this) | |
setenv LC_CTYPE en_US.UTF-8 | |
defutf8 on | |
autodetach on | |
crlf off | |
#deflogin off | |
hardcopy_append on |