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
| poop_name_is_long = this_is_a_boolean_checker ? | |
| the_stuff_you_do_for_true : | |
| the_stuff_you_do_for_false | |
| poop_name_is_long = | |
| if this_is_a_boolean_checker | |
| the_stuff_you_do_for_true | |
| else | |
| the_stuff_you_do_for_false | |
| end |
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
| ~/personal$ mkdir git_test | |
| ~/personal$ cd git_test/ | |
| ~/personal/git_test$ git init | |
| Initialized empty Git repository in /Users/baldur/personal/git_test/.git/ | |
| ~/personal/git_test$ echo "hi i'm a commit" > first.txt | |
| ~/personal/git_test$ git add first.txt | |
| ~/personal/git_test$ gcom -m "This is my first commit" | |
| [master (root-commit) 129986c] This is my first commit | |
| 1 file changed, 1 insertion(+) | |
| create mode 100644 first.txt |
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
| describe "carrots diced with celery julienned" do | |
| let(:chosen_carrots) { carrots_diced } | |
| let(:chosen_celery) { celery_diced } | |
| describe "user is selecting carrots" do | |
| let(:changed_vegetable) { chosen_carrots } | |
| it_sets :celery, to: :diced | |
| it_does_not_change :carrots | |
| end |
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
| class Wrapper | |
| attr_reader :string | |
| def initialize(string) | |
| @string = string | |
| end | |
| def upcase! | |
| string.upcase! | |
| end |
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
| [1] pry(main)> using Refinements::StringNumericalConversions | |
| => main | |
| [2] pry(main)> "12".to_integer | |
| NoMethodError: undefined method `to_integer' for "12":String | |
| from (pry):2:in `<main>' | |
| [3] pry(main)> class Foo | |
| [3] pry(main)* using Refinements::StringNumericalConversions | |
| [3] pry(main)* def bar | |
| [3] pry(main)* "12".to_integer | |
| [3] pry(main)* end |
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
| module Refinements::StringNumericalConversions | |
| refine String do | |
| def to_integer | |
| banana | |
| Integer(self) | |
| rescue ArgumentError | |
| nil | |
| end | |
| private |
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
| module StringAppleization | |
| refine String do | |
| def appleize | |
| split(' ').map do |word| | |
| appleize_word(word) | |
| end.join(' ') | |
| end | |
| private |
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
| <p> | |
| <%= "Husband: #{husband}" %> | |
| <%= "Wife: #{ begin; husband.wife; rescue NoMethodError; end}" %> | |
| <%= "Status: #{ begin; husband.wife.status; rescue NoMethodError; end}" %> | |
| </p> |
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
| def skills_in_roster(roster) | |
| skills = roster.map { |_, skills_array| skills_array }.flatten.uniq | |
| end | |
| def developers_with_skill(skill, roster) | |
| roster.select do |developer, developer_skills| | |
| developer_skills.include?(skill) | |
| end. | |
| keys.map(&:to_s) | |
| end |
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 'securerandom' | |
| def secure_random_test(max = 1_000_000) | |
| ratio = (0...max).map do | |
| SecureRandom.random_number(max) | |
| end.uniq.count.to_f/max.to_f | |
| (ratio - (1 - 1/Math::E)).abs | |
| end |