Skip to content

Instantly share code, notes, and snippets.

@aprilrabkin
aprilrabkin / gist:aacc0a6ca59b66990989
Last active Aug 29, 2015
HTML for Checked and Unchecked Boxes
View gist:aacc0a6ca59b66990989
<input checked="checked" id="post_tag_ids_1" name="post[tag_ids][]" type="checkbox" value="1">
<label for="post_tag_ids_1">adventurous</label>
<input id="post_tag_ids_2" name="post[tag_ids][]" type="checkbox" value="2">
<label for="post_tag_ids_2">aggressive</label>
@aprilrabkin
aprilrabkin / checkboxes
Created Jun 30, 2014
Form helper for collection boxes
View checkboxes
<%= form_for(@post) do |f| %>
<%= f.label :name %><br>
<%= f.text_field :name %><br>
<%= f.label :content %><br>
<%= f.text_area :content %><br>
Tags:
<%= f.collection_check_boxes :tag_ids, Tag.all, :id, :name %><br>
<%= f.submit %>
<% end %>
@aprilrabkin
aprilrabkin / gist:3af125598e08b6ecdc8b
Created May 21, 2014
Caesar Cipher Before Refactoring
View gist:3af125598e08b6ecdc8b
$lower_case = "abcdefghijklmnopqrstuvwxyz"
$upper_case = $lower_case.upcase
def caesar_encode(string, offset)
array = string.split("")
array.map! do |l|
if /[a-z]/ === l
idx = $lower_case.rindex(l)
idx = (idx + offset) % 26
$lower_case[idx]