Skip to content

Instantly share code, notes, and snippets.

class Klass
def self.build_map
@@map = "hi"
end
self.build_map
def self.use_it
puts @@map
end
end
bright_cove_content_parts = ContentPart.find(:all, :conditions=>["content like '%%c.brightcove.com%%'"])
bright_cove_content_parts.collect {|cp| cp.template_part.name}.uniq
bright_cove_content_parts = ContentPart.find(:all, :conditions=>["content like '%%c.brightcove.com%%'"])
def parse_it(x)
x
end
map = {}
bright_cove_content_parts.each do |bc_cp|
map[bc_cp.version.content_id] ||= {}
map[bc_cp.version.content_id][bc_cp.template_part_id] = parse_it(bc_cp.content)
end
video_pagination_layouts = PaginationLayout.find(:all,
:conditions => ["content like '%%Video Review%%'"],
:include => [:content_template])
all_cts = []
all_cts += ContentTemplate.find_all_by_landing_page_layout_id(video_pagination_layouts)
all_cts += video_pagination_layouts.collect {|vpl| vpl.content_template}.compact # just in case
authkey.rb
authenticate!(key)
if success
response = [:status=>"success", :remaining_requests=>499]
else
response = [:status=>"failure", :remaining_requests=>499, :errors => [something]]
end
end
pets:
name | owner
--------------------
spot | Dog
Rover | Dog
Fluffy | Cat
def non_multi_dupes
non_multi_specs = Spec.find_all_by_is_multival(false).select{|x| parent = x.try(:parent); !parent.try(:is_multival)}
non_multi_sids = non_multi_specs.collect {|s| s.id}
# this sql will find all spec values grouped by product_id+spec_id where the count of this grouping is greater than 1
sql = ["select * from spec_values where spec_id in (?) group by spec_id, product_id having (count(*) > 1)", non_multi_sids]
puts "about to do a beefy sql statement. Shouldn't take longer than 10 seconds or so."
single_dupe_svs = SpecValue.find_by_sql(sql)
before_save :check_for_blanks
...
def check_for_blanks
debugger
if (self.token.blank?)
self.token = ApiKey.generate_token
end
def check_for_blanks
defaults = ApiKey.new
self.attributes.each do |k, v|
self[k] == defaults[k] if v.blank?
end
end
Viewfinder Score : 8.25, 8.25
Menu Score : 6, 6
Viewfinder Score - Scaled : 7.67441860465116, 7.67441860465116
Menu Score - Scaled : 3.04347826086957, 3.04347826086957
Performance Metascore : 6.5805381117459, 1.70070078521717, 1.34244316044779
Usability Metascore : 5.56540390658712, -0.0825331872914443