This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
def set_plot_settings(font_size=18): | |
# a font that is very close to LaTeX. | |
plt.rcParams['mathtext.fontset'] = 'stix' | |
plt.rcParams['font.family'] = 'STIXGeneral' | |
# ticks with the same width as axis, and consistent with font size (below) | |
plt.rcParams['axes.linewidth'] = 1 | |
plt.rcParams['xtick.major.width'] = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pickle | |
def cache(file_name): | |
""" | |
A decorator to cache the result of the function into a file. The result | |
must be a dictionary. The result storage is in pickle | |
""" | |
def cache_function(function): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage: `bash -c "$(curl -fsSL <gist_url>)" <version> | |
VERSION=$0 | |
wget http://sphinxsearch.com/files/sphinx-$VERSION-release.tar.gz | |
tar -xf sphinx-$VERSION-release.tar.gz | |
cd sphinx-$VERSION-release | |
./configure --with-pgsql | |
make | |
make install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# name, Fiscal number | |
Gabinete do Ministro da Saúde;600052303 | |
Gabinete do Secretario de Estado Adjunto do Ministro da Saúde;600071006 | |
Gabinete do Secretario de Estado da Saúde;600052290 | |
Secretaria-Geral do Ministério da Saúde;600080684 | |
Direcção-Geral da Saúde;600037100 | |
Instituto da Droga e da Toxicodependência;506452654 | |
Inspecção-Geral das Actividades Saúde;600018857 | |
Autoridade para os Serviços de Sangue e da Transplantação;600082695 | |
Alto Comissariado da Saúde;600082709 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# prepare | |
VERSION=$1 | |
DIRECTORY=$2 | |
# download | |
curl -O http://nginx.org/download/nginx-$VERSION.tar.gz | |
# extract | |
tar -xzf nginx-$VERSION.tar.gz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# first argument of the script is Xapian version (e.g. 1.2.19) | |
VERSION=$1 | |
# prepare | |
mkdir $VIRTUAL_ENV/packages && cd $VIRTUAL_ENV/packages | |
CORE=xapian-core-$VERSION | |
BINDINGS=xapian-bindings-$VERSION |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Exact copy of original, https://gist.github.com/adamgit/3786883, | |
# but removed comments. | |
# OS related | |
.DS_Store | |
*.swp | |
*.lock | |
profile | |
# Xcode related |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::vector<double> unitaryVector(unsigned int dimension) | |
{ | |
std::vector<double> vector(dimension); | |
double norm = 0; | |
for (unsigned int d = 0; d < dimension; d++) | |
{ | |
vector[d] = grandom(); // RNG call for a gaussian with mean=0 and sigma=1 | |
norm += vector[d]*vector[d]; | |
} | |
norm = sqrt(norm); |