Skip to content

Instantly share code, notes, and snippets.

View DanThiffault's full-sized avatar

Dan Thiffault DanThiffault

View GitHub Profile
# Filename: RAILS_ROOT/config/initializers/paperclip_thumbnail_with_dimensions.rb
# Required Configuration in the model
#
# include Paperclip::Dimensions
#
# has_attached_file :image,
# :styles => {
# :thumbnail => {
# :geometry => "100x100>",
# :format => :png
@DanThiffault
DanThiffault / paperclip_model.rb
Created February 15, 2011 13:44
Paperclip section within model
include Paperclip::Dimensions
has_attached_file :image,
:styles => {
:tiny =>{:geometry => "95x110>"},
:small =>{:geometry => "114x132>"},
:normal =>{:geometry => "133x154>"},
:large =>{:geometry => "190x220>"}
},
:path => Settings.user_images.base_path + ":id/:style.:extension",
@DanThiffault
DanThiffault / cucumber.rb
Created February 16, 2011 05:24
Ruby based cucumber file
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'cucumber' is installed as part of a gem, and
# this file is here to facilitate running it.
#
if File.exists? "bin/cucumber"
exec "bin/cucumber " + $*.join(" ")
@DanThiffault
DanThiffault / respond_to_bookmarklet.rb
Created February 28, 2011 06:21
Bookmarklet format setup
module BookmarkletFormat
Mime::Type.register_alias "text/javascript", :bookmarklet
def infer_bookmarklet_format
if request.format == :js && request.referer.to_s.match('^' + bookmarklet_url.to_s)
request.format = :bookmarklet unless disable_bookmarklet?
end
end
def disable_bookmarklet?
module BookmarkletFormat
Mime::Type.register_alias "text/javascript", :bookmarklet
end
class ApplicationController < ActionController::Base
before_filter :infer_bookmarklet_format
include BookmarkletFormat
end
@DanThiffault
DanThiffault / application_helper.rb
Created May 6, 2011 07:05
Rails 3 page title helper
def page_title(title=view_context.t('.title'))
content_tag(:h1, title)
end
@DanThiffault
DanThiffault / new.html.erb
Created May 6, 2011 07:10
Example template for page title helper
<header>
<%=page_title %>
<hr/>
</header>
<%= render "form" %>
@DanThiffault
DanThiffault / en.yml
Created May 6, 2011 07:13
Example yaml file
en:
user_sessions:
new:
title: "Sign in to My Site"
@DanThiffault
DanThiffault / build_source.sh
Created July 21, 2011 06:32
Fingerworks Multitouch Utility Runner
# authenticate with the repository
# use a blank password
cvs -d:pserver:[email protected]:/cvsroot/jusb login
# pull down the source
cvs -z3 -d:pserver:[email protected]:/cvsroot/jusb co -P jusb
# change directories
cd jusb