Skip to content

Instantly share code, notes, and snippets.

View julienr's full-sized avatar

Julien Rebetez julienr

View GitHub Profile
"""
This is a local proxy to intercept GDAL vsigs request (when storing data
on google cloud storage) and inject error codes to exercise the logging
codepath.
Usage:
$ python vsi_proxy.py
$ CPL_GS_ENDPOINT=http://localhost:9999/ gdal_translate -srcwin 5000 5000 2000 2000 /vsigs/mybucketfile.tif out.tit
"""
@julienr
julienr / build_opencv_android.sh
Created September 18, 2014 21:52
OpenCV Android custom build multiple ABI script
#!/bin/bash
# Script to build opencv for android for multiple architectures
# Must be run from a directory that contains an 'opencv' directory with the
# opencv sources (from git or a tarball)
# Final Build to opencv/build/install
export ANDROID_NDK=$NDK
CMAKE_ARGS="-DNATIVE_API_LEVEL=14 \
-DBUILD_ANDROID_EXAMPLES=0 \
-DBUILD_ANDROID_PACKAGE=0 \
@julienr
julienr / fixing_python_path.rst
Created March 19, 2016 10:17
fixing python path
@julienr
julienr / sklearn_classif_report_to_latex.py
Created October 26, 2015 16:04
Parse and convert scikit-learn classification_report to latex
"""
Code to parse sklearn classification_report
"""
##
import sys
import collections
##
def parse_classification_report(clfreport):
"""
Parse a sklearn classification report into a dict keyed by class name
@julienr
julienr / tvtk_image_overlay.py
Last active April 23, 2018 04:02
TVTK 2D image overlay over 3D plot (python, mayavi.mlab and tvtk)
"""
Example of overlaying an image on a 3D view with tvtk
"""
##
import mayavi.mlab as mlab
import numpy as np
import pylab as pl
import vtk
from tvtk.api import tvtk
##
@julienr
julienr / Makefile
Last active February 8, 2018 16:08
OSmesa on ubuntu 14.04
OSMESA_PATH=/opt/osmesa_llvmpipe
LDFLAGS+=`PKG_CONFIG_PATH=$(OSMESA_PATH)/lib/pkgconfig/ pkg-config --libs osmesa`
CFLAGS+=`PKG_CONFIG_PATH=$(OSMESA_PATH)/lib/pkgconfig/ pkg-config --cflags osmesa`
all:
clang -o osmesa_test osmesa_test.cc $(LDFLAGS) $(CFLAGS) -lGLU
run:
LD_LIBRARY_PATH=$(OSMESA_PATH)/lib ./osmesa_test
@julienr
julienr / embedded_notebook_server
Last active March 14, 2016 09:22
Ipython notebook save.js test output
# This is running with python -m notebook.jstest notebook/save.js
Test group: notebook/save.js
Test file: notebook/tests/notebook/save.js 
step complete undefined
step complete undefined
remote message caught: Object {
"readyState": 4,
"responseText": "{\"reason\": null, \"message\": \"No such file or directory: has#hash and space and unic\\u00f8\\u2202e.ipynb\"}",
@julienr
julienr / pca_svds.py
Created December 23, 2013 12:31
PCA using scipy.sparse.linalg.svds (economy SVD decomposition)
def pca(X, npc):
n_samples, n_features = X.shape
Xmean = np.mean(X, axis=0)
U, s, Vt = scipy.sparse.linalg.svds(X - Xmean, k=npc)
order = np.argsort(-s) # sort s in descending order
# svds returns U, s, Vt sorder in ascending order. We want descending
s = s[order]
W = Vt[order,:]
// g++ -o eigen_test eigen_sparse_solver.cc -I/home/julien/slash/include/eigen3 -I/usr/include/suitesparse -lumfpack -lamd -lblas
#include <cstdlib>
#include <cassert>
#include <Eigen/Eigen>
#include <Eigen/UmfPackSupport>
#include <vector>
#include <iostream>
using namespace Eigen;
using namespace std;
@julienr
julienr / cmds.md
Last active November 9, 2015 09:55
jupyter-notebook commands

Useful commands to work on jupyter-notebook

Note that test are run on built js files, so you should run python setup.py build everytime you modify the notebook's js files.

Running a single js test

cd notebook/tests

python -m notebook.jstest notebook/attachments.js | less