Skip to content

Instantly share code, notes, and snippets.

View fikovnik's full-sized avatar

Filip Krikava fikovnik

View GitHub Profile
@fikovnik
fikovnik / latency.markdown
Created July 3, 2019 13:12 — 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

val G1 = List("α", "β", "γ", "δ", "ε", "ϛ", "ζ", "η", "θ")
val G10 = List("ι", "κ", "λ", "μ", "ν", "ξ", "ο", "π", "ϙ")
val G100 = List("ρ", "σ", "τ", "υ", "φ", "χ", "ψ", "ω", "ϡ")
val G1000 = List(",α", ",β", ",γ", ",δ", ",ε", ",ϛ", ",ζ", ",η", ",θ")
# From [[info:efaq#Colors%20on%20a%20TTY][Colors on a TTY]]
# Use colon separators.
screen-24bit|screen with 24-bit direct color mode,
use=screen-256color,
setb24=\E[48:2:%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%dm,
setf24=\E[38:2:%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%dm,
# Use semicolon separators.
screen-24bits|screen with 24-bit direct color mode,
use=screen-256color,
setb24=\E[48;2;%p1%{65536}%/%d;%p1%{256}%/%{255}%&%d;%p1%{255}%&%dm,
@fikovnik
fikovnik / r-build-gdb.sh
Created October 11, 2021 12:29
Build R for debugging
#!/bin/sh
export CXXFLAGS="-O0 -ggdb3"
export CPPFLAGS="-O0 -ggdb3"
export CFLAGS="-O0 -ggdb3"
export R_KEEP_PKG_SOURCE=yes
export CXX="g++"
./configure --with-blas --with-lapack --without-ICU --with-x \
--with-tcltk --without-aqua --with-recommended-packages \
@fikovnik
fikovnik / r-build.sh
Created October 11, 2021 12:41
Build R
#!/bin/sh
export CXXFLAGS="-O2 -ggdb3"
export CPPFLAGS="-O2 -ggdb3"
export CFLAGS="-O2 -ggdb3"
export R_KEEP_PKG_SOURCE=yes
export CXX="g++"
./configure --with-blas --with-lapack --without-ICU --with-x \
--with-tcltk --without-aqua --with-recommended-packages \
@fikovnik
fikovnik / tg2p.st
Created December 20, 2021 08:42 — forked from jdevoo/tg2p.st
Not so Terse Guide to Pharo
"**************************************************************************
* Allowable characters: *
* - a-z *
* - A-Z *
* - 0-9 *
* - .+/\*~<>@%|&? *
* - blank, tab, cr, ff, lf *
* *
* Variables: *
* - variables must be declared before use *
@fikovnik
fikovnik / tracer.c
Created February 5, 2024 14:48
Intercept syscalls of a child process using ptrace
#include <stdio.h>
#include <sys/ptrace.h>
#include <sys/reg.h>
#include <sys/wait.h>
#include <unistd.h>
int main() {
int status;
pid_t child_pid = fork();
@fikovnik
fikovnik / make-audiobook.sh
Created June 16, 2024 18:38
Create a m4b file from mp3 files with metadata and image cover (tailored for audioteka.cz)
#!/bin/bash -x
CATEGORY="audioteka"
function get_mp3_tag() {
local file="$1"
local tag="$2"
ffprobe -v error -show_entries format_tags="$tag" -of default=noprint_wrappers=1:nokey=1 "$file"
}