Skip to content

Instantly share code, notes, and snippets.


salotz salotz

View GitHub Profile
salotz / latency.txt
Created Apr 24, 2020 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
View latency.txt
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
salotz /
Created Apr 4, 2020 — forked from timss/
A combination of python-daemon and APScheduler
#!/usr/bin/env python
import apscheduler.scheduler
import daemon.runner
import os.path
import sys
import time
class Core():
def __init__(self):
salotz /
Created Jan 9, 2020
Clean numpy-only implementation of the Shimazaki-Shinimoto histogram binning method as a function.
def shimazaki_shinimoto_binning(x, min_bins, max_bins):
"""The Shimazaki-Shinimoto histogram binning algorithm for choosing an
optimal constant number of bins.
x : array of int or float
The data you want to bin
salotz /
Created Mar 20, 2019
CRIU as a interactive terminal session manager with disk persistence

First start an ipython session first printing out the PID.

bash -c "echo $$; exec ipython"

I also tried changing the name of the process so you can name them but it didn’t seem to work, although there is probably something you can do to be able to do this:

salotz /
Created Mar 1, 2019
Move a matplotlib Axes from one figure to another.
import matplotlib.pyplot as plt
def move_axes(ax, fig, subplot_spec=111):
"""Move an Axes object from a figure to a new pyplot managed Figure in
the specified subplot."""
# get a reference to the old figure context so we can release it
old_fig = ax.figure
# remove the Axes from it's original Figure context
salotz /
Created Oct 10, 2018 — forked from cube-drone/
Automation For The People

Automation for the People

Long ago, the first time I read "The Pragmatic Programmer", I read some advice that really stuck with me.

"Don't Use Manual Procedures".

This in the chapter on Ubiquitous Automation. To summarize, they want you to automate all the things.

The trouble was that I hadn't much of an idea how to actually go

salotz /
Created Jun 17, 2018 — forked from upbeta01/
Install Docker In Debian 9 (Stretch)
# -----------------------
# This is a script that installs docker-ce (Docker Community Edition) on Debian 9
# Inspired by
# -----------------------
# Pre-requesite
salotz / Abbreviate Journal Names in Bibtex Using the translation table from the Jabref program, finds and replaces all scientific journal names to their standardized abbreviated form. First argument is the file to be processed; outputs safely to 'abbreviated.bib'
View Abbreviate Journal Names in Bibtex
#!/usr/bin/env python
#-*- coding: utf-8 -*-
# Supporting Python 3
import sys, os, re
try: bibtexdb = open(sys.argv[1]).read()
except: print("Error: specify the file to be processed!")
if not os.path.isfile('journalList.txt'):
salotz /
Created Jun 20, 2017
Signing my github account from

Keybase proof

I hereby claim:

  • I am salotz on github.
  • I am salotz ( on keybase.
  • I have a public key ASB24_I5jo3wKU9_DxOuUnSpzWrQT5jpRAg5JbxVeI8I8wo

To claim this, I am signing this object:

salotz /
Created Oct 7, 2015
Matplotlib colormap utility functions: get_cmap, array_cmap, truncate_colormap, stack_colormap, band_colormap .
""" new colormaps from old: stack, truncate builtin cmaps / files / numpy arrays
What's a colormap or cmap in matplotlib ?
Mainly a bar or array of 256 colors, rgb or rgba values 0 .. 1,
used in
pl.imshow( a 2d numpy array, cmap=cmap, ... )
Cmaps can be indexed with () like
cmap( .25 ), cmap( [0, .25, .5] ), cmap( np.linspace( ... ))