Skip to content

Instantly share code, notes, and snippets.

View aizquier's full-sized avatar

Manuel Arturo Izquierdo aizquier

  • CEN-r, Université de Montréal
  • Montreal, Canada
View GitHub Profile
@aizquier
aizquier / print_function_debug_overload.py
Created December 3, 2019 16:33
python3: Overloads the builtin `print()` function to print the file and line number where the print occurs.
'''
Overloads the builtin `print()` function to print the file and line number
where the print occurs, similarly to Javascript's `console.log()`.
Useful when in development. Just import this file at the top of your project.
'''
import builtins
import inspect
import os
@aizquier
aizquier / pyarray_to_html_table.py
Last active July 5, 2018 14:51
Python 2D array to HTML table
def array2htmltable(data):
q = "<table>\n"
for i in [(data[0:1], 'th'), (data[1:], 'td')]:
q += "\n".join(
[
"<tr>%s</tr>" % str(_mm)
for _mm in [
"".join(
[
"<%s>%s</%s>" % (i[1], str(_q), i[1])
@aizquier
aizquier / azimuth_plot.py
Created October 17, 2017 16:40
Azimuth plot for archaeoastronomy
import matplotlib.pyplot as plt
import numpy as np
# azimuths to plot (degrees)
data = [95, 87, 82, 96, 78, 89, 129, 264, 277, 58]
# convert to radians
azimuths_rad = (np.array(data) * np.pi) / 180.0
# Polar plotting
@aizquier
aizquier / legend_outside_plot.py
Created November 11, 2016 18:48
Matplotlib: plot the legend outside the plot and adjusts the viewport to contain the plot and the (outer) legend
# * just prepares some data to plot, the legend trick is at line 54
docs = {'ndocs': {'Actes': 1775,
'Article': 626,
'Autre': 497580,
'Compte rendu': 1831,
'Culturel': 76034,
'Document': 525,
'Livres': 313,
@aizquier
aizquier / emacs24.5_build_intructions.txt
Created April 14, 2016 00:14
Build emacs 24.5 in linux Mint
sudo apt-get remove \
emacs emacs24 emacs24-bin-common \
emacs24-common emacs24-common-non-dfsg emacsen-common
wget -c http://gnu.mirror.vexxhost.com/emacs/emacs-24.5.tar.xz
tar vxf emacs-24.5.tar.xz
cd emacs-24.5/
sudo apt-get install libxml2-dev libgtk-3-dev \
libtiff5-dev libgif-dev libXpm-dev libncurses-dev
./configure
make