Skip to content

Instantly share code, notes, and snippets.

@numpde
numpde / sorcery_param_logger.py
Last active June 20, 2021 19:51
Parameter logger with sorcery
# RA, 2021-06-20
import executing
import inspect
import sorcery
class Memo(dict):
"""
Example:
@numpde
numpde / hashing.py
Created June 17, 2021 20:19
Hash stuff
# SOURCE: https://home.cc.umanitoba.ca/~psgendb/doc/spades/joblib3/hashing.py
"""
Fast cryptographic hash of Python objects, with a special case for fast
hashing of numpy arrays.
"""
# Author: Gael Varoquaux <gael dot varoquaux at normalesup dot org>
# Copyright (c) 2009 Gael Varoquaux
# License: BSD Style, 3 clauses.
@numpde
numpde / model_to_html.m
Created May 22, 2021 11:41
Export SimBiology model as HTML
% model_to_html(m)
% Usage:
%
% fid = fopen('model.html', 'wt');
% fprintf(fid, evalc("model_to_html(sbioloadproject('model.sbproj').m1)"));
% fclose(fid);
%
% RA, 2021-05-22, The Unlicense
function model_to_html(m)
@numpde
numpde / cleanup.sh
Last active March 14, 2021 21:11
Clean Ubuntu: logs, trash, snaps, etc.
#!/bin/bash
# From
# https://itsfoss.com/free-up-space-ubuntu-linux/
# APT
sudo apt-get autoremove
sudo apt-get clean
@numpde
numpde / CompressMP4
Last active October 6, 2021 08:26
Nautilus script: compress mp4 file
#!/bin/bash
function x {
mv "$1" "$1.original.mp4"
ffmpeg -i "$1.original.mp4" -vcodec libx264 -crf 40 "$1" -vf scale=640:-1 -preset veryslow \
&& mv "$1.original.mp4" "$1.done.mp4"
notify-send "$1 compression done."
}
# https://stackoverflow.com/questions/11003418/calling-shell-functions-with-xargs
@numpde
numpde / Terminal
Last active November 29, 2020 18:10
Nautilus script: open terminal
#!/bin/bash
gnome-terminal
# Put in ~/.local/share/nautilus/scripts/
@numpde
numpde / pdf_trick_2x1.sh
Last active November 3, 2020 12:10
Make PDF 2x1 for printing
# Make PDF 2x1 for printing
pdftk $FILE cat 1-end output - | pdfjam --nup 2x1 --landscape --outfile /dev/stdout | pdfjam --angle=90 /dev/stdin --outfile /dev/stdout | okular -
@numpde
numpde / fdr.py
Last active November 9, 2020 11:32
Visualization of the FDR and estimates by Benjamini-Hochberg and Storey-Tibshirani
# RA, 2020-10-16
"""
Visualization of the FDR and estimates by Benjamini-Hochberg and Storey-Tibshirani.
[1] Benjamini Y and Hochberg Y.
Controlling the false discovery rate: a practical
and powerful approach to multiple testing.
J R Statist Soc B, 1995.
@numpde
numpde / 20201002_simbio_first.m
Last active October 2, 2020 15:06
SimBiology first script -- modified to index names of species
% 2020-HS Intro Bio Computers
% SimBiology first script -- modified to index names of species
% The trick
index_of = containers.Map();
for i = 1 : length(BioComp_1.Species)
index_of(BioComp_1.Species(i).Name) = i;
end
clear AB;
@numpde
numpde / view_paper_to_print.sh
Created September 24, 2020 14:31
Display a PDF file in 2x1 portrait format for printing
# Display a PDF file in 2x1 portrait format for printing
pdfjam --nup 2x1 --landscape "file.pdf" --outfile /dev/stdout | \
pdfjam --angle=90 /dev/stdin --outfile /dev/stdout | \
okular -