Skip to content

Instantly share code, notes, and snippets.

View luminousmen's full-sized avatar

Kirill luminousmen

View GitHub Profile
@luminousmen
luminousmen / dino.py
Last active April 23, 2020 15:35
T-Rex dino game script that will play for you, successfully
import numpy as np
import cv2
from mss import mss
import pyautogui as pg
# Please put here you location of t-rex, I used `$ xdotool getmouselocation` for that
MONITOR = {"top": 247, "left": 566, "width": 70, "height": 35}
def process_image(img):
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@luminousmen
luminousmen / run.sh
Created August 1, 2019 18:34
Big Data file formats
#!/bin/bash
END=3
FUNC="stats"
for ((i=1;i<=END;i++)); do
for fmt in csv json avro parquet; do
spark-submit --packages org.apache.spark:spark-avro_2.11:2.4.0 script.py $fmt $FUNC
done
done
import random
letters = [
"Person 1",
"Person 2",
"Person 3",
"Person 4",
]
print(f"Next: `{random.choice(letters)}`")
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@luminousmen
luminousmen / mail.sh
Created December 22, 2022 04:23
Bash send mail
echo "this is the body" | mail -s "this is the subject" "to@address"
@luminousmen
luminousmen / retry.sh
Created December 22, 2022 04:24
Bash retry function
function retry {
local retries=3
local count=0
until "$@"; do
exit=$?
wait=$((10 ** $count))
count=$(($count + 1))
if [ $count -lt $retries ]; then
echo "Retry $count/$retries exited $exit, retrying in $wait seconds..."
sleep $wait
@luminousmen
luminousmen / bloom_1.py
Last active January 31, 2023 22:40
Sample bloom filter implementations
# Hash implementations from
# http://www.partow.net/programming/hashfunctions/index.html
# Author: @luminousmen
class BloomFilter:
def __init__(self, size: int):
self.size = size
self.bitmap = size * [0]
def FNV(self, key: str):
@luminousmen
luminousmen / latency.markdown
Created July 29, 2023 02:38 — 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