Skip to content

Instantly share code, notes, and snippets.

View iHiD's full-sized avatar
💙

Jeremy Walker iHiD

💙
View GitHub Profile
@iHiD
iHiD / show.html.haml
Created June 25, 2012 19:13
Security Article Part 3 - 9
=cache "#{current_user.is_admin?}_user_#{@user.id}_#{@user.updated_at}_#{@user.media_files_updated_at}_#{@user.wall_updated_at}" do
%h2= @user.name
=cache "#{current_user.is_admin?}_user_#{@user.id}_information_#{@user.updated_at}" do
=render "users/information"
=cache "user_#{@user.id}_media_files_#{@user.media_files_updated_at}" do
=render "users/media_files"
=cache "user_#{@user.id}_wall_#{@user.wall_updated_at}" do
@iHiD
iHiD / show.html.erb
Created June 25, 2012 19:15
Security Article Part 3 - 10
<h2><%= @blog_post.title %></h2>
<div id="content"><%= sanitize(@blog_post.content, tags: tags %w(b strong i em)) %></div>
@iHiD
iHiD / data_helper.rb
Created June 25, 2012 19:16
Security Article Part 3 - 11
module DataHelper
# Expects a nested array such as:
# [[1,'Jez','iHiD'], [2,'Bob','<b>xyz</b>']]
#
# and outputs:
# <table>
# <tr><td>1</td><td>Jez</td><td>iHiD</td></tr>
# <tr><td>2</td><td>Bob</td><td>&lt;b&gt;xyz&lt;/b&gt;</td></tr>
# </table>
def data_to_table(data)
@iHiD
iHiD / data_helper.rb
Created June 25, 2012 19:17
Security Article Part 3 - 12
module DataHelper
...
output << "<td>#{h cell}</td>"
...
end
@iHiD
iHiD / data_helper.rb
Created June 25, 2012 19:35
Security Article Part 3 - 14
module DataHelper
def data_to_table(data)
content_tag :table do
data.map do |row|
content_tag :tr do
row.map {|cell| content_tag :td, cell}.reduce(:<<)
end
end.reduce(:<<)
end
end
@iHiD
iHiD / data_helper.rb
Created June 25, 2012 19:47
Security Article Part 3 - 13
module DataHelper
def data_to_table(data)
content_tag :table do
rows = data.map do |row|
content_tag :tr do
cells = row.map do |cell|
content_tag :td, cell
end
safe_join(cells)
end
@iHiD
iHiD / config.rb
Created June 26, 2012 01:17
Security Article Part 3 - 15
config.filter_parameters += [:password, :email]
@iHiD
iHiD / speaker.md
Created June 30, 2012 14:47 — forked from matiaskorhonen/speaker.md
Frozen Rails Talk Proposal Template (http://2012.frozenrails.eu/)
@iHiD
iHiD / converter.rb
Created July 3, 2012 12:15
PDF to SVG components
# Set up a couple of paths
lib_directory = "#{Rails.root}/lib/svgs/"
assets_directory = "#{Rails.root}/app/assets/images/pages/"
pdf_path = "/Users/iHiD/Downloads/SightSound.pdf"
(1..18).each do |id|
# Setup image specific paths
orignal_filename = "#{lib_directory}#{id}.svg"
text_filename = "#{assets_directory}#{id}_text.svg"
@iHiD
iHiD / post-commit
Created July 30, 2012 15:21 — forked from consti/post-commit
Take a photo of you, whenever you make a commit
#!/bin/sh
#
# Take a photo of you, whenever you make a commit
#
# This is an improved version of Víctor Martínez original post:
# http://coderwall.com/p/xlatfq
#
# Improvements: