Skip to content

Instantly share code, notes, and snippets.

Aaron Quint quirkey

Block or report user

Report or block quirkey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:1247
module ApplicationHelper
def e_tag(model)
eval("link_to image_tag(\'pencil.png\'), edit_#{model.class.name.underscore}_path(model)")
end
def d_tag(model)
eval("link_to image_tag(\'delete.png\'), model, :confirm => \'Are you sure?\', :method => :delete")
end
View deep_hash.rb
module DeepHash
def deep_value(key_array)
value = self
Array(key_array).each do |key|
value = value.fetch(key, nil)
end
value
rescue NoMethodError
nil
View action_mailer_extensions.rb
module ActionMailer
class Base
class_inheritable_accessor :view_paths
def self.prepend_view_path(path)
view_paths.unshift(*path)
ActionView::TemplateFinder.process_view_paths(path)
end
def self.append_view_path(path)
View gist:11134
# example <a onclick="popup('http://gooogle.com','Google',400,300);">Popup</a>
function popup(link,title,width,height) {
return window.open(link,title,"height="+height+",width="+width+",status=no,toolbar=no,menubar=no,location=no");
}
View gist:16056
[10:29 AM:n41(master)] $ ./script/console
Loading development environment (Rails 2.1.1)
>> m1, m2 = Money.new(200), Money.new(200)
=> [#<Money:0x32165f8 @currency="USD", @cents=200>, #<Money:0x32165e4 @currency="USD", @cents=200>]
>> m2.eql?(m1)
=> true
>> m1.eql?(m2)
=> true
>> m1 == m2
=> true
View gist:16142
TherapistReport.send(:with_exclusive_scope) {
@last_tr = TherapistReport.find(:all, :conditions => ["report_id = ? AND therapist_id = ? AND report.territory_id = ? ", self.report.previous, self.therapist_id, self.report.territory_id], :include => [:report])
}
View gist:27221
class TrueClass
def to_s
"so fucking true"
end
end
View gist:31143
def truncate_words(text, length = 30, truncate_string = "..." )
return if text.nil?
words = text.split
words.length > length ? words[0...length].join(" ") + truncate_string : text
end
View gist:32377
desc "Download a tarball from Github and extract to a shared dir then symlink to vendor/rails"
task :deploy_edge do
puts "Pulling Rails from github"
shared = ENV['SHARED_PATH'] || File.join('..','..','shared')
shared_path = File.expand_path(shared)
puts "Shared Path: #{shared_path}"
rails_path = File.join(shared_path, 'rails')
rails_version = ENV['VERSION'] || ENV['REVISION'] || 'v2.1.0'
export_path = File.join(rails_path, "rails_#{rails_version}")
View gist:35158
export PS1='\[\e[36;1m\][\@:\[\e[32;1m\]\W\[\e[33;1m\]$(__git_ps1 "(%s)")\[\e[32;1m\]] \[\e[0m\]$ '
# Color Code
# Black 0;30
# Blue 0;34
# Green 0;32
# Cyan 0;36
# Red 0;31
# Purple 0;35
# Brown 0;33
You can’t perform that action at this time.