Skip to content

Instantly share code, notes, and snippets.

💭
skiing

ara.t.howard ahoward

💭
skiing
Block or report user

Report or block ahoward

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:31017
def self.find( *a, &b )
opts =
if Hash === a.last then a.last
else
a << {}
a.last
end
unless opts.has_key?(:order)
opts[:order] = 'name ASC'
View gist:34225
# railsext.rb - my collection of rails hacks
#
# force const_missing to preload these classes - muckery
#
ActionController
ActionController::Base
ActiveRecord
ActiveRecord::Base
View gist:34241
# railsext.rb - my collection of rails hacks
#
# force const_missing to preload these classes - muckery
#
ActionController
ActionController::Base
ActiveRecord
ActiveRecord::Base
View gist:34245
def copy(content)
case RUBY_PLATFORM
when /darwin/
return content if `which pbcopy`.strip == ''
IO.popen('pbcopy', 'r+') { |clip| clip.puts content }
when /linux/
return content if `which xclip`.strip == ''
IO.popen('xclip', 'r+') { |clip| clip.puts content }
end
View gist:34246
def copy(content)
case RUBY_PLATFORM
when /darwin/
return content if `which pbcopy`.strip == ''
IO.popen('pbcopy', 'r+') { |clip| clip.print content.strip }
when /linux/
return content if `which xclip`.strip == ''
IO.popen('xclip', 'r+') { |clip| clip.print content.strip}
end
View gist:34251
has_many(:buckets, :dependent => :destroy) do
def self.extend_object buckets
super
ensure
buckets.class # hack to know about .each
buckets.each do |bucket|
bucket.collection = buckets.collection
end
end
View gist:34252
class Bucket < ActiveRecord::Base
include Sluggable
Fu = FileUtils
belongs_to :collection
collection_reader = instance_method 'collection'
define_method('collection') do |*a|
@collection ? @collection : collection_reader.bind(self).call(*a)
end
View gist:34272
has_many :buckets, :dependent => :destroy
buckets = instance_method(:buckets)
define_method(:buckets) do |*a|
@buckets ||= buckets.bind(self).call(*a)
@buckets.each{|bucket| bucket.collection = self}
@buckets
end
View gist:34820
def lettuce_report_review
allows :student, :studentdemo
setup_for_student
@number = params[:id] || 1
@disabled = params[:disabled]||params[:readonly]||request.query_string.to_s[%r/disabled|readonly/]
@review = @unit.find_lettuce_report_review(:student => @student, :number => @number)
unless @review
View gist:34823
def lettuce_report
allows :student, :studentdemo
setup_for_student
@report = @unit.find_lettuce_seed_bioassay_report(:student => @student)
@questionnaire = @report.questionnaire
@questions_and_answers = @student.questions_and_answers_for(@questionnaire, :context => @classroom, :blank => true)
if request.post?
transaction do
You can’t perform that action at this time.