Skip to content

Instantly share code, notes, and snippets.


Jorge Leitao jorgecarleitao

  • Munin Data ApS
  • Copenhagen, Denmark
View GitHub Profile
jorgecarleitao /
Created Jul 4, 2017
A minimal change of settings parameters for quality images with matplotlib
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[''] = '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
jorgecarleitao /
Created Feb 17, 2017
A decorator of functions that stores a dictionary *args->result in a pickle and returns cached versions after first call
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):
jorgecarleitao /
Created Mar 21, 2015
Installs Sphinx search on the machine. Useful for travis CI.
# usage: `bash -c "$(curl -fsSL <gist_url>)" <version>
tar -xf sphinx-$VERSION-release.tar.gz
cd sphinx-$VERSION-release
./configure --with-pgsql
make install
jorgecarleitao / pt_health_entities.dat
Created Feb 27, 2015
DB of portuguese public entities related to public health
View pt_health_entities.dat
# 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
jorgecarleitao /
Created Jan 14, 2015
Installs nginx in a local directory (e.g. for webfaction)
# prepare
# download
curl -O$VERSION.tar.gz
# extract
tar -xzf nginx-$VERSION.tar.gz
jorgecarleitao /
Last active Apr 14, 2020
Install Xapian in current Python virtualenv
#!/usr/bin/env bash
# first argument of the script is Xapian version (e.g. 1.2.19)
# prepare
mkdir $VIRTUAL_ENV/packages && cd $VIRTUAL_ENV/packages
View .gitignore
# Exact copy of original,,
# but removed comments.
# OS related
# Xcode related
jorgecarleitao / gist:a7ef61d4d918ee8059d6
Created May 21, 2014
Generates a unitary random vector in D dimensions
View gist:a7ef61d4d918ee8059d6
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);