Skip to content

Instantly share code, notes, and snippets.

@salotz
salotz / colormaputil.py
Created October 7, 2015 01:08
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, ... )
pl.colorbar()
Cmaps can be indexed with () like
cmap( .25 ), cmap( [0, .25, .5] ), cmap( np.linspace( ... ))
@salotz
salotz / keybase.md
Created June 20, 2017 03:33
Signing my github account from keybase.io

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 / Abbreviate Journal Names in Bibtex Database.py
Created December 19, 2017 22:08 — forked from FilipDominec/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'
#!/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 / install-docker-deb9.sh
Created June 17, 2018 18:28 — forked from upbeta01/install-docker-deb9.sh
Install Docker In Debian 9 (Stretch)
#!/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 / automation.md
Created October 10, 2018 06:43 — forked from cube-drone/automation.md
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
salotz / move_axes.py
Created March 1, 2019 20:22
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
salotz / criu_session_manager.org
Created March 20, 2019 21:20
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
salotz / shimazaki_shinimoto_binning.py
Created January 9, 2020 18:16
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.
Parameters
----------
x : array of int or float
The data you want to bin
@salotz
salotz / python-daemon_apscheduler.py
Created April 4, 2020 04:50 — forked from timss/python-daemon_apscheduler.py
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
salotz / latency.txt
Created April 24, 2020 15:31 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
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