Skip to content

Instantly share code, notes, and snippets.

View julienr's full-sized avatar

Julien Rebetez julienr

View GitHub Profile
@julienr
julienr / bisect.log
Last active August 29, 2015 13:59
tmux set-buffer crash
git bisect start
# bad: [57c514d2f85f9d1c81601bae32131f1cd2948422] Remove <vis.h>; not used on Linux.
git bisect bad 57c514d2f85f9d1c81601bae32131f1cd2948422
# bad: [1b083aa0fd2d8ac000504488135bf58e35c3361e] Update CHANGES and configure.ac for 1.8 release.
git bisect bad 1b083aa0fd2d8ac000504488135bf58e35c3361e
# good: [2b5c3fc49f9f96dd84fb26f75be7d634ea4c282c] Update NOTES, CHANGES, configure.ac for 1.7 release
git bisect good 2b5c3fc49f9f96dd84fb26f75be7d634ea4c282c
# good: [357da035b9d052b4cba8db806c6237272ade6673] Merge send-prefix into send-keys.
git bisect good 357da035b9d052b4cba8db806c6237272ade6673
# skip: [599dd2a56009300df999c54c73aa9e83268809e8] Create a new context when copying instead of using the input context. The input context may not exist yet. Fixes crash when copying from config file errors.
@julienr
julienr / convert_timestamp.py
Created April 28, 2014 12:42
convert_timestamp.py
"""Convert UTC timestamp to custom timezone"""
import datetime
import pytz
import sys
assert len(sys.argv) > 1, 'Usage : convert_timestamp <timestamp>'
utc = pytz.utc
zurich = pytz.timezone('Europe/Zurich')
utc_dt = datetime.datetime.fromtimestamp(float(sys.argv[1]), tz=utc)
dt = utc_dt.astimezone(zurich)
@julienr
julienr / OpenIterm2.app
Created June 4, 2014 20:44
Open iTerm2 here in OSX
-- Automator AppleScript to add a finder toolbar icon to "open iterm2 window here"
-- * Create an Automator application
-- * Add this script as Utilities/Run AppleScript
-- * Drag the application to the finder toolbar with command pressed
(* http://peterdowns.com/posts/open-iterm-finder-service.html *)
on run {input, parameters}
tell application "Finder"
set dir_path to POSIX path of (folder of the front window as alias)
end tell
CD_to(dir_path)
@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
@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 / bashrc_prompt_shortener
Created April 19, 2011 21:15
bashrc prompt pwd shortener
# prompt shortener : http://stackoverflow.com/questions/3497885/code-challenge-bash-prompt-path-shortener
_dir_chomp () {
local IFS=/ c=1 n d
local p=(${1/#$HOME/\~}) r=${p[*]}
local s=${#r}
while ((s>$2&&c<${#p[*]}-1))
do
d=${p[c]}
n=1;[[ $d = .* ]]&&n=2
((s-=${#d}-n))
#!/usr/bin/python3
# This is a simple pre-processor for a boustrophedonic dialect of the C
# programming language :
# http://en.wikipedia.org/wiki/Boustrophedonic
#
# A sample program is :
# #include <stdio.h>
# { )( niam tni
# printf("Hello dlrow\n");
@julienr
julienr / .Xresources
Created April 4, 2012 09:09
.Xresources for urxvt
URxvt.depth: 32
URxvt.scrollBar: off
URxvt.font: -*-terminus-medium-r-normal-*-*-*-*-*-*-*-*-*
URxvt.keysym.Control-Up: \033[1;5A
URxvt.keysym.Control-Down: \033[1;5B
URxvt.keysym.Control-Left: \033[1;5D
URxvt.keysym.Control-Right: \033[1;5C
URxvt.background: #300A24
URxvt.foreground: #ffffff
@julienr
julienr / npycat
Last active October 13, 2015 16:18
npycat : cat-like tool for numpy .npy files
#!/home/julien/tm/v2/venv/bin/python
"""
Cat-like utility for .npy files
"""
import numpy as np
import sys
def print_arr(a):
print 'dtype : ', a.dtype
print 'shape : ', a.shape
@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