This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,:] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 | |
## |
OlderNewer