Skip to content

Instantly share code, notes, and snippets.

Peter Brown beerlington

Block or report user

Report or block beerlington

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View tabular vimrc
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
View wtf.rb
Constant.find_all_by_global(true).each do |c|
@system_constants.class_eval do
define_method, lambda { detect {|sc| ==}.instance_eval { {:value => value, :unit => c.unit} } }
end unless @system_constants.empty?
View formtastic_input.rb
module ClassyEnumHelper
class SemanticFormBuilder < Formtastic::SemanticFormBuilder
def enum_select_input(method, options)
enum_class = object.send(method)
unless enum_class.respond_to? :base_class
raise "#{method} does not refer to a defined ClassyEnum object"
options[:collection] = enum_class.base_class.all_with_name
You can’t perform that action at this time.