require 'benchmark/ips' | |
array = (1..10_000).to_a | |
Benchmark.ips do |x| | |
x.report('each_with_object') { array.each_with_object([]) { |i,a| a << (i * 2) } } | |
x.report('map') { array.map { |i| i * 2 } } | |
x.report('map!') { array.map! { |i| i * 2 } } | |
x.report('reduse') { array.reduce([]) { |a,i| a << i * 2 } } | |
x.compare! |
{% comment %} | |
* | |
* This loop loops through a collection called `collection_name` | |
* and sorts it by the front matter variable `date` and than filters | |
* the collection with `reverse` in reverse order | |
* | |
* To make it work you first have to assign the data to a new string | |
* called `sorted`. | |
* | |
{% endcomment %} |
To create anchor links that jump down to different sections of a README (as in an interactive table of contents), first create a heading:
#Real Cool Heading
The anchor link for that heading is the lowercase heading name with dashes where there are spaces. You can always get the anchor name by visiting the README on Github.com and clicking on the anchor that appears when you hover to the left of the heading. Copy everything starting at the #:
#real-cool-heading
Wherever you want to link to your Real Cool Heading section, put your desired text in brackets, followed by the anchor link in parentheses:
[Go to Real Cool Heading section](#real-cool-heading)
Most example code taken from A Tour of Go, which is an excellent introduction to Go. If you're new to Go, do that tour. Seriously.
- Imperative language
-
Netflix is responsible for about 1/3 of downstream traffic in NA
-
Responsible team in the company is called "edge engineering"
- Apart from resiliency/scaling, also cares about high velocity product innovation and real time health insights
-
Basic architecture:
- end-user devices make requests to ELBs, which delegates to zuul, which routes to origin servers serving APIs
HTTP status code symbols for Rails | |
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
Status Code Symbol | |
1xx Informational | |
100 :continue | |
101 :switching_protocols | |
102 :processing |
defmodule EmailValidator do | |
# ensure that the email looks valid | |
def validate_email(email) when is_binary(email) do | |
case Regex.run(~r/^[\w.!#$%&’*+\-\/=?\^`{|}~]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/i, email) do | |
nil -> | |
{:error, "Invalid email"} | |
[email] -> | |
try do | |
Regex.run(~r/(\w+)@([\w.]+)/, email) |> validate_email |
git branch -m old_branch new_branch # Rename branch locally | |
git push origin :old_branch # Delete the old branch | |
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |