- Write a function called
stop_sign
that prints out the questionWhich way do you want to turn?
and then takes keyboard input from the user. If the input equalsleft
printTurning left!
. If the input equalsright
printTurning right!
. If the input is anything other than the two previous options, printCrash!!!
- Write a function called
spaces
that takes a string as input. Return the number or spaces in the string as an integer.
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
defmodule Success do | |
@type t :: %Success{value: any} | |
defstruct value: nil | |
end | |
defmodule Failure do | |
@type t :: %Failure{value: any, reason: String.t} | |
defstruct value: nil, reason: nil | |
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
defmodule EmailValidation do | |
def validate(email) do | |
email_validation_result = {:ok, email} | |
check_for_validity(email_validation_result) | |
|> check_if_email_taken | |
end | |
defp check_for_validity({:ok, email}) do | |
case check_against_regex(email) do |
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
Dir.glob("**/*.rb").each do |file| | |
`vim -c "set ts=4 sts=4 noet|retab!|set ts=2 sts=2 et|retab|wq" #{file}` | |
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
module Products | |
# What if we want to differ the content between iOS and Web? | |
class IndexResource | |
def initialize(product_presenters, content_type) | |
@product_presenters = product_presenters | |
@content_type = content_type | |
end | |
def render(rendering_engine = RenderingEngine) | |
rendering_engine.render(partial_path, product_presenters: product_presenters) |
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
module Products | |
# What if we want to differ the content between iOS and Web? | |
class IndexResource | |
def initialize(product_presenters, content_type) | |
@product_presenters = product_presenters | |
@content_type = content_type | |
end | |
def render(rendering_engine = RenderingEngine) | |
rendering_engine.render(partial_path, product_presenters: product_presenters) |
- A function named
dog
that prints out "Woof!" to the screen. - A function named
cat
that prints out "Meow." to the screen. - A function named
hello_name
that takes a string as input and prints out "Hello, name!" wherename
is the string given as input. - A function named
even?
that takes a number as input and returns true if the number is evenly divisibly by 2 and false otherwise. - A function named
multiple_of?
that takes 2 inputs. For example:multiple_of?(2, 4)
returnstrue
because 4 is a multiple of 2 (2*2 = 4).multiple_of?(5, 32)
returns false because 32 is not a multiple of 5. - A function named
count
that takes a number as input and prints out all the numbers between 0 and number to the screen. - A function named
multiples
that takes a number as input, and returns an array containing all results of the given number multiplied by the numbers from 1 to 10. So formultiples(5)
the result should be[5,10,15,20,25, ...]
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
# On the host machine, run | |
tmux -S /tmp/foo | |
chmod 777 /tmp/foo | |
# From the remote machine | |
ssh username@host | |
tmux -S /tmp/foo attach |
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
presenters.ClickerAlert = function(element) { | |
$(element).on('click', showAlert); | |
function showAlert(){ | |
alert("Hey, you clicked me!"); | |
} | |
} | |
(function($, ns) { | |
ns('clicker-alert', { |
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
module Example | |
class Dog | |
attr_reader :stomach | |
def initialize(stomach) | |
@stomach = stomach | |
end | |
def hungry? | |
stomach.empty? |
NewerOlder