Skip to content

Instantly share code, notes, and snippets.

Avatar

salotz salotz

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

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
salotz / move_axes.py
Created Mar 1, 2019
Move a matplotlib Axes from one figure to another.
View move_axes.py
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
salotz / automation.md
Created Oct 10, 2018 — forked from cube-drone/automation.md
Automation For The People
View automation.md

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
salotz / install-docker-deb9.sh
Created Jun 17, 2018 — forked from upbeta01/install-docker-deb9.sh
Install Docker In Debian 9 (Stretch)
View install-docker-deb9.sh
#!/bin/bash
#
# -----------------------
#
# This is a script that installs docker-ce (Docker Community Edition) on Debian 9
# Inspired by https://gist.github.com/frgomes/a6f889583860f5b330c06c8b46fa0f42
#
# -----------------------
# Pre-requesite
@salotz
salotz / Abbreviate Journal Names in Bibtex Database.py 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 Database.py
#!/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
salotz / keybase.md
Created Jun 20, 2017
Signing my github account from keybase.io
View keybase.md

Keybase proof

I hereby claim:

  • I am salotz on github.
  • I am salotz (https://keybase.io/salotz) on keybase.
  • I have a public key ASB24_I5jo3wKU9_DxOuUnSpzWrQT5jpRAg5JbxVeI8I8wo

To claim this, I am signing this object:

@salotz
salotz / colormaputil.py
Created Oct 7, 2015
Matplotlib colormap utility functions: get_cmap, array_cmap, truncate_colormap, stack_colormap, band_colormap .
View colormaputil.py
#...............................................................................
""" 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, ... )
pl.colorbar()
Cmaps can be indexed with () like
cmap( .25 ), cmap( [0, .25, .5] ), cmap( np.linspace( ... ))