!!Repeat Previous Command!-1Repeat Previous Command!-2Repeat 2nd Previous Command!psExecute Previous Command STARTING WITH ps!^First Argument From Previous Command!:22nd Argument From Previous Command!$Last Argument From Previous Command!!:$Last Argument From Previous Command
This file contains hidden or 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
| require 'active_record' | |
| require 'arel' | |
| # Ruby-like syntax in AR conditions using the underlying Arel layer (Rails >= 3.0). | |
| # | |
| # What you would usually write like this: | |
| # | |
| # User.where(["users.created_at > ? AND users.name LIKE ?", Date.yesterday, "Mary"]) | |
| # | |
| # can now be written like this: |
If the namespace is not used then the commands will perform on top of the default database.
bundle exec rake db:create
bundle exec rake db:migrate
By using the namespace we are going to use all the configuration for our alternate DB.
bundle exec rake store:db:create
bundle exec rake store:db:migrate
This file contains hidden or 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
| messages = [nil, "Fizz", "Buzz", "FizzBuzz"] | |
| acc = 810092048 | |
| (1..100).each do |i| | |
| c = acc & 3 | |
| puts messages[c] || i | |
| acc = acc >> 2 | c << 28 | |
| end | |
| # Explanation | |
| # |
This file contains hidden or 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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
I hereby claim:
- I am jrhorn424 on github.
- I am jrhorn (https://keybase.io/jrhorn) on keybase.
- I have a public key whose fingerprint is EA9D 4FC3 908C 7657 08BB 2A11 A2D2 72CF F38D B3A7
To claim this, I am signing this object:
See full kata at codewars
Finish the function numberToOrdinal, which should take a number and return it as a string with the correct ordinal indicator suffix (in English). That is:
- numberToOrdinal(1) ==> '1st'
- numberToOrdinal(2) ==> '2nd'
- numberToOrdinal(3) ==> '3rd'
- numberToOrdinal(4) ==> '4th'
This file contains hidden or 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
| body { | |
| width: 100%; | |
| height: 500px; | |
| margin: 0; | |
| padding: 0; | |
| text-align: center; | |
| } | |
| body:before { | |
| display: inline-block; | |
| content: ' '; |
This file contains hidden or 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
| # lib/tasks/db.rake | |
| # execute me with rake db:nuke_pave | |
| namespace :db do | |
| desc "drops, creates, migrates, and seeds database" | |
| unless Rails.env == "Production" | |
| task :nuke_pave => %w(environment db:drop db:create db:migrate db:seed) do | |
| # If you have a sample file that creates data for you to play with locally: | |
| # Rake::Task["db:sample"].execute if Rails.env == "development" | |
| puts "Nuke and pave of #{Rails.env} complete." |
This file contains hidden or 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
| # Encapsulate the configuration DSL pattern. | |
| # | |
| # Any `X=(value)` setter method on the given +obj+ is translated into `X(value)` method | |
| # in the context of this object. | |
| class ConfigDSL < BasicObject | |
| def initialize(obj, &config) | |
| @self = obj | |
| call(&config) | |
| end |