Skip to content

Instantly share code, notes, and snippets.

View shuklaneerajdev's full-sized avatar
🎯
Focusing

Niraj Shukla shuklaneerajdev

🎯
Focusing
View GitHub Profile
@shuklaneerajdev
shuklaneerajdev / latency.txt
Created January 4, 2022 09:52 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
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
@shuklaneerajdev
shuklaneerajdev / configmap.yaml
Created May 16, 2021 12:53 — forked from jferris/configmap.yaml
Rails Kubernetes Manifests
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"
$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)
def reverse(input)
rev = ""
i = input.length-1
while i>=0 do
rev = rev+input[i]
i=i-1
end
puts rev
end
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)
<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>
@shuklaneerajdev
shuklaneerajdev / 1. ELK.install
Created January 18, 2018 07:30 — forked from PavloBezpalov/1. ELK.install
ELK Stack with Rails (Elasticsearch, Logstash, Kibana) on Ubuntu VPS
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
@shuklaneerajdev
shuklaneerajdev / nginx-config-rails4-with-puma-ssl-version.conf
Created January 17, 2018 17:49 — forked from rkjha/nginx-config-rails4-with-puma-ssl-version.conf
Nginx config for rails 4 application using puma [ssl and non-ssl version]
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;
}
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
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