Skip to content

Instantly share code, notes, and snippets.

View fedelebron's full-sized avatar

Federico Lebrón fedelebron

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<title>Mandelbrot in JS + Canvas</title>
<meta charset="UTF-8">
<style type="text/css">
#centered {
margin-left: 35%;
margin-top: 10%;
width: 430px;
#include <stdexcept>
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <sys/time.h>
using namespace std;
#define izquierda(nodo) (nodo+nodo+1)
#define derecha(nodo) (nodo+nodo+2)
#define padre(nodo) ((nodo-1)>>1)
@fedelebron
fedelebron / gist:227577
Created November 6, 2009 01:00
Binary Search Tree, with DSW balancing
#include <exception>
#include <cstdlib>
#include <iostream>
using namespace std;
class NodoInexistenteException : public exception {
};
<!doctype html>
<html>
<head>
<title>Canvas + JS</title>
<style>
#canvas {
border: 1px solid black;
}
</style>
</head>
#include <iostream>
#include <vector>
using namespace std;
#define INFINITO 1000000
#define forn(i, n) for(i = 0; i < (n); ++i)
typedef vector<int> vint;
typedef vector<vint> vvint;
@fedelebron
fedelebron / nginx_config
Created January 14, 2011 21:43
How to tell nginx's configuration to directly serve requests from /media to a specific folder, when one has / being handled by Django.
location /media {
alias /home/flebron/sites/fedelebron.com/media;
}
@fedelebron
fedelebron / practica_isomorfismo.tex
Created April 23, 2011 08:37
A piece of a document sent to students regarding graph isomorphisms.
\section{Resumen de isomorfismos}
\begin{definition} Dados grafos $G = (V, E)$ y $G' = (V', E')$, se dice que $G$ y $G'$ son \emph{isomorfos} si existe una función $f: V \to V'$ biyectiva tal que $\forall \ u, v \in V, (u, v) \in E \iff (f(u), f(v)) \in E'$. Notamos $G \cong G'$, y decimos que $f$ es un \emph{isomorfismo de grafos}.
\end{definition}
\paragraph{} Intuitivamente, un isomorfismo de grafos preserva lo que es el grafo en sí. Sobre un grafo, generalmente, nos importan solo los ejes entre los nodos. No nos importan, por ejemplo, las etiquetas con las que nombremos a los nodos, ni la posición gráfica de los mismos, ni las curvas que usemos para dibujar los ejes, ni si llovía mientras lo dibujábamos. Un isomorfismo de grafos preserva la estructura que nos importa, la relación entre los nodos. Se deja como ejercicio ver que ``ser isomorfo'' es una relación de equivalencia.
\paragraph{} Como dijo Mariano, podemos pensar que cualquier propiedad que intentemos escribir usando sólo esta estructura del g
function hashElements(arr, directions, order) {
var i = order.length, sort_pass = function(field, order) {
arr = arr.sort(function(a, b) {
var res = a[field] <= b[field];
return b == -1? res : !res;
});
};
while(i--) sort_pass(order[i], directions[order[i]]);
return arr;
}
@fedelebron
fedelebron / mandelbrot.go
Created June 28, 2011 11:21
Parallel Mandelbrot in Go
package main
import (
"flag"
"image"
"image/color"
"image/png"
"math"
"os"
)
@fedelebron
fedelebron / latex_render.py
Created June 28, 2011 11:34
How I vertically align my LaTeX on my Django-based blog
import tempfile
import sys
import os
import hashlib
import shutil
import re
from subprocess import Popen, PIPE
pattern = re.compile(r'\$(.*?)\$')
pattern2 = re.compile(r'\[`(.*?)`\]', re.DOTALL)