View power_raise.exs
defmodule Power do
defmacro raise_n(x) do
method_name = :"raise_#{x}"
quote do
def unquote(method_name)(val) do
:math.pow(val, unquote(x) )
end
end
end
end
View ping-pong.exs
defmodule PingPong do
import :timer
@timer 500
def ping(x) do
receive do
{pong_pid, n} when n <= x -> IO.puts ("Ping #{n}")
send pong_pid, { self, (n) }
sleep @timer
ping(x)
end
View gist:5502200
updated product:
#<Spree::Product id: nil, name: "He Bear She Bear", description: nil, available_on: nil, deleted_at: nil, permalink: nil, meta_description: "He Bear She Bear", meta_keywords: "He Bear She Bear", tax_category_id: nil, shipping_category_id: nil, created_at: nil, updated_at: nil, count_on_hand: 0, featured: false, taxon_keywords: nil, status: true, delta: true, install: false, heavy_item: false, approved_reviews_count: 0, store_id: nil, from_gardners: true, sync_gardners: true, is_dropship: true, bin_location: nil, row: nil, shelf: nil, column: nil, bin: nil>
rake aborted!
Mysql2::Error: Duplicate entry '646-630' for key 'PRIMARY': INSERT INTO `spree_products_taxons` (`product_id`, `taxon_id`) VALUES (646, 630)
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query'
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:
View gist:5501454
bundle exec rake gb:isbn RAILS_ENV='gardners_staging'
updating isbn data
rake aborted!
undefined method `id' for nil:NilClass
/var/www/Konga-Staging/releases/20130502095740/lib/spree_gardners_books/lib/tasks/gb.rake:304:in `block (2 levels) in <top (required)>'
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
View gist:5500713
bundle exec rake gb:sync_taxon RAILS_ENV='gardners_staging'
rake aborted!
Couldn't find Spree::Taxon with id=949
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:343:in `find_one'
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:314:in `find_with_ids'
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:107:in `find'
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/querying.rb:5:in `find'
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/bundler/gems/spree-59399e6f5d29/core/app/models/spree/taxon.rb:39:in `set_permalink'
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:418:in `_run__1436883041183878916__create__1200570912174408727__callbacks'
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13
View gist:4117298
Hey there! And welcome to my little mailing list about writing faster Rails tests.
My goal is to send you only focused, actionable info that will help you speed up your test suites right away. Let's get started!
The first thing we'll cover is the leading cause of test slowness in Rails apps: bloated fixtures.
Here's an example of a test that will run far slower than it needs to (using factory_girl (a great tool, despite its involvement in this test's slowness)):
describe "#full_name" do
View gist:3720549
# In rails 3.2, it's creating custom error pages is much more easier:
#
# Add this to config/application.rb:
config.exceptions_app = self.routes
# That causes errors to be routed via the router. Then you just add to config/routes.rb:
match "/404", :to => "errors#not_found"
View gist:3550776
Beginner’s Guide to Responsive Web Design
http://blog.teamtreehouse.com/beginners-guide-to-responsive-web-design
Responsive Web Design, by- ETHAN MARCOTTE
http://www.alistapart.com/articles/responsive-web-design/
E-Book on Responsive web design, by - ETHAN MARCOTTE
http://www.abookapart.com/products/responsive-web-design
A Presentation on Responsive Design:
View gist:3433947
# cattr_accessor
class Base
cattr_accessor :settings
# def self.settings
# @@settings
# end
# def self.settings=(value)
View gist:3402488
# Edge rails you can do:
create_join_table :products, :categories
# Earlier:
create_table :categories_products, :id => false do |td|
td.integer :product_id, :null => false
td.integer :category_id, :null => false