So here is a bit of a complicated ruby function
function4(
function3(
function2(
function1,
value,
),
value,
value,
| defmodule Scrabble do | |
| def score(nil), do: 0 | |
| def score(""), do: 0 | |
| def score("A"), do: 1 | |
| def score("B"), do: 3 | |
| def score("C"), do: 3 | |
| def score("D"), do: 2 | |
| def score("E"), do: 1 | |
| def score("F"), do: 4 | |
| def score("G"), do: 2 |
| POINTS = { | |
| "A" => 1, "B" => 3, "C" => 3, "D" => 2, | |
| "E" => 1, "F" => 4, "G" => 2, "H" => 4, | |
| "I" => 1, "J" => 8, "K" => 5, "L" => 1, | |
| "M" => 3, "N" => 1, "O" => 1, "P" => 3, | |
| "Q" => 10, "R" => 1, "S" => 1, "T" => 1, | |
| "U" => 1, "V" => 4, "W" => 4, "X" => 8, | |
| "Y" => 4, "Z" => 10 | |
| } |
So here is a bit of a complicated ruby function
function4(
function3(
function2(
function1,
value,
),
value,
value,
| class MyObject | |
| include SquareMethod | |
| def method | |
| "#{square 4}" | |
| end | |
| end | |
| module SquareMethod | |
| def square(number) | |
| number * number |
| Nick | |
| - Wednesday | |
| - Thursday | |
| - Friday | |
| Jason | |
| - Thursday |
| Run options: exclude {:skip=>true} | |
| Progress: | | |
| 1) diff output for tags outputs using the standard differ | |
| Failure/Error: expect(hash_1).to eq hash_2 | |
| expected: {1=>2, 53=>60, 87=>88, 71=>72, 39=>40, 37=>38, 33=>60, 99=>100, 21=>22, 93=>94, 15=>16, 29=>30, 83=>84, 55=>56, 41=>42, 79=>80, 49=>50, 47=>48, 89=>90, 63=>60, 91=>92, 67=>68, 11=>12, 17=>18, 5=>6, 69=>70, 59=>60, 35=>36, 3=>4, 81=>82, 97=>98, 43=>44, 75=>76, 9=>10, 13=>14, 23=>60, 77=>78, 7=>8, 27=>28, 73=>60, 25=>26, 95=>96, 51=>52, 31=>32, 61=>62, 65=>66, 57=>58, 85=>86, 19=>20, 45=>46} |
| Automated Styleguide Enforcement | |
| Why bother having a styleguide? | |
| - It gives your code a uniform look and feel | |
| - Makes it easier to read | |
| Why you should automate this? | |
| - Ensures crappy looking code never hits production | |
| - Reduces review time overall |
Combining both find and sed to find and replace words
find app db spec -type f \( -name '*.rb' -o -name '*.sql' \) -exec sed -i '' -e 's/dollar_value/budget_value/g' {} \;
This script:
app, db, and spec directories.rb or .sql filesI've been dealing with large views a lot lately, when looking at individual rows, I find that it dumps to much data on the screen. I found myself using the following pattern a lot.
activity.attributes.slice(*activity.attributes.keys.grep /search_term/I think it would be cool to instead just go
activity.find_columns(:budget)| describe 'examples' do | |
| it "shouldn't alert a cop" do | |
| expect('this').to eq 'this' | |
| expect('this this').to eq 'this this' | |
| end | |
| it "should alert a cop" do | |
| expect('this').to eq 'this' | |
| end | |
| end |