Skip to content

Instantly share code, notes, and snippets.

View mgaitan's full-sized avatar
🛠️
devex

Martín Gaitán mgaitan

🛠️
devex
View GitHub Profile
@mgaitan
mgaitan / s_opt_in_load.ipynb
Last active December 24, 2015 07:49
Demo of -s option for %load magic
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mgaitan
mgaitan / gist:6804513
Created October 3, 2013 03:36
return a concatenation of dictionaries ``a`` and ``b`` prefering values of b but extending lists
def smart_update(a, b):
"""
return a concatenation of dictionaries ``a`` and ``b``
prefering values of b but extending lists
>>> a = {'name': 'Martin', 'things': [1]}
>>> b = {'name': 'Nati', 'things': [2]}
>>> smart_update(a, b)
{'name': 'Nati', 'cosas': [1, 2]}
@mgaitan
mgaitan / git-w
Created October 9, 2013 16:22
apply the current changes ignoring whitespaces [1] (keeping a popped stash as backup). [2] [1] http://stackoverflow.com/a/6311302 [2] http://stackoverflow.com/questions/89332/recover-dropped-stash-in-git
#/usr/bin/env sh
git stash && git stash pop && git diff -w > foo.patch && git checkout . && git apply foo.patch && rm foo.patch
@mgaitan
mgaitan / clarin-comillas-politicas.ipynb
Last active December 25, 2015 06:19
Clarín, el "gran" diario argentino
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
from numpy.testing import assert_array_equal
def segments(x, y, bp_x, bp_y):
"""
recibe dos arrays de 1D (x, y) y otros dos vectores (bp_x, bp_y) que dan las coordenadas de algunos puntos en x,y..
Devuelve una tupla (X_segs, Y_segs) cada uno de 2D, donde cada fila es el
segmento del array original hasta el valor más a cercano a un punto en (bp_x, bp_y)
"""
# to do
@mgaitan
mgaitan / elecciones_cba_2013.ipynb
Created October 28, 2013 22:57
En córdoba se ponian 9 bancas de diputados en juego. ¿Qué pasó con Liliana Olivero?
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mgaitan
mgaitan / django_orm_magic.py
Last active December 26, 2015 20:19
cell magic to define django models dynamically
import importlib
import sys
import os.path
import tempfile
from django.core.management import call_command
from django.utils.crypto import get_random_string
from IPython.core.magic import Magics, magics_class, cell_magic
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mgaitan
mgaitan / mesas_sospechosas_fit.ipynb
Created October 30, 2013 18:50
Software para búsqueda de mesas sospechosas en el computo de votos del Frente de Izquierda. Autor: Martín Gaitán mgaitan.github.io twitter: tin_nqn_
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.