Skip to content

Instantly share code, notes, and snippets.

@doncote
doncote / twitter_bootstrap_habtm_checkboxes.rb
Created February 29, 2012 21:56
habtm_checkboxes for twitter bootstrap
def habtm_checkboxes(obj, column, assignment_objects, assignment_object_display_column, label_css_class)
obj_to_s = obj.class.to_s.split("::").last.underscore
field_name = "#{obj_to_s}[#{column}][]"
html = hidden_field_tag(field_name, "")
html += "\n"
assignment_objects.each do |assignment_obj|
cbx_id = "#{obj_to_s}_#{column}_#{assignment_obj.id}"
cbx = check_box_tag field_name, assignment_obj.id, obj.send(column).include?(assignment_obj.id), :id => cbx_id
html += label_tag cbx_id, h(assignment_obj.send(assignment_object_display_column)) + " " + h(cbx), :class => label_css_class + ' checkbox'
@doncote
doncote / gist:1947916
Created March 1, 2012 06:58
avoid the arrows
" Get off my lawn
nnoremap <Left> :echoe "Use h"<CR>
nnoremap <Right> :echoe "Use l"<CR>
nnoremap <Up> :echoe "Use k"<CR>
nnoremap <Down> :echoe "Use j"<CR>
@doncote
doncote / gist:3830440
Created October 3, 2012 22:59
cron job to show growl notifications for commuter rail
16 17 * * 1-5 /usr/local/bin/growlnotify -m "25 minutes until the 5:41 train (express)"
35 17 * * 1-5 /usr/local/bin/growlnotify -m "25 minutes until the 6:01 train"
03 18 * * 1-5 /usr/local/bin/growlnotify -m "25 minutes until the 6:38 train"
59 18 * * 1-5 /usr/local/bin/growlnotify -m "25 minutes until the 7:24 train"
16 20 * * 1-5 /usr/local/bin/growlnotify -m "25 minutes until the 8:41 train"
@doncote
doncote / gist:1c57ef1dbdea32809cbf
Created December 12, 2014 00:57
functional drinking
def drink
don << Bourbon.new
drink if don.standing?
end
@doncote
doncote / create_aws_params.sh
Last active December 21, 2023 03:53
Create multiple AWS SSM parameters from a json file
#!/bin/sh
jq -c '.[]' params.json | while read i; do
aws ssm put-parameter --cli-input-json $i
done