Skip to content

Instantly share code, notes, and snippets.

@leotac
leotac / replace ext
Last active October 11, 2015 03:08
Replacing file extension
find . -name '*.in' | while read old; do
new=${old%.in}.out # strips the .in and adds .out
mv "$old" "$new"
done
#JUST USE ZMV!
@leotac
leotac / gist:3793613
Created September 27, 2012 11:51
To use ssh authentication in a repo already created/cloned, replace https in .git/config
OLD=https://github.com/sbebo/repo.git
NEW=git@github.com:sbebo/repo.git
sed "s#$OLD#$NEW#g" config
@leotac
leotac / install.sh
Last active October 12, 2015 22:18
Things to do after a fresh install (+git setup)
cd
# Install dropbox from https://www.dropbox.com/install?os=lnx
# Install vim
sudo apt-get install vim
# Generate public key and install git
ssh-keygen -t rsa -C "xxxCOMMENTxxx"
cat .ssh/id_rsa.pub # Copy the pub key into github account
#If needed:
#ssh-agent bash
#ssh-add
wget http://scip.zib.de/download/release/scipoptsuite-3.0.1.tgz
cd /opt
sudo tar xvf scipoptsuite-3.0.1.tgz
sudo chown -R leo:leo scipoptsuite-3.0.1
ln -s scipoptsuite-3.0.1 scipoptsuite
cd scipoptsuite
make #LPS=cpx If compiling against CPLEX, ZIMPL=false if no ZIMPL needed
cd scip-3.0.1
make install INSTALLDIR="/usr/local/" #LPS=cpx
@leotac
leotac / ipython-notebook.sh
Last active December 16, 2015 17:09
Setting up ipython notebook
sudo apt-get install pip
sudo apt-get install libzmq-dev liblapack-dev gfortran python-dev build-essential python-qt4
sudo pip install scipy numpy tornado pyzmq pandas ipython pygments matplotlib --upgrade
ipython
#from IPython.lib import passwd
#passwd()
ipython profile create myserver
@leotac
leotac / handy.sh
Last active December 17, 2015 07:28
Bits and pieces
# Full syntax
zmv '(*)' '${(L)1}'
# -W to do quick, simple things
# '' are needed to avoid zsh globbing
zmv -W '*.txt' '*.markdown'
# Nice and useful example of progressive renumbering with 3-zeros left-padded indices.
@leotac
leotac / atlas.sh
Last active December 18, 2015 04:49
Build ATLAS + Numpy/Scipy on Ubuntu 12.04
#Following for the most part the instruction in http://www.scipy.org/scipylib/building/linux.html#building-everything-from-source-with-gfortran-on-ubuntu-nov-2010
sudo apt-get install build-essential python-dev swig gfortran python-nose
# If needed (check less /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor):
sudo apt-get install cpufrequtils
sudo cpufreq-set -c 0 -g performance #for each core, set freq scaling to performance
mkdir BUILD
cd BUILD
@leotac
leotac / gist:5735514
Last active December 18, 2015 05:49
Install and get postgres working on linux (via unix socket)
#Check release (e.g., precise)
lsb_release -c
sudo echo "deb http://apt.postgresql.org/pub/repos/apt/ <release>-pgdg main" > /etc/apt/sources.list.d/pgdg.list
#Authenticate repo
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql pgadmin3
# Then (http://blog.deliciousrobots.com/2011/12/13/get-postgres-working-on-ubuntu-or-linux-mint/)
sudo -u postgres psql postgres
@leotac
leotac / gist:5783795
Created June 14, 2013 17:37
plot columnb "timeCG" for all ".nfo" files with label "pricername" (tab separated files)
import pandas as pd
from pylab import *
import os
[plot(x.timeCG,label=x.pricername.max()) for x in (pd.read_csv(l,"\t") for l in os.listdir('.') if l.endswith("nfo"))]; legend(); show()