Skip to content

Instantly share code, notes, and snippets.

View ayinlaaji's full-sized avatar
🧐
Observing

Àyìnlá Ọmọ́tọ́ṣọ̀ Abdulsalam ayinlaaji

🧐
Observing
View GitHub Profile
@ayinlaaji
ayinlaaji / node.sh
Last active February 28, 2018 12:00
Setup nodejs linux server
#!/bin/bash
sudo apt-get update
sudo apt-get install -y wget git
wget -qO- https://deb.nodesource.com/setup_8.x | sudo bash -
sudo apt-get install -y nodejs build-essential
sudo npm install -g nodemon yarn pm2
@ayinlaaji
ayinlaaji / determine-os.sh
Last active February 19, 2018 09:59
Script to determine operation system version
#!/bin/bash
# Determine OS platform
UNAME=$(uname | tr "[:upper:]" "[:lower:]")
# If Linux or darwin, try to determine specific distribution
if [ "$UNAME" == "linux" ] ; then
# If available, use LSB to identify distribution
if [ -f /etc/lsb-release -o -d /etc/lsb-release.d ]; then
export DISTRO=$(lsb_release -i | cut -d: -f2 | sed s/'^\t'//)
# Otherwise, use release info file
@ayinlaaji
ayinlaaji / index.html
Last active April 26, 2018 12:04
immutable Objects #jsbench #jsperf (http://jsbench.github.io/#f0b9f46cba8ca404524eea52de090089) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>immutable Objects #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@ayinlaaji
ayinlaaji / index.html
Last active April 26, 2018 12:02
Slicing arguments #jsbench #jsperf (http://jsbench.github.io/#a706c23667317f9d24d474f155d4285a) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Slicing arguments #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@ayinlaaji
ayinlaaji / currying.js
Last active April 26, 2018 13:39
Playing with currying
// Understanding currying
// Github Git @ayinlaaji
const curry = funcToBeCurried => {
const noArgs = funcToBeCurried.length;
return doYouHaveMore([]);
//Hoisting :D
function doYouHaveMore(prevArgs) {
@ayinlaaji
ayinlaaji / partial-application.js
Created April 26, 2018 18:30
Understanding partial applications
// Understanding partial applications
// Github Gist @ayinlaaji
function partiallyApply(func) {
const someArgs = Array.prototype.slice.call(arguments, 1);
return giveMeRemainingArgs;
//Hoisting :D
function giveMeRemainingArgs() {
@ayinlaaji
ayinlaaji / latency.markdown
Created June 9, 2018 12:31 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@ayinlaaji
ayinlaaji / latency.txt
Created June 9, 2018 12:31 — 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
@ayinlaaji
ayinlaaji / data-feeds.md
Last active June 24, 2018 17:39
data-feeds
@ayinlaaji
ayinlaaji / snips.md
Last active May 3, 2020 17:54
snippets

Snips

  • Find and rename files with regexp

    find . -type f -name '*.stories.tsx' -execdir  rename  -v 's/(.*)\.stories\.tsx$/component\.stories\.tsx/' {} \;;
    
  • Redirect port:

    sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000