Skip to content

Instantly share code, notes, and snippets.

@mgaitan
mgaitan / pre-commit.py
Created November 2, 2012 19:02 — forked from nqnwebs/pre-commit.py
pep8 and pyflake as git hook
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Script to run pep8 and pyflakes via git's pre-commit hook
Based on https://github.com/lbolla/dotfiles/blob/master/githooks/pre-commit
Modified by Martin Gaitán <mgaitan@machinalis.com> for Machinalis (www.machinalis.com)
Install:
@mgaitan
mgaitan / Preferences.sublime-settings
Last active December 14, 2015 08:19
my sublime settings
{
"auto_complete_delay": 500,
"detect_indentation": false,
"file_exclude_patterns":
[
".*",
"*.pyc",
"*.pyo",
"*.exe",
"*.dll",
@mgaitan
mgaitan / git-integrate
Last active December 16, 2015 08:39
Integrate our branch into origin/develop
#!/bin/bash
#
# Integrate our branch into origin/develop
#
# It's a shortcut for :
#
# 1. pull for last changes on develop
# 2. rebase the target branch against develop
# 3. recheck if no changes happen in the meanwhile
# 4. merge --no-ff
@mgaitan
mgaitan / sse.py
Last active December 19, 2015 04:18
See http://stackoverflow.com/a/13429719 for an explanation on why uses StreamingHttpResponse
# python (django) side:
from django.http import StreamingHttpResponse
import time
def stream(request):
def event_stream():
while True:
time.sleep(3)
yield 'data: %s\n\n' % 'hola mundo'
@mgaitan
mgaitan / goread.js
Last active December 19, 2015 14:59
Goread.io send by gmail userscript
// ==UserScript==
// @name Goread.io send by gmail
// @description Add a send by email action link after go to page icon
// @version 1
// @author Martín Gaitán
// @include http://www.goread.io/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js
// ==/UserScript==
@mgaitan
mgaitan / gist:6319640
Last active December 21, 2015 14:28
ejemplo
def marquesina(cadena, ancho=60, alto=1, caracter="*"):
cadena = str(cadena).center(ancho)
cadena = caracter + cadena[1:-1] + caracter
cadena += '\n'
relleno = " " * ancho
relleno = caracter + relleno[1:-1] + caracter
relleno += '\n'
tapa = caracter * ancho
return tapa + '\n' + relleno * alto + cadena + relleno * alto + tapa
@mgaitan
mgaitan / distance_np.py
Created September 6, 2013 15:10
Computes the distance between m points using Euclidean distance (2-norm) as the distance metric between the points. The points are arranged as m n-dimensional row vectors in the matrix X.
import numpy as np
def distance(X):
"""
Computes the distance between m points using Euclidean distance (2-norm)
as the distance metric between the points.
The points are arranged as m n-dimensional row vectors in the matrix X.
"""
# agregamos una dimension. Ahora X.shape == (m, 1, n)
# Por ejemplo np.all(X[0] == X_dim_plus[0, 0])
@mgaitan
mgaitan / real_size.ipynb
Created September 9, 2013 22:48
how many bytes has each kind of reals
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mgaitan
mgaitan / fortran.js
Created September 10, 2013 15:55
first attempt of codemirror fortran parser
CodeMirror.defineMode("fortran", function(conf, parserConf) {
var ERRORCLASS = 'error';
function wordRegexp(words) {
return new RegExp("^((" + words.join(")|(") + "))\\b", "i");
}
var Operators = new RegExp("(\.and\.|\.or\.|\.eq\.|\.lt\.|\.le\.|\.gt\.|\.ge\.|\.ne\.|\.not\.|\.eqv\.|\.neqv\.)", "i");
var Operators2 = new RegExp("((==)|(/=)|(=)|(<=)|(>=)|(/)|(//))"); //" |(\\*\\*)|\-|\+|\/\/|\/|(?!^)\*)");
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.