Use guard-shell gem.
# terminal (at exercism/ruby/)
gem install guard guard-shell
guard init shell
# Guardfile
# return the unique elements of this array: | |
# a = [] | |
# 10000000.times{a.push(rand(100))} | |
# no array.uniq please | |
# extra credit -- in one function, count all the occurrences of each element of a | |
a = [] | |
10000000.times{a.push(rand(100))} |
# Take this array: | |
a = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] | |
# and transform it into this array | |
# [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 0, 0]] | |
flat = a.flatten |
# write a method called "transpose" that takes this array of arrays: | |
# [ | |
# ['first', 'second'], | |
# ['third', 'fourth'] | |
# ] | |
# and transposes it into this array of arrays | |
# [ |
elm package install | |
elm package install evancz/elm-html | |
<add & edit Bingo.elm> | |
# elm make --warn Bingo.elm --output index.html | |
elm reactor # and then open Bingo.elm file | |
module Bingo where |
# terminal (at exercism/ruby/)
gem install guard guard-shell
guard init shell
# Guardfile
##Quiz: Lesson 3 Solutions
####1. What's the difference between rendering and redirecting? What's the impact with regards to instance variables, view templates?
Rendering displays a view template that accesses the instance variables available in that action. Therefore, instance variables must be declared in that action before the render will work. Redirecting will send a new request to the browser based on the route path that was provided. In this case, the instance variables in that action are not related to the redirected view.
####2. If I need to display a message on the view template, and I'm redirecting, what's the easiest way to accomplish this?
You can use flash, which saves the message with a session. The message will be displayed on your next action and will be removed after that. flash[:message] = 'Your account was created.' redirect_to :back
git clone https://github.com/kangkyu/list-of-hamburger-restaurants.git | |
cd list-of-hamburger-restaurants | |
echo "# list-of-hamburger-restaurants" >> README.md | |
git add README.md | |
git commit -m "first commit" | |
git push -u origin master |
<form action="http://google.com"> | |
<input type="submit" value="Go to Google"> | |
</form> | |
<a href="http://google.com">Go to Google</a> |
(0..9).to_a + ('a'..'z').to_a + ('A'..'Z').to_a + %w(! @ # $ % ^ & * < > ?) | |
a = _ | |
a.shuffle.pop(9).join |
- if @task.errors.any? | |
= content_tag(:div, class: ["alert", "alert-danger", "alert-dismissible"], role: "alert", id: "error-explanation") do | |
= content_tag(:button, class: "close", type: "button", "data-dismiss"=> "alert") do | |
= content_tag(:span, escape_once("×"), "aria-hidden"=> "true") | |
= content_tag(:span, "Close", class: "sr-only") | |
%p= pluralize(@task.errors.count, "error") + " prohibited this user from being saved" | |
%ul | |
- @task.errors.full_messages.each do |msg| | |
%li= msg |