Skip to content

Instantly share code, notes, and snippets.

View lnds's full-sized avatar

Eduardo Díaz lnds

View GitHub Profile
@lnds
lnds / gist:5424160
Created April 20, 2013 00:32
Clase que permite abrir archivos detectando su encoding en forma automática, muy útil para trabajar con archivos codificados en WIndows Ansi, UTF8, Unicode, etc. Un problema que se está haciendo demasiado frecuente. Usa la biblioteca universalchardet de Mozilla
import org.mozilla.universalchardet.UniversalDetector;
import java.io.*;
import java.nio.charset.Charset;
public class DetectEncoding {
private static final int BUF_SIZE = 4096;
// open a BufferedReader detect encoding
@lnds
lnds / hamming0_lnds.py
Created July 8, 2012 18:08
Haming Solucion 0 en Python (www.programando.org)
def hamming(p1,p2,p3):
yield 1
m2 = times(p1, hamming(p1,p2,p3))
m3 = times(p2, hamming(p1,p2,p3))
m5 = times(p3, hamming(p1,p2,p3))
for h in merge(merge(m2, m3), m5):
yield h