Skip to content

Instantly share code, notes, and snippets.

View alexlib's full-sized avatar
:octocat:
Working

Alex Liberzon alexlib

:octocat:
Working
View GitHub Profile
@alexlib
alexlib / MFISH_colorCombination.ipynb
Created June 7, 2017 04:17 — forked from jeanpat/MFISH_colorCombination.ipynb
An ipython notebook showing how to combine five greyscaled images into one RGB MFISH image using scikit-image
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexlib
alexlib / randomvariate.py
Created March 20, 2017 10:27 — forked from rsnemmen/randomvariate.py
Rejection method for random number generation / Python
def randomvariate(pdf,n=1000,xmin=0,xmax=1):
"""
Rejection method for random number generation
===============================================
Uses the rejection method for generating random numbers derived from an arbitrary
probability distribution. For reference, see Bevington's book, page 84. Based on
rejection*.py.
Usage:
>>> randomvariate(P,N,xmin,xmax)
import numpy as np
import matplotlib as mpl
mpl.use('pgf')
def figsize(scale):
fig_width_pt = 469.755 # Get this from LaTeX using \the\textwidth
inches_per_pt = 1.0/72.27 # Convert pt to inch
golden_mean = (np.sqrt(5.0)-1.0)/2.0 # Aesthetic ratio (you could change this)
fig_width = fig_width_pt*inches_per_pt*scale # width in inches
fig_height = fig_width*golden_mean # height in inches
import numpy as np
import matplotlib as mpl
mpl.use('pgf')
def figsize(scale):
fig_width_pt = 469.755 # Get this from LaTeX using \the\textwidth
inches_per_pt = 1.0/72.27 # Convert pt to inch
golden_mean = (np.sqrt(5.0)-1.0)/2.0 # Aesthetic ratio (you could change this)
fig_width = fig_width_pt*inches_per_pt*scale # width in inches
fig_height = fig_width*golden_mean # height in inches
@alexlib
alexlib / heatEquation.py
Created December 6, 2016 19:53 — forked from mick001/heatEquation.py
Heat Equation: a Python implementation (part 1). Full article can be found at http://www.firsttimeprogrammer.blogspot.com/2015/07/the-heat-equation-python-implementation.html
import numpy as np
from numpy import pi
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig = plt.figure()
fig.set_dpi(100)
ax1 = fig.add_subplot(1,1,1)
#Diffusion constant
@alexlib
alexlib / git-annex-overview.md
Created October 23, 2016 14:13 — forked from jaymzcd/git-annex-overview.md
Quick overview of git-annex - quite liking it

Git Annex

git annex - this is a separate bit of software that sits "atop" git and lets you (in it's words):

allows managing files with git, without checking the file contents into git.

Say what!? It basically stores your directory contents in git via symlinks, so really you are just checking in a bunch of symlinks - not content. This keeps the repo very small.

@alexlib
alexlib / post-commit
Created October 3, 2016 17:10 — forked from jobovy/post-commit
Modified version of Andy Casey's (@andycasey) post-commit hook to run latexdiff between different revisions of a latex draft (see http://astrowizici.st/blog/2013/10/04/publishing-with-git); works on Macs and when the paper is in a sub-directory of the main git repository.
#!/bin/sh
# Post-commit hook for revision-awsm-ness
function gettempfilename()
{
tempfilename=$1-$RANDOM$RANDOM.tex
if [ -e $tempfilename ]
then
tempfilename=$(gettempfilename)
@alexlib
alexlib / peakdet.m
Created September 17, 2016 17:05 — forked from endolith/peakdet.m
Peak detection in Python
function [maxtab, mintab]=peakdet(v, delta, x)
%PEAKDET Detect peaks in a vector
% [MAXTAB, MINTAB] = PEAKDET(V, DELTA) finds the local
% maxima and minima ("peaks") in the vector V.
% MAXTAB and MINTAB consists of two columns. Column 1
% contains indices in V, and column 2 the found values.
%
% With [MAXTAB, MINTAB] = PEAKDET(V, DELTA, X) the indices
% in MAXTAB and MINTAB are replaced with the corresponding
% X-values.
@alexlib
alexlib / build_liboptv_openptv-python.sh
Created August 31, 2016 14:02 — forked from anonymous/build_liboptv_openptv-python.sh
Build shell script for the complete installation from the source of the liboptv and openptv-python
git clone git://github.com/OpenPTV/openptv.git
cd openptv/liboptv
mkdir build && cd build
cmake ../
make
make verify
sudo make install
cd ../../py_bind
python setup.py build_ext --inplace -I/usr/local/include -L/usr/local/lib
@alexlib
alexlib / cython_tricks.md
Created August 30, 2016 21:44 — forked from ctokheim/cython_tricks.md
cython tricks

Cython

Cython has two major benefits:

  1. Making python code faster, particularly things that can't be done in scipy/numpy
  2. Wrapping/interfacing with C/C++ code

Cython gains most of it's benefit from statically typing arguments. However, statically typing is not required, in fact, regular python code is valid cython (but don't expect much of a speed up). By incrementally adding more type information, the code can speed up by several factors. This gist just provides a very basic usage of cython.