Skip to content

Instantly share code, notes, and snippets.

@netologist
netologist / latency.markdown
Created July 11, 2022 12:08 — 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

@netologist
netologist / asyncio.wait.py
Created May 25, 2022 11:55 — forked from Integralist/asyncio.wait.py
[Wait for multiple Python futures to finish using asyncio.wait()] #asyncio #wait #concurrency #multiple #requests #httpclient
import time
import asyncio
import requests
domain = 'http://integralist.co.uk'
a = '{}/foo?run={}'.format(domain, time.time())
b = '{}/bar?run={}'.format(domain, time.time())
async def get(url):
print('start: ', url)
@netologist
netologist / cka-ckad-bookmarks
Created February 25, 2021 19:51 — forked from milindchawre/cka-ckad-bookmarks
Bookmarks for cka and ckad exam
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 ADD_DATE="1604897638" LAST_MODIFIED="0" PERSONAL_TOOLBAR_FOLDER="true">Bookmarks bar</H3>
<DL><p>
(cd /some/dir && zip -r - dir-there) > file.zip
https://unix.stackexchange.com/questions/77605/change-working-directory
@netologist
netologist / Dockerfile
Last active October 13, 2017 04:28
nginx react unsupported
FROM nginx:alpine
ADD dist/ /usr/share/nginx/html
ADD /docker/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
https://www.ximedes.com/test-redux-action-creators-with-jest/
@netologist
netologist / photos-date-changer.sh
Last active May 18, 2017 06:36
photos-date-changer.sh
#!/bin/bash
for folder in */ ; do
d1=${folder%%_*}
for file in "$folder"*; do
echo "$file"
if [[ $file =~ \.(avi|AVI|mpeg|mpg|mov|wmv|mp4)$ ]]; then
datestr=${d1//' '/'-'}
f=${file%%.*};
#!/bin/sh
if [ "$1" == "" ]; then
echo "Usage: $0 <PROJECT_ROOT> <GITHUB_REPO>"
exit 1
fi
if [ "$2" == "" ]; then
echo "Usage: $0 <PROJECT_ROOT> <GITHUB_REPO>"
exit 1
fi
package main
import (
"fmt"
"regexp"
)
// Turkish Alpabetic Numeric "(),\-./"
func IsAlphaNumeric(text string) (ok bool) {
ok, _ = regexp.MatchString("^([\\(\\)\\,\\\\\\-\\./ a-zA-ZğüşıöçĞÜŞİÖÇ0-9]+)$", text)
const items = [1,52,14,54,[10,1,3,5],14,6];
const flatten = (arr) => {
const flat = [].concat(...arr)
return flat.some(Array.isArray) ? flatten(flat) : flat;
}
const splitAt = (arr, predicate) => {
var selected = [];
var others = [];