Skip to content

Instantly share code, notes, and snippets.

@miguelrios
miguelrios / address_cleaner.rb
Created October 29, 2020 21:15
Cleaning addresses through ruby_postal.
require 'ruby_postal/parser'
require 'csv'
c= CSV.read("users_simple.csv")
RECIPIENT = 0
ADDRESS = 1
CSV.open("addresses_clean.csv", "wb") do |csv|
c.each do |item|
parsed = Postal::Parser.parse_address(item[ADDRESS]).map do |x| [x[:label], x[:value]] end.to_h
@miguelrios
miguelrios / Oasis.txt
Created September 28, 2017 15:42
Lista de oasis (no confirmado)
Compartir para que su familia sepa donde buscar provisiones!
LISTA DE OASIS
Oasis Región Metro:
Bayamón – Carr. 829, entrada a Collores, Urb. Santa Olaya
Bayamón – Ave. Santa Juanita, Esquina Hostos, frente Funeraria Asencio
Bayamón – Al final Ave. Irlanda Height, calle Palestina, Santa Juanita
Trujillo Alto – Calle José de Diego, Escorial Shopping Center, detrás del Home Depot
Trujillo Alto – PR 843, Km 3.5 frente a Urb. Villas de Carraízo
Carolina – Carr. 845, Ave. Montecarlo, frente a Portal de la Reina
Guaynabo – Carr. 833, Int. Centros de Servicios Múltiples Guaraguao
Dear coworkers,
Earlier this week Puerto Rico was hit by one of the most powerful hurricanes ever recorded in the Atlantic. The life and economic loss are expected to be massive. In most of the islands roads are either blocked or washed out, and the electricity and telecoms systems went down broadly.(In a personal note: <ADD SOMETHING ABOUT YOUR FAMILY OR FRIENDS IN THE ISLAND>).
While it's still early to assess all damage, the early reports are incredibly awful. Much like the areas of US that were affected by Harvey and Irma, Maria will leave a painful scar. Electricity, food, & clean water will be scarce for months. Some areas will probably be completely disconnected from the outer world for a while.
I share this with you so you can appreciate the gravity of the situation and ask you for your help.
How to help:
@miguelrios
miguelrios / recons.rb
Created September 5, 2017 05:38 — forked from anonymous/recons.rb
Read latest vortex reads for Hurricane Irma
#!/opt/twitter/rvm/rubies/ruby-2.1.5/bin/ruby
require 'nokogiri'
require 'zip'
require 'open-uri'
parent_urls = "http://tropicalatlantic.com/recon/google_earth/listings_for_network_links/North_Atlantic.kml"
parent_doc = Nokogiri::XML(open(parent_urls))
urls = parent_doc.css("href").map do |i| i.text end
@miguelrios
miguelrios / gist:5862819
Last active December 18, 2015 23:39
Script used to draw Twitter's "Billion Strokes" maps. http://www.flickr.com/photos/twitteroffice/sets/72157633647745984/
library("ggmap")
city <- "istanbul,tr" #city,country. see list in filenames.
map <- get_map(city, zoom=11)
bb <- attr(map, "bb")
filename <- paste("/Users/miguel/data/geo_series/250cities/",city,".txt", sep="") # directory with city files
output <- paste("/Users/miguel/design/geoseries/",city,"_black.png", sep="") # director where you want the output
data = read.table(filename, sep='\t', col.names=c("lat", "lon","city","count", "density"))
sorted <- data[with(data, order(count)), ]
points <- geom_point(aes(x=lon, y=lat, alpha=density, size = count, colour = count), data = sorted, shape=15)
ppi <- 300
@miguelrios
miguelrios / fb_sec.sh
Created February 1, 2012 20:29
Bash script that checks if Facebook posted their IPO papers to the SEC every 10 seconds (warning, very naive approach, make it better).
#!/bin/sh
URL='http://www.sec.gov/cgi-bin/browse-edgar?company=facebook&match=&CIK=&filenum=&State=&Country=&SIC=&owner=exclude&Find=Find+Companies&action=getcompany'
alias fb_sec='curl $URL'
PREIPO=`fb_sec`
while : ;
do
sleep 10s
IPO=`fb_sec`
if [[ "$IPO" != "$PREIPO" ]]
@miguelrios
miguelrios / index.html
Created November 11, 2011 19:46
Force directed nodes
<!DOCTYPE html>
<html>
<head>
<title>Force-Directed Layout (Multiple Foci)</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js"></script>
</head>
<body>
<script type="text/javascript">
var array = [];
console.log("my array has " + array.length + " elements and it looks like: ", array);
console.log("WTF?");
array[5] = 1;
console.log("now my array has " + array.length + " elements and it looks like: ", array);
console.log("Okey...");
/*
results from Chrome-Safari console:
my array has 0 elements and it looks like: [undefined, undefined, undefined, undefined, undefined, 1]
@miguelrios
miguelrios / transparent_bg.js
Created December 18, 2010 23:35
Transparent Background in Processing JS
//width and height are the dimensions of your processing canvas.
processing.setup = function() {
processing.size(width, height);
processing.loadPixels();
for (var i = 0; i < processing.width*processing.height; i++){
processing.pixels.setPixel(i,0);
}
processing.updatePixels();
};