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
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
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
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: example | |
namespace: default | |
data: | |
APPLICATION_HOST: example.com | |
LANG: en_US.UTF-8 | |
PIDFILE: /tmp/server.pid | |
PORT: "3000" |
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
$map = Hash.new | |
def fibonacci(n) | |
if $map.key?(n) | |
return $map[n] | |
end | |
if n==1 || n==0 | |
return 1 | |
else | |
val = fibonacci(n-1)+fibonacci(n-2) |
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
def reverse(input) | |
rev = "" | |
i = input.length-1 | |
while i>=0 do | |
rev = rev+input[i] | |
i=i-1 | |
end | |
puts rev | |
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
require "stripe" | |
Stripe.api_key = "YOUR_API_KEY" | |
def grab_and_process_charges(list_of_charges) | |
# complete the task that you need to do with your list of charges | |
list_of_charges.each do |charge| | |
puts "charge id is #{charge['id']} and the amount is #{charge['amount']} in currency #{charge['currency']}" | |
end | |
end | |
list_of_charges = Stripe::Charge.list(limit: 10) |
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
<video id="into-video" class="video-js vjs-default-skin" autoplay controls preload="auto" width="640" | |
poster="https://mycdn.cloudfront.net/myposter.png"> | |
<source src="https://mycdn.cloudfront.net/video.webm" type='video/webm' /> | |
<source src="https://mycdn.cloudfront.net/video.mp4" type='video/mp4' /> | |
<p class="vjs-no-js">To view this video please enable JavaScript, or consider upgrading your browser.</p> | |
</video> |
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
INSTALL JAVA | |
$ sudo apt-get update && sudo apt-get install default-jre | |
INSTALL ELASTIC SEARCH https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html | |
$ wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - | |
$ echo "deb https://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list | |
$ sudo apt-get update && sudo apt-get install elasticsearch | |
$ sudo update-rc.d elasticsearch defaults 95 10 | |
$ sudo service elasticsearch restart | |
$ sudo service elasticsearch status |
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
upstream myapp_puma { | |
server unix:/tmp/myapp_puma.sock fail_timeout=0; | |
} | |
# for redirecting to https version of the site | |
server { | |
listen 80; | |
rewrite ^(.*) https://$host$1 permanent; | |
} | |
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
source 'https://rubygems.org' | |
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' | |
gem 'rails', '~> 5.0.0', '>= 5.0.0.1' | |
# Use postgresql as the database for Active Record | |
gem 'pg', '~> 0.18' | |
gem 'sidekiq' | |
gem 'detect_timezone_rails' | |
# Use Puma as the app server |
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
def flatten(input) | |
result = Array.new | |
input.each do |element| | |
if element && element.instance_of?(Array) | |
# if the current element is an array then recursively flatten that | |
# array and add that array to the result | |
result = result+flatten(element) | |
else | |
# else this is just a regular element and add the element to result | |
result << element |