Skip to content

Instantly share code, notes, and snippets.

View aniversarioperu's full-sized avatar

AniversarioPeru aniversarioperu

View GitHub Profile
@aniversarioperu
aniversarioperu / tuits_CarmenOmonte.csv
Last active August 29, 2015 13:56
Algunos tuits georeferenciados de la congresista Omonte.
tuit_id screen_name latitud longitud fecha y hora
326104115111424000 carmenomonte -12.108433 -77.0335621 2013-04-21 05:44:14 PM |
326024118581489664 carmenomonte -12.1081355 -77.0336217 2013-04-21 12:26:21 PM | PERU
325972703326646273 carmenomonte -12.1100994 -77.034321 2013-04-21 09:02:03 AM |
325531064036642816 carmenomonte 40.4220098 -3.6809711 2013-04-20 03:47:08 AM |
325008393708376066 carmenomonte 40.4224202 -3.6843151 2013-04-18 05:10:14 PM |
324939467284684801 carmenomonte 40.4220642 -3.6809915 2013-04-18 12:36:20 PM |
324599353329217536 carmenomonte 40.4220021 -3.6809971 2013-04-17 02:04:51 PM | ESPAÑA
324265403977191424 carmenomonte 40.4220725 -3.6810365 2013-04-16 03:57:51 PM |
324260683061534722 carmenomonte 40.4220689 -3.6810248 2013-04-16 03:39:06 PM |
@aniversarioperu
aniversarioperu / saludos_molina.py
Created February 1, 2014 16:41
extraer todos los saludos firmados por el congresista Molina
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import codecs
import glob
for filename in glob.glob("*html"):
f = codecs.open(filename, "r", "latin1")
html_doc = f.read()
f.close()
soup = BeautifulSoup(html_doc)
for tag in soup.find_all("td", width="150"):
@aniversarioperu
aniversarioperu / plot_saludos_por_congresista.py
Last active August 29, 2015 13:55
código para plotear lista de congresistas y saludos oficiales emitidos durante 2011-2014. Los datos te los bajas de aqui: http://pastebin.com/adJ20W81
# -*- coding: utf-8 -*-
import codecs
import prettyplotlib as ppl
import numpy as np
from prettyplotlib import plt
import csv
@aniversarioperu
aniversarioperu / plotear_tuits.py
Created December 25, 2013 14:15
Código para plotear tuits conteniendo la palabra INCENDIO. Ver post en http://aniversarioperu.utero.pe/2013/12/25/feliz-navidad-con-incendio-para-todos/
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import codecs
import re
import datetime
import time
from itertools import groupby
import numpy as np
import matplotlib.pyplot as plt
@aniversarioperu
aniversarioperu / tuits_incendio.csv
Last active January 1, 2016 09:09
tuits de la cuenta @bomberos conteniendo la palabra INCENDIO durante el mes de Diciembre 2013. Ver post en http://aniversarioperu.utero.pe/2013/12/25/feliz-navidad-con-incendio-para-todos/
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 4 columns, instead of 3. in line 8.
415727619427299328,2013-12-25 06:16:02 +0000,bomberos,INCENDIO Carreteras - Panamericanas Panamericana Sur 16.4 San Juan De Miraflores M120-3
415727115305504768,2013-12-25 06:14:02 +0000,bomberos,INCENDIO Cl. Cucarda 200 CIST176-4
415726862464483328,2013-12-25 06:13:02 +0000,bomberos,INCENDIO Av. Villa Hermosa (huascar) (coronel Francisco Bolognesi) (4) 000 San Juan De Lurigancho M65-1
415724752737955840,2013-12-25 06:04:39 +0000,bomberos,"RT @televivape: ""@bomberos: INCENDIO Pj. Pamplona Alta Sector Ollantay Mz U3 Lt 5 San Juan De Miraflores M138-4"""
415724096505516032,2013-12-25 06:02:03 +0000,bomberos,INCENDIO Cl. Emilio Fernandez 693 Lima M4-5
415723088089976832,2013-12-25 05:58:02 +0000,bomberos,INCENDIO Pj. Pamplona Alta Sector Ollantay Mz U3 Lt 5 San Juan De Miraflores M138-4
415722083558367232,2013-12-25 05:54:03 +0000,bomberos,INCENDIO Barrio Chocoy M73-3
415722082702721024,2013-12-25 05:54:02 +0000,bomberos,INCENDIO Jr. Fernandez Quiroz 000 Lima
415720575215370241,2013-12-25 05:48:03 +0000,bombero
@aniversarioperu
aniversarioperu / leeme_votaciones.py
Created December 1, 2013 17:08
Script para ver cómo ha votado Peru, Chile y EEU (PE, CL, US) en las negociaciones del TPP filtrado por Wikileaks (http://wikileaks.org/tpp/)
import re
import sys
f = open(sys.argv[1].strip(), "r")
lines = f.readlines()
f.close()
def clean_line(line):
propose = ""
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import codecs
import re
import datetime
import time
from itertools import groupby
import numpy as np
import matplotlib.pyplot as plt
@aniversarioperu
aniversarioperu / datos.txt
Created November 4, 2013 20:45
número total de delitos Perú, años 2005 al 2012. Fuente INEI
152516
153055
144205
151560
160848
181866
206610
254405
@aniversarioperu
aniversarioperu / delitos_bayesian.py
Created November 3, 2013 18:11
Análisis estadístico bayesiano del número de delitos por año para Perú. Se obtiene el número esperado de delitos y el año más probable en que se produjo un aumento en la cantidad de delitos. Usando teoría y cógidos de "Bayesian methods for hackers": http://bit.ly/19tyAUX
# -*- coding: utf-8 -*-
import prettyplotlib as ppl
from prettyplotlib import plt
import sys
import pymc as pm
import numpy as np
datos = np.loadtxt("datos.txt")
alpha = 1.0/datos.mean()
print alpha
@aniversarioperu
aniversarioperu / lm.R
Created November 3, 2013 18:08
Plot del total de delitos por año para Perú. Datos tomados del INEI: http://www.inei.gob.pe/media/MenuRecursivo/Cap08005.xls
library(ggplot2)
y <- read.csv("datos.txt", header=FALSE)
y <- as.vector(y[,1])
x <- 2005:2012
int <- lsfit(x,y)$coefficients[1]
slope <- lsfit(x,y)$coefficients[2]
p <- ggplot(,aes(x,y))
p + geom_point() + geom_abline(intercept=int, slope=slope) +
labs(title = "Perú: Número total de delitos por año")