<%= select_for_tag :name,
options_for_select(complex.stuff.collect{|d| d.stuff} + ['other', 'stuff']) %>
<%= select_for_tag :name,
options_for_select(complex.stuff.collect{|d| d.stuff} + admin_selection_choices(user) + ['other', 'stuff']) %>
#!/usr/bin/ruby | |
# | |
# Most of this taken from here: https://gist.github.com/jmazzi/436947 | |
require 'csv' | |
require 'pathname' | |
# CHANGE THIS | |
input_file = Pathname("PATH/TO/CSV").expand_path | |
output_file = Pathname("~/pwds.xml").expand_path |
" block select commenting & uncommenting | |
au BufEnter *.rb map ,c :s/^/#/<CR>:nohlsearch<CR> | |
au BufEnter *.rb map ,u :s/^#//<CR>:nohlsearch<CR> | |
au BufEnter *.vim* map ,c :s/^/"/<CR>:nohlsearch<CR> | |
au BufEnter *.vim* map ,u :s/^"//<CR>:nohlsearch<CR> | |
au BufEnter *.haml* map ,c :s/^/-#/<CR>:nohlsearch<CR> | |
au BufEnter *.haml* map ,u :s/^-#//<CR>:nohlsearch<CR> |
let indent_colors = ['#645640','#564832','#484024','#646452','#565644','#484834','#565656','#484848','#404040'] | |
let indent = 8 | |
for icolor in indent_colors | |
let indent_name = 'Indent' . indent | |
exec 'highlight ' . indent_name . ' guibg=' . icolor | |
au bufwinenter * call matchadd(indent_name, '^\s\{' . (indent * 2 + 4) . '}\&^\s\{' . (indent * 2 + 1) . '}', 200-indent) | |
let indent -= 1 | |
endfor |
highlight LongLines guibg=#333300 | |
au BufWinEnter * call matchadd('LongLines', '^.\{80,119}$', -1) | |
highlight VeryLongLines guibg=#330000 | |
au BufWinEnter * call matchadd('VeryLongLines', '^.\{120,}$', -1) |
set relativenumber | |
au InsertEnter * :set number | |
au InsertLeave * :set relativenumber | |
function! FocusGainNumbering() | |
if(mode() == 'i') | |
:set number | |
else | |
:set relativenumber |
def address_method(city: "Bloomington", state: "IN", street: "123 fake st") | |
print x,y,z,"\n" | |
end | |
input = {city: "Indianapolis", street: "321 faux st", zip: "12345"} | |
address_method(input_address) # => ArgumentError: unknown keyword: zip | |
addr_mthd = method(:address_method) | |
acceptable_keywords = addr_mthd.parameters.select{|p| p[0] == :key}.map(&:last) |
# boring var technique | |
x = nil | |
[1,2,3,4].each do |y| | |
if x | |
puts x + y | |
end | |
x = y | |
end |
class Dryer = Struct.new(:file_path, :super_class, :blk) do | |
def self.def_class(file_path, super_class=Object, &blk) | |
new(file_path, super_class, blk).def_class | |
end | |
def def_class | |
constant_names.each.with_index.inject(Object) do |const, (next_const, index)| | |
if constant_names.length == index + 1 |
arg = `echo $COUNT_CALLS_TO` | |
KLASS, METHOD = *arg.split('#').map(&:strip) | |
module MethodCounter | |
module ClassMethods | |
@@method_times_run_var = 0 | |
def method_times_called | |
@@method_times_run_var | |
end |