Skip to content

Instantly share code, notes, and snippets.

@sbebo
sbebo / rm_author.sh
Created Sep 5, 2017
Remove all git commits from history by given author
View rm_author.sh
skip_commit()
{
shift;
while [ -n "$1" ];
do
shift;
map "$1";
shift;
done;
}
@sbebo
sbebo / rm_files.sh
Last active Sep 5, 2017
Remove files and/or subdirs from all git history
View rm_files.sh
git filter-branch -f --index-filter "git rm -r --cached --ignore-unmatch file1 file2 dir1 dir2" --prune-empty
View livemap.js
// 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%"},
];
@sbebo
sbebo / fork_subdir.sh
Last active Oct 11, 2019
Create new repo from subdirectory
View fork_subdir.sh
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
View gist:ff653eb60b3af9acb13e
+ 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
View gist:e5348894c6c78db5d8c5
#variables
:'<,'>s/@defVar(m, /var /g
:'<,'>s/)/;/g
:'<,'>s/\[/{/g
:'<,'>s/\]/}/g
#contraints
:'<,'>s/@addConstraint(m, /subject to /g
:'<,'>s/)\n/;\r/g
@sbebo
sbebo / gist:07bff0f318388c0a7452
Created Jun 16, 2015
Install from pypi with conda
View gist:07bff0f318388c0a7452
conda skeleton pypi #package#
conda build #package#
conda install --use-local #package#
View gist:dae0fe67df11d91ef7cf
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.
View lp.jl
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))
@sbebo
sbebo / gist:2311b6bd279d5e3ef412
Created Sep 15, 2014
Move one file (with history) from one git repo to another
View gist:2311b6bd279d5e3ef412
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
You can’t perform that action at this time.