Skip to content

Instantly share code, notes, and snippets.

View airhorns's full-sized avatar
🎯
Workin' on Gadget at https://gadget.dev

Harry Brundage airhorns

🎯
Workin' on Gadget at https://gadget.dev
View GitHub Profile
git filter-branch -f --index-filter 'git update-index --remove public/images/posters/fc1cc0358623559b6935b22e56d136a3.jpg'
git filter-branch -f --index-filter 'git update-index --remove public/images/posters/f9dea1841c49c481ea6de11ad37b7c92.jpg'
.
.
.
rm -rf .git/refs/original/ && git reflog expire --all && git gc --aggressive --prune
git push --force --verbose --dry-run
git push --force
class Movie < ActiveRecord::Base
acts_as_taggable
has_one :download, :as => :resource, :dependent => :destroy
has_attached_file :poster, :styles => {:medium => "300x300>", :thumb => "100x100>"}
before_validation :download_remote_image, :if => :image_url_provided?
validates_associated :download
validates_presence_of :title
validates_numericality_of :year, :allow_nil => true
/Users/hornairs/.rvm/gems/ruby-1.9.2-head@rails3/gems/actionpack-3.0.0.beta3/lib/action_view/helpers/url_helper.rb:30:in `url_options'
/Users/hornairs/.rvm/gems/ruby-1.9.2-head@rails3/gems/actionpack-3.0.0.beta3/lib/action_dispatch/routing/url_for.rb:131:in `url_for'
/Users/hornairs/.rvm/gems/ruby-1.9.2-head@rails3/gems/actionpack-3.0.0.beta3/lib/action_view/helpers/url_helper.rb:107:in `url_for'
/Users/hornairs/.rvm/gems/ruby-1.9.2-head@rails3/gems/actionpack-3.0.0.beta3/lib/action_dispatch/routing/route_set.rb:180:in `contact_path'
app/helpers/contacts_helper.rb:31:in `block (2 levels) in format_grid!'
vendor/plugins/gridify/lib/gridify/grid_finder.rb:63:in `call'
vendor/plugins/gridify/lib/gridify/grid_finder.rb:63:in `block (2 levels) in encode_records'
/Users/hornairs/.rvm/gems/ruby-1.9.2-head@rails3/gems/activemodel-3.0.0.beta3/lib/active_model/serializers/xml.rb:186:in `call'
/Users/hornairs/.rvm/gems/ruby-1.9.2-head@rails3/gems/activemodel-3.0.0.beta3/lib/active_model/serializers/xml.rb:186:in `block
Started GET "/work_orders/queue" for 127.0.0.1 at 2010-07-18 19:53:11 -0400
SQL (1.6ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
SQL (1.1ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
SQL (1.1ms) SELECT name
FROM sqlite_master
# model
class GiftIdea
has_many :images
end
# in the view (say app/views/gift_ideas/show.html.erb)
# say we are rendering html about one GiftIdea object, found in the @gift_idea variable
..
..
<div class="gift_idea">
Started GET "/product_categories/autocomplete_for_product_sub_category_name?q=ang&limit=10&timestamp=1279805094583" for 130.15.105.53 at 2010-07-22 09:29:55 -0400
Processing by ProductCategoriesController#autocomplete_for_product_sub_category_name as HTML
Parameters: {"q"=>"ang", "limit"=>"10", "timestamp"=>"1279805094583"}
Rendered inline template (0.6ms)
Completed 200 OK in 58ms (Views: 1.7ms | ActiveRecord: 7.7ms)
Started GET "/product_categories/autocomplete_for_product_sub_category_name?q=ang&limit=10&timestamp=1279805094583" for 130.15.105.53 at 2010-07-22 09:30:05 -0400
Processing by ProductCategoriesController#autocomplete_for_product_sub_category_name as HTML
Parameters: {"q"=>"ang", "limit"=>"10", "timestamp"=>"1279805094583"}
def build_role(&block)
@role = Role.new
self.instance_eval &block if block_given?
r = @role
@role = nil
r
end
Questions: do you always need to have m or can you just use a helper method where you get the number of elements in a, that way you limit the number of parameters you pass always?
1. More on list intersections
Algorithm: commonElementsList( a, m, b, n)
Input: Two arrays, a and b, with m and n distinct String elements respectively
Output: A list of String elements common to both arrays
function commonElementsList( a, m, b, n) {
if( listIntersection( a, m, b, n ) > 0 )
User
- has_many :end_of_day_reports
Quote
- has_and_belongs_to_many :end_of_day_reports
- has_many :time_reports
EndOfDayReport
- has_and_belongs_to_many :quotes
- belongs_to :user
module Toto
module Template
def to_html page, config, &blk
path = ([:layout, :repo].include?(page) ? Paths[:templates] : Paths[:pages])
config[:to_html].call(path, page, self, blk)
end
end
end