- Randomly mixes input gathering, error handling, and business logic
- imposes cognitive load on the reader
- no digressions
| Factory.define :item do |f| | |
| include ActionDispatch::TestProcess | |
| f.name "Macbook Pro 15" | |
| f.price_in_dollars 1500 | |
| f.photo fixture_file_upload('/files/avatar.jpg', 'image/jpg') | |
| end |
| # yes, sometimes you need to do this. you get pilloried in a forum if you | |
| # ask about it, though! | |
| # this code taken from | |
| # http://wholemeal.co.nz/blog/2011/04/05/rendering-from-a-model-in-rails-3/ | |
| class MyModel < ActiveRecord::Base | |
| # Use the my_models/_my_model.txt.erb view to render this object as a string | |
| def to_s | |
| ActionView::Base.new(Rails.configuration.paths.app.views.first).render( |
| literally always have to look up the meaning of :limit in migrations when it comes to integer values. Here's an overview. Now let's memorise it (oh, this works for MySQL, other databases may work differently): | |
| :limit Numeric Type Column Size Max value | |
| 1 tinyint 1 byte 127 | |
| 2 smallint 2 bytes 32767 | |
| 3 mediumint 3 byte 8388607 | |
| nil, 4, 11 int(11) 4 byte 2147483647 | |
| 5..8 bigint 8 byte 9223372036854775807 | |
| Note: by default MySQL uses signed integers and Rails has no way (that I know of) to change this behaviour. Subsequently, the max. values noted are for signed integers. |
| class Forum | |
| include Mongoid::Document | |
| include Mongoid::Timestamps | |
| field :posts_count, :type => Integer, :default => 0 | |
| has_many_related :posts | |
| end |
| /* Extend the Underscore object with the following methods */ | |
| // Rate limit ensures a function is never called more than every [rate]ms | |
| // Unlike underscore's _.throttle function, function calls are queued so that | |
| // requests are never lost and simply deferred until some other time | |
| // | |
| // Parameters | |
| // * func - function to rate limit | |
| // * rate - minimum time to wait between function calls | |
| // * async - if async is true, we won't wait (rate) for the function to complete before queueing the next request |
| root - admin123 | |
| developer - admin123 | |
| rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm | |
| yum install --enablerepo=webtatic git | |
| sudo yum install curl | |
| sudo su - | |
| groupadd rvm | |
| usermod -a -G rvm root |
| cd ~ | |
| sudo yum update | |
| sudo yum install java-1.7.0-openjdk.i686 -y | |
| wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.9.tar.gz -O elasticsearch.tar.gz | |
| tar -xf elasticsearch.tar.gz | |
| rm elasticsearch.tar.gz | |
| mv elasticsearch-* elasticsearch | |
| sudo mv elasticsearch /usr/local/share |
This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.
You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.