Skip to content

Instantly share code, notes, and snippets.

View pat's full-sized avatar
🇵🇸
free Palestine 🇵🇸

Pat Allan pat

🇵🇸
free Palestine 🇵🇸
View GitHub Profile
@pat
pat / gist:465237
Created July 6, 2010 10:39 — forked from dnch/gist:465056
ActionView::Helpers::AssetTagHelper.register_javascript_expansion(
:jquery => if Rails.env.production?
["http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"]
else
['jquery-1.4.2']
end
)
@pat
pat / Rakefile
Created November 18, 2009 13:08 — forked from tobstarr/Rakefile
# Since rubygems should have been required already, we can determine from the
# Gem object what is and isn't available.
if Gem.available?('thinking-sphinx')
require 'thinking_sphinx/0.9.8'
require 'thinking_sphinx/tasks'
require 'thinking_sphinx/deltas/datetime_delta/tasks'
else
puts 'gem thinking-sphinx required for all rake tasks'
end
# Examples:
# Post.by_day
# Post.by_day(Time.yesterday)
# Post.by_day("next tuesday")
def by_day(time = Time.zone.now, options = {}, &block)
time = parse(time)
by_star(time.utc.beginning_of_day, time.utc.end_of_day, options, &block)
end
alias_method :today, :by_day
1) Add the function below into your .bash_profile, .bash_login, or other shell profile file.
2) Then you can hit nt (for new tab) anywhere
and a new tab will open up in same directory.
All credit for the idea and applescript goes to @jnunemaker - I just tidied it up.
If you can improve it further, let him know -- nunemaker@gmail.com.
@pat
pat / super.rb
Created April 25, 2009 05:54 — forked from benschwarz/super.rb
class A
def initialize
dispatch if respond_to?(:dispatch)
end
end
class B < A
def dispatch
puts "called dispatch"
end
- filtered_filenames(@items).each do |name|
%p do some stuff
# Goal is => Client.first.items... Can do with finder_sql, but want an activerecord way!
class Client < ActiveRecord::Base
has_many :contacts
has_many :tasks, :through => :contacts
# has_many :items, :through => :tasks # THIS DOESNT WORK
def items
@items ||= self.tasks.collect { |task| task.items }.flatten
end
@pat
pat / gist:43460
Created January 5, 2009 16:57 — forked from headius/gist:43347
RubyConf
RailsConf
RailsConf EU
acts_as_conference
Euruko
Ruby Kaigi
Mountain West RubyConf
eRubyCon
Ruby Hoedown
Amsterdam Ruby en Rails