This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):001:0> 1.class | |
=> Integer | |
irb(main):002:0> 1.to_s | |
=> "1" | |
irb(main):003:0> class Integer | |
irb(main):004:1> def to_s | |
irb(main):005:2> "two" | |
irb(main):006:2> end | |
irb(main):007:1> end | |
=> :to_s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a onafterprint="console.log(244599)" onbeforeprint="console.log(309354)" onbeforeunload="console.log(879813)" onerror="console.log(949564)" onhashchange="console.log(575242)" onload="console.log(301053)" onmessage="console.log(976974)" onoffline="console.log(796090)" ononline="console.log(432638)" onpagehide="console.log(504345)" onpageshow="console.log(696619)" onpopstate="console.log(398418)" onresize="console.log(943097)" onstorage="console.log(882233)" onunload="console.log(929443)" onblur="console.log(932104)" onchange="console.log(102339)" oncontextmenu="console.log(761265)" onfocus="console.log(188946)" oninput="console.log(143653)" oninvalid="console.log(304208)" onreset="console.log(318472)" onsearch="console.log(778420)" onselect="console.log(942035)" onsubmit="console.log(603589)" onkeydown="console.log(650647)" onkeypress="console.log(579383)" onkeyup="console.log(821763)" onclick="console.log(284098)" ondblclick="console.log(477370)" ondrag="console.log(439095)" ondragend="console.log(546684)" o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
git filter-branch --env-filter ' | |
OLD_EMAIL="your-old-email@example.com" | |
CORRECT_NAME="Your Correct Name" | |
CORRECT_EMAIL="your-correct-email@example.com" | |
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ] | |
then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Activate the gem you are reporting the issue against. | |
gem 'activerecord', '4.0.0' | |
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
# This connection will do for database-independent bug reports. | |
# ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'shiz.db') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
devise = yes?("Devise? ") | |
cancan = yes?("Cancan? ") | |
omniauth = yes?("Omniauth? ") | |
foundation = yes?("Foundation? ") | |
bootstrap = foundation ? false : yes?("Bootstrap? ") | |
ember = yes?("Ember? ") | |
handlebars = ember ? false : yes?("Handlebars? ") | |
underscore = yes?("Underscore? ") | |
staticpages = yes?("Static Pages Controller with home page? ") | |
github = yes?("GitHub create and push? ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 | |
@user.errors[:email].should include("is invalid") # check for the error format message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = method_that_returned_nil() #=> nil | |
x ||= "default" #=> "default" : value of x is nil, so it will be replaced with "default" | |
x ||= "other" #=> "default" : value of x is "default" so it will stay "default" and NOT be set to "other" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var1, var2 = [1, 2] # var1 = 1; var2 = 2 | |
var1, var2 = 1, 2 # var1 = 1; var2 = 2 | |
var1, var2 = 1 # var1 = 1; var2 = nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Factorial | |
attr_reader :computed | |
def initialize(number) | |
@computed = solve(number) | |
end | |
def solve(number) | |
number > 1 ? number * solve(number-1) : 1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cmd": [ "/Users/YOUR_USER_NAME/.rvm/bin/rvm-auto-ruby", "$file" ], | |
"file_regex": "^(...*?):([0-9]*):?([0-9]*)", | |
"selector": "source.ruby" | |
} |