Skip to content

Instantly share code, notes, and snippets.

@meresmclr
meresmclr / myprog.c
Created April 15, 2016 02:41
Example of writing and reading file with HDF5 in C. Based on https://scivision.co/linking-libhdf5-dev-with-cmake/
#include "hdf5.h"
#define FILE "dset.h5"
int main() {
hid_t file_id, dataset_id,dataspace_id; /* identifiers */
herr_t status;
int i, j, dset_data[4][6], read_data[4][6];
hsize_t dims[2];
@meresmclr
meresmclr / setup_gnuparallel.sh
Last active August 29, 2024 23:10
Install GNU Parallel on any system including Cygwin
#!/bin/bash
# useful for platforms such as Cygwin that don't currently have GNU Parallel in their repo.
# prerequisite: make
(
wd=$(mktemp -d)
wget -nc -P $wd ftp://ftp.gnu.org/gnu/parallel/parallel-latest.tar.bz2
cd $wd
moved to https://github.com/scienceopen/fortran2015-examples
@meresmclr
meresmclr / matlab Python N-D array passing.m
Last active June 26, 2016 15:34
Matlab Python workaround for N-D array passing. Matlab R2014b-R2016a
% 200x320 image is now in variable X
load clown
% I ravel X to a row vector, and unravel with Numpy
Xp = py.numpy.reshape(X(:)',size(X),'F');
% Apply Gaussian filter to image
Yp = py.skimage.filters.gaussian(Xp,3);
% now let's come back to Matlab
@meresmclr
meresmclr / opencv3.cmake
Created July 8, 2016 04:35
OpenCV 3 simple CMake for Linux and Cygwin
cmake -DBUILD_TIFF=ON -DBUILD_opencv_java=OFF -DWITH_CUDA=OFF -DENABLE_AVX=OFF -DWITH_OPENGL=OFF \
-DWITH_OPENCL=OFF -DWITH_IPP=OFF -DWITH_TBB=OFF -DWITH_EIGEN=OFF -DWITH_V4L=OFF -DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
-DPYTHON3_EXECUTABLE=$(which python3) \
-DPYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-DPYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") ..
@meresmclr
meresmclr / startvnc.sh
Last active August 26, 2016 18:26
stop/start VNC desktop
#!/bin/sh
# run on remote PC, connect with runvnc.sh
vncserver -kill :1
vncserver :1 -geometry 1200x800 -localhost
@meresmclr
meresmclr / runvnc.sh
Created August 26, 2016 18:26
on laptop connect to remote PC where have already run startvnc.sh
#!/bin/sh
ssh -f -L 5901:localhost:5901 username@address sleep 1;
ssvncviewer localhost::5901
@meresmclr
meresmclr / matplotlib_integer_axes.py
Created August 30, 2016 16:36
make matplotlib label axes with integers
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
#...
ax = plt.figure().gca()
#...
ax.xaxis.set_major_locator(MaxNLocator(integer=True))
#!/bin/sh
#
# finds N biggest directories.
# Alternative is "ncdu" a graphical biggest file program
\du -hd1 $1 | sort -h | head -n 8
@meresmclr
meresmclr / matlab_animation_example.m
Last active September 2, 2016 05:10
example animated movie in Matlab or Octave
%% create data, 25 frames of 512x512 pixels
data = rand(512,512,25);
%% create blank image
img = imagesc(rand(512));
ht = title(''); % to show frame number
%% for loop to play "movie"
for i = 1:25
set(img,'cdata',data(:,:,i)) % update latest frame