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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexlib
alexlib / squeezing.tex
Created May 10, 2016 18:13 — forked from chfritz/squeezing.tex
A tex file full of tricks for squeezing a latex document. Clearly you should avoid using these tricks. But when the deadline is near and you see no other way, you can use it to quickly change the formatting slightly to get more space. Just comment in some of the length changes or add other for the described sizes.
%% /** ---------------------------------------------------------
%% a file full of squeezing options
%% -- which you should try to avoid
%% -------------------------------------------------------------
%%
%% from:
%% http://www.eng.cam.ac.uk/help/tpl/textprocessing/squeeze.html
%% ---------------------------------------------------------- */
%% * Page Layout
%% o \columnsep: gap between columns
@alexlib
alexlib / traitsui_mpl_qt.py
Created June 4, 2016 15:04 — forked from pierre-haessig/traitsui_mpl_qt.py
Matplotlib integration with Enthought's traitsui, using Qt toolkit (instead of wx)
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Pierre Haessig — March 2014
"""
Qt adaptation of Gael Varoquaux's tutorial to integrate Matplotlib
http://docs.enthought.com/traitsui/tutorials/traits_ui_scientific_app.html#extending-traitsui-adding-a-matplotlib-figure-to-our-application
based on Qt-based code shared by Didrik Pinte, May 2012
http://markmail.org/message/z3hnoqruk56g2bje
@alexlib
alexlib / gist:58a4488f3d3c069a930aa71732672f6b
Created June 4, 2016 15:22 — forked from aestrivex/gist:3a8608f3f26faa9e8817
traitsui list editor working with both qt backends on 4.4
import os
from traits.trait_base import ETSConfig
_tk = ETSConfig.toolkit
from functools import partial
from traits.api import (Property, Instance, Bool, Str, BaseTraitHandler,
Range)
from traitsui.api import CustomEditor
if _tk in ('null','',None):
@alexlib
alexlib / nbstripout
Created June 11, 2016 18:56 — forked from minrk/nbstripout
git pre-commit hook for stripping output from IPython notebooks
#!/usr/bin/env python
"""strip outputs from an IPython Notebook
Opens a notebook, strips its output, and writes the outputless version to the original file.
Useful mainly as a git filter or pre-commit hook for users who don't want to track output in VCS.
This does mostly the same thing as the `Clear All Output` command in the notebook UI.
LICENSE: Public Domain
@alexlib
alexlib / Julia_Python_perf.ipynb
Created August 12, 2016 21:11 — forked from jfpuget/Julia_Python_perf.ipynb
An exercise in Python optimization: make Python benchmarks as fast, if not faster, than Julia.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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.

@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 / 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 / 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)