Skip to content

Instantly share code, notes, and snippets.

@leotac
leotac / rm_author.sh
Created September 5, 2017 10:03
Remove all git commits from history by given author
skip_commit()
{
shift;
while [ -n "$1" ];
do
shift;
map "$1";
shift;
done;
}
@leotac
leotac / rm_files.sh
Last active September 5, 2017 10:05
Remove files and/or subdirs from all git history
git filter-branch -f --index-filter "git rm -r --cached --ignore-unmatch file1 file2 dir1 dir2" --prune-empty
// this can be loaded via browser console with
// var script=document.createElement('script'); script.type='text/javascript'; script.src='http://quicksort.altervista.org/SnackOverflow/js/SnackOverflowLiveMap.js'; document.head.appendChild(script);
var vehicleName;
var vehicleStats = [
{last: "10/08/2016 - 80€", level: "12%"},
{last: "13/08/2016 - 65€", level: "70%"},
{last: "14/08/2016 - 76€", level: "85%"},
];
@leotac
leotac / fork_subdir.sh
Last active October 11, 2019 20:15
Create new repo from subdirectory
mkdir subdir-fork
cd subdir-fork
git clone git@github.com:sbebo/REPO.git
git filter-branch --prune-empty --subdirectory-filter <SUBFOLDER> master
git remote -v
git remote rm origin
git remote add origin git@github.com:sbebo/<NEWREPO>.git
@leotac
leotac / gist:ff653eb60b3af9acb13e
Last active August 29, 2015 14:24
Mac tricks/quirks.
+ iterm: VIM or SSH scrollback buffer is preserved? --> Uncheck "Save lines to scrollback in alternate screen mode"
+ ipython/jupyter: if installed via anaconda, it is not a "framework", so the osx backend in matplotlib works badly (keyboard highlight stays on the notebook). it's better to use qt, at least it works.
+ SCIP/SCIP.jl: to have a .dylib, just rename the .so file to .dylib
+ slow text cursor (repeat interval): system preferences -> keyboard -> key repeat
@leotac
leotac / gist:e5348894c6c78db5d8c5
Created June 24, 2015 19:38
from JuMP to AMPL
#variables
:'<,'>s/@defVar(m, /var /g
:'<,'>s/)/;/g
:'<,'>s/\[/{/g
:'<,'>s/\]/}/g
#contraints
:'<,'>s/@addConstraint(m, /subject to /g
:'<,'>s/)\n/;\r/g
@leotac
leotac / gist:07bff0f318388c0a7452
Created June 16, 2015 18:10
Install from pypi with conda
conda skeleton pypi #package#
conda build #package#
conda install --use-local #package#
ssh -N -f -L localhost:9999:localhost:8888 username@remot-host.xxx.it
#tunnel via port 9999 to port 8888 on remote host. useful, e.g., for ipython notebooks.
@leotac
leotac / lp.jl
Last active August 29, 2015 14:07
module LPTest
using JuMP
using CPLEX, Gurobi
function gen_data(M, N)
srand(3)
println("Generating data..")
p = max(randn(N),0)
A = max(randn(M,N),0)
b = abs(randn(M))
@leotac
leotac / gist:2311b6bd279d5e3ef412
Created September 15, 2014 20:48
Move one file (with history) from one git repo to another
mkdir /tmp/mergepatchs
cd ~/repo/org
export reposrc=myfile.c #or mydir
git format-patch -o /tmp/mergepatchs $(git log $reposrc|grep ^commit|tail -1|awk '{print $2}')^..HEAD $reposrc
cd ~/repo/dest
git am /tmp/mergepatchs/*.patch