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
# encoding: utf-8 | |
# | |
# Smarter than SmartyPants? For plain text. | |
module Chinos | |
extend self | |
def educate(text) | |
educate_quotes educate_ellipses(educate_dashes(text)) | |
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
" MacVim meets WriteRoom. | |
if has("autocmd") | |
augroup txt | |
au! | |
autocmd GUIEnter *.txt set nolist | |
autocmd GUIEnter *.txt set columns=80 | |
autocmd GUIEnter *.txt set noruler | |
autocmd GUIEnter *.txt set nonumber | |
autocmd GUIEnter *.txt set linebreak |
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 |
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
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
# 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
# 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
# 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
# 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
#!/usr/bin/env ruby | |
require "optparse" | |
require "erb" | |
module Script | |
class Nginx | |
TEMP_PATH = "tmp/nginx.conf" | |
def initialize | |
@host = "0.0.0.0" |