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 / fixing_python_path.rst
Created March 19, 2016 10:17
fixing python path
@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 / 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

@julienr
julienr / vispy_mesh.py
Created October 29, 2015 09:13
vispy_mesh
##
import sys
import numpy as np
from vispy import scene
from vispy.color import Color
from vispy import gloo
from vispy.scene.cameras import TurntableCamera
import vispy.io
import vispy.geometry
import ply
@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 / timestamp.py
Created September 17, 2015 11:21
Python timestamp
def date_from_timestamp_ms(timestamp_ms):
date = datetime.utcfromtimestamp(timestamp_ms / 1000.0)
return date
def format_date(timestamp_ms, sep=None):
if sep is None:
sep = '_'
date = date_from_timestamp_ms(timestamp_ms)
return date.strftime('%Y{0}%m{0}%d'.format(sep))
@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 / android_png.cc
Last active August 29, 2015 14:27
libpng-android loading from assets
#include "android_png.h"
#include <android/asset_manager.h>
#include <png.h>
struct PNGImageData : public ImageData {
PNGImageData(png_byte* pixels, int width, int height) {
this->img_width = width;
this->img_height = height;
this->pixels = (uint8_t*)pixels;
@julienr
julienr / mkdirp.py
Created June 8, 2015 09:59
mkdir -p in python
import os
import errno
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST:
pass
else: raise