Skip to content

Instantly share code, notes, and snippets.

bibexport -o short.bib paper.aux
#create bib file with only cited references
# get names of files in last commit, remove name of folder, copy to dropbox folder (for git-agnostic)
cp $(git show --name-only | grep pamf-workingcopy | sed 's/pamf-workingcopy\///g') ~/Dropbox/journalworkingcopy
for FILE in 50_p_*
do
sed -i 0,/52/"s/52 ..../52 $(( $( wc -l < $FILE ) -53 ))/" $FILE
done
#scan until first occurence of 52 http://stackoverflow.com/a/9453461/812817
#replace 52 .... with number of lines in FI minus 53
@leotac
leotac / gist:f506549ac8e9817b5f69
Last active August 29, 2015 14:01
git snippets
#stop tracking file
git update-index --assume-unchanged file.mod
git ls-files -v | grep "^[[:lower:]]"
# alias in git/config file:
#[alias]
# ignore = !git update-index --assume-unchanged
# unignore = !git update-index --no-assume-unchanged
# ignored = !git ls-files -v | grep "^[[:lower:]]"
@leotac
leotac / gist:e874b85d2b0e90b37da1
Created May 15, 2014 10:04
useful shell (zsh) snippets
#pretty print of tab-separated table ("less -S": do not wrap lines)
column -t -s $'\t' -n < table | less -S
sed -i "s/cap/c/g" *dat
#-C: copy -n: try, but do not execute command. -W: simplified glob
zmv -C -n -W 'comm*' '#comm*'
#more complex stuff (standard syntax):
zmv 'commodities_(*)_1.dat' '#commodities_$1_1.dat'
@leotac
leotac / gist:9760509
Created March 25, 2014 12:08
build Couenne with Cplex link
go build
../configure -C --with-cplex-lib="/opt/ibm/ibm/cplex/lib/x86-64_sles10_4.1/static_pic/libcplex.a -lpthread -lm" --with-cplex-incdir=/opt/ibm/ibm/cplex/include/ilcplex
make
make install
@leotac
leotac / install_ruby.sh
Last active July 18, 2020 23:18
Install Ruby (with zsh)
#Install rbenv and add it to .zshrc
cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
source ~/.zshrc
rbenv install 1.9.3-p0
rbenv local 1.9.3-p0
@leotac
leotac / gist:8376176
Last active July 13, 2018 01:39
Installing Octopress on a Github project page
Prerequisites: git and ruby (ruby --version must be >= 1.9.3)
#git clone git://github.com/imathis/octopress.git octopress
#cd octopress
git clone <my-blog-source>
cd blog-source
gem install bundler
rbenv rehash # If you use rbenv, rehash to be able to run the bundle command
@leotac
leotac / gist:7341211
Created November 6, 2013 18:14
Bibtex find and replace
#Find all occurrences of:
# - multiple lines -> \_.*
# - starting with ### -> ^###
# - not greedily (first match) -> use "\{-\}" instead of "*" (Valid in Vim! Generally, you would use ".*?" for non-greedy behavior)
# - ending with a @
# - and replace with a @
:%s/^###\_.\{-\}@/@/g
@leotac
leotac / gist:7339850
Created November 6, 2013 16:58
Open terminal in current nautilus window, Ubuntu 12.04/64 and add shortcut
sudo apt-get install nautilus-open-terminal
cd ~/.gnome2/accels
vi nautilus
# Uncomment (remove semicolon) and add shortcut
(gtk_accel_path "<Actions>/ExtensionsMenuGroup/NautilusOpenTerminal::open_terminal" "<Alt>n")