start new:
tmux
start new with session name:
tmux new -s myname
| # RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
| # defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
| module Player | |
| describe MovieList, "with optional description" do | |
| it "is pending example, so that you can write ones quickly" | |
| it "is already working example that we want to suspend from failing temporarily" do | |
| pending("working on another feature that temporarily breaks this one") |
| # switch default editor for pry to sublime text | |
| Pry.config.editor = "sublime" | |
| # format prompt to be <Rails version>@<ruby version>(<object>)> | |
| Pry.config.prompt = proc do |obj, level, _| | |
| prompt = "\e[1;30m" | |
| prompt << "#{Rails.version} @ " if defined?(Rails) | |
| prompt << "#{RUBY_VERSION}" | |
| "#{prompt} (#{obj})>\e[0m" | |
| end |
| # Rake Quick Reference | |
| # by Greg Houston | |
| # http://ghouston.blogspot.com/2008/07/rake-quick-reference.html | |
| # ----------------------------------------------------------------------------- | |
| # Running Rake | |
| # ----------------------------------------------------------------------------- | |
| # running rake from the command-line: | |
| # rake --help |
| ## If you are using under a rails project, | |
| ## I recommend to put this script onto config/initializer instead of applying the patch | |
| module Compass::SassExtensions::Functions::GradientSupport | |
| class ColorStop < Sass::Script::Literal | |
| def initialize(color, stop = nil) | |
| self.options = {} | |
| if color.is_a?(Sass::Script::String) && color.value == 'transparent' |
| # 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 |
| # RSpec's subject method, both implicitly and explicitly set, is useful for | |
| # declaratively setting up the context of the object under test. If you provide a | |
| # class for your describe block, subject will implicitly be set to a new instance | |
| # of this class (with no arguments passed to the constructor). If you want | |
| # something more complex done, such as setting arguments, you can use the | |
| # explicit subject setter, which takes a block. | |
| describe Person do | |
| context "born 19 years ago" do | |
| subject { Person.new(:birthdate => 19.years.ago } | |
| it { should be_eligible_to_vote } |
| source "https://rubygems.org" | |
| gem 'sprockets' | |
| gem 'sprockets-sass' | |
| gem 'sass' | |
| gem 'compass' | |
| gem 'bootstrap-sass' | |
| gem 'handlebars_assets' | |
| gem 'coffee-script' |
| #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) |
| /* Exercise: Loops and Functions #43 */ | |
| package main | |
| import ( | |
| "fmt" | |
| "math" | |
| ) | |
| func Sqrt(x float64) float64 { | |
| z := float64(2.) |