Skip to content

Instantly share code, notes, and snippets.

View bermanmaxim's full-sized avatar

Maxim Berman bermanmaxim

View GitHub Profile
@bermanmaxim
bermanmaxim / tmux_local_install.sh
Created May 14, 2017 12:20 — forked from ryin/tmux_local_install.sh
bash script for installing tmux without root access
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=1.8
CC=gcc-4.9 CXX=g++-4.9 luarocks install cutorch
@bermanmaxim
bermanmaxim / .block
Created March 27, 2016 21:36 — forked from mbostock/.block
Epicyclic Gearing
license: gpl-3.0
@bermanmaxim
bermanmaxim / save_jld.m
Created October 16, 2015 11:51
Using jlcall.jl to save Matlab variables to Julia JLD In Matlab
function save_jld( file, varargin )
Jl.eval('using JLD')
arguments = cell(2*length(varargin), 1);
for ii = 1:length(varargin)
arguments{2*(ii-1) + 1} = inputname(1 + ii);
arguments{2*(ii-1) + 2} = varargin{ii};
end
using PyCall
import Base.next
import Base: sigatomic_begin, sigatomic_end
#overwrite 'next' definition in PyCall
function next(po::PyObject, s)
sigatomic_begin()
try
nxt = PyObject(ccall((PyCall.@pysym :PyIter_Next), PyPtr, (PyPtr,), s[2]))
return (s[1], (nxt, s[2])) # No conversion to PyAny
@bermanmaxim
bermanmaxim / external_model.py
Created July 2, 2015 22:57
Wrapping around Python PyStruct: structured SVM in Julia
from pystruct.models.base import StructuredModel
import numpy as np
import types
class ExternalModel(StructuredModel):
"""Interface definition for Structured Learners.
This class defines what is necessary to use the structured svm.
You have to implement at least joint_feature and inference.
"""
def __init__(self, size_joint_feature=None, joint_feature=None,
@bermanmaxim
bermanmaxim / gist:d4ff86174fffcf65ec3f
Created July 2, 2015 17:35
Bounding a Python method to an instance during its initialization
import types
class Test(object):
def __init__(self, method):
self.fruit = "apple"
self.method = types.MethodType(method, self)
def method(self):
print self.fruit
@bermanmaxim
bermanmaxim / fr_fragment_xkb
Created May 31, 2015 15:31
Logitech K760 French keyboard layout for XKB configuration file
// Maxim : copied from macintosh_vndr/fr and modified to suit Logitech K760 french keyboard layout
// put in /usr/share/X11/xkb/symbols/fr
// select with setxkbmap -device 14 -layout fr -variant ipad
// Marc.Shapiro@inria.fr 19-sep-1998
// modifications : Etienne Herlent <eherlent@linux-france.org> june 2000
// adapted to the new input layer :
// Martin Costabel <costabel@wanadoo.fr> 3-jan-2001
// adapted for Latin9 alphabet (ISO-8859-15):
// Etienne Herlent <eherlent@linux-france.org> march 2005