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
Get the previous commit hash from the last line of .git/logs/HEAD | |
Replace .git/refs/heads/yourbranch with it | |
"git status" should now work. Note the files changed (you will copy them later) | |
Push this repo elsewhere (a different branch on origin) | |
Remove the .git directory | |
Pull that repo back out to a different directory | |
Copy over the noted files to that directory | |
Commit them |
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
# Ruby 1.9.2 | |
Random.new.rand(10..15) # 10, 11, 12, 13, 14, 15 | |
Random.new.rand(10...15) # 10, 11, 12, 13, 14 | |
# Ruby >1.9.2 | |
rand(10..15) |
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
[*1..5] # => [1, 2, 3, 4, 5] |
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
days = ["Friday", "Saturday", "Sunday", "Monday", "Friday", "Saturday", "Friday"] | |
days.inject({}) {|h,day| h[day] = h.include?(day) ? h[day]+1 : 1; h }.sort_by{|k,v|v}.reverse.each{|k,v| puts [k,v].join(",")} | |
#Friday,3 | |
#Saturday,2 | |
#Sunday,1 | |
#Monday,1 |
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
# remember to add "devise :token_authenticatable" to user.rb | |
# and uncomment "config.token_authentication_key = :auth_token" from devise.rb | |
class AddTokenAuthenticatableToUsers < ActiveRecord::Migration | |
def self.up | |
change_table(:users) do |t| | |
t.token_authenticatable | |
end | |
User.reset_column_information | |
User.all.each do |user| |
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
git checkout master | |
git merge --squash private_feature_branch | |
git commit -v |
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
# stops once it finds a match | |
@users.detect { |u| u.gender == 'm' } |
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
[1,2,3].inject([]) {|new_array, incoming_item| new_array << "item#{incoming_item}"} | |
# => ["item1", "item2", "item3"] |
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
(1..10).inject([]) {|all, i| all << "i#{i}"} | |
# => ["i1", "i2", "i3", "i4", "i5", "i6", "i7", "i8", "i9", "i10"] |
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
ActiveRecord::Base.logger = Logger.new(STDOUT) |