Skip to content

Instantly share code, notes, and snippets.

@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))
@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 / 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 / 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 / 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
moved to https://github.com/scienceopen/fortran2015-examples
@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
@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 / testlowtran.txt
Created April 14, 2016 05:18
lowtran testlowtran output
./testlowtran
for wavelengths [nm]: 1200.48022 1132.50281 1071.81128 1017.29407 968.054260 923.361084 882.612549 845.308533 811.030029 779.423218 750.187561 723.065796 697.836670 674.308838 652.315735 631.711975 612.369873 594.177063 577.034058 560.852478 545.553772 531.067444 517.330566 504.286407 491.883911 480.076813 468.823242 458.085205 447.828033 438.020142 428.632690 419.639099 411.015198 402.738617 394.788788 387.146729 379.794922 372.717102 365.898285 359.324463 352.982697 346.860901 340.947845 335.232971 329.706543 324.359375 319.182892 314.169006 309.310242 304.599457 300.029999
transmission: 0.934353650 0.653181911 0.980576396 0.988120317 0.922352910 0.928113937 0
@meresmclr
meresmclr / gist:b16a0a1d91a3973c1658
Created October 30, 2015 03:37
Edison dmesg ready for flashing with dfu-util
new high-speed USB device number 42 using xhci_hcd
New USB device found, idVendor=8086, idProduct=e005
New USB device strings: Mfr=2, Product=1, SerialNumber=3
Product: MERRIFIELD
Manufacturer: INTEL
SerialNumber: XXX
USB disconnect, device number 42
new high-speed USB device number 43 using xhci_hcd
New USB device found, idVendor=8086, idProduct=e005
New USB device strings: Mfr=2, Product=1, SerialNumber=3