$ rails g model User
belongs_to
has_one
| ּ_בּ | |
| בּ_בּ | |
| טּ_טּ | |
| כּ‗כּ | |
| לּ_לּ | |
| מּ_מּ | |
| סּ_סּ | |
| תּ_תּ | |
| ٩(×̯×)۶ | |
| ٩(̾●̮̮̃̾•̃̾)۶ |
| =Navigating= | |
| visit('/projects') | |
| visit(post_comments_path(post)) | |
| =Clicking links and buttons= | |
| click_link('id-of-link') | |
| click_link('Link Text') | |
| click_button('Save') | |
| click('Link Text') # Click either a link or a button | |
| click('Button Value') |
| namespace :db do desc "Backup project database. Options: DIR=backups RAILS_ENV=production MAX=7" | |
| task :backup => [:environment] do | |
| datestamp = Time.now.strftime("%Y-%m-%d_%H-%M-%S") | |
| base_path = Rails.root | |
| base_path = File.join(base_path, ENV["DIR"] || "backups") | |
| backup_base = File.join(base_path, 'db_backups') | |
| backup_folder = File.join(backup_base, datestamp) | |
| backup_file = File.join(backup_folder, "#{RAILS_ENV}_dump.sql") | |
| FileUtils.mkdir_p(backup_folder) | |
| db_config = ActiveRecord::Base.configurations[RAILS_ENV] |
| #!/usr/bin/env ruby | |
| # Convert command line | |
| # | |
| #gm convert -font helvetica -fill white -pointsize 20 -draw "text 500,600 'WALLPAPERZ ARE GOOD'" test.jpg output.jpg | |
| # | |
| #convert -background transparent -fill white -gravity center -size 1024x200 -font Helvetica -pointsize 20 #caption:"I'm a wallpaper, you know what to do" test.jpg +swap -gravity south -composite output.jpg | |
| # | |
| # Mogrify command line | |
| # |
| <%= form_for(@user) do |f| %> | |
| <% if @user.errors.any? %> | |
| <div id="error_explanation"> | |
| <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2> | |
| <ul> | |
| <% @user.errors.full_messages.each do |msg| %> | |
| <li><%= msg %></li> | |
| <% end %> | |
| </ul> |
| # Change devise encryption strategy to match your existing authentication | |
| # https://github.com/plataformatec/devise/tree/master/lib/devise/encryptors | |
| class MigrateUsers < ActiveRecord::Migration | |
| def self.up | |
| rename_column :users, :crypted_password, :encrypted_password | |
| add_column :users, :confirmation_token, :string, :limit => 255 | |
| add_column :users, :confirmed_at, :timestamp | |
| add_column :users, :confirmation_sent_at, :timestamp |
| #Model | |
| @user.should have(1).error_on(:username) # Checks whether there is an error in username | |
| @user.errors[:username].should include("can't be blank") # check for the error message | |
| #Rendering | |
| response.should render_template(:index) | |
| #Redirecting | |
| response.should redirect_to(movies_path) |
| Latency Comparison Numbers (~2012) | |
| ---------------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |