Skip to content

Instantly share code, notes, and snippets.

View diegovalle's full-sized avatar

Diego Valle-Jones diegovalle

View GitHub Profile
@diegovalle
diegovalle / index.js
Last active August 23, 2018 00:20
openwhisk contact form with recaptcha
// Contact form for www.ilsevalle.com
// The form requieres 4 parameters:
// SENDGRID_API - Sendgrid API key to send emails
// EMAIL_SENDER - address from which the mail is sent
// SEND_TO - address to which the mail is sent
// RECAPTCHA_SECRET - Server secret from Google's recaptcha service
// TIMEZONE - time zone in which to display the submission time (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
const request = require('request');
const sgMail = require('@sendgrid/mail');
@diegovalle
diegovalle / homicides-2013.Rmd
Last active August 1, 2018 15:38
changes and trends in homicide rates in the most violent metro areas or big municipios or at the national level
---
title: "Changes in homicide rates"
output: html_document
---
I've updated the [mxmortalitydb](https://github.com/diegovalle/mxmortalitydb) package to include 2013 data. This data only packages includes all injury intent deaths (accidents, homicides, suicides and unspcified intent) that were registered in Mexico from 2004 to 2013. You can use the package to calculate changes and trends in homicide rates in the most violent metro areas or big municipios.
```{r}
#if (!require('devtools')) install.packages('devtools')
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@diegovalle
diegovalle / privacy_policy_blogdiegovallenet.md
Last active May 27, 2018 17:02
Privacy policy for blog.diegovalle.net

Privacy Policy

Last revised on 2018-05-18

www.diegovalle.net, blog.diegovalle.net Privacy Policy

This Privacy Policy describes how your personal information is collected, used, and shared when you visit or make a purchase from www.diegovalle.net or blog.diegovalle.net (the “Site”).

PERSONAL INFORMATION WE COLLECT

@diegovalle
diegovalle / temp-cdmx.R
Last active February 1, 2018 15:46
Temperaturas diarias durante eneros de 2005 a 2018 por estación
library(viridis)
library(ggridges)
library(aire.zmvm)
library(lubridate)
library(ggplot2)
library(dplyr)
library(tidyr)
library(stringr)
library(lubridate)
@diegovalle
diegovalle / january-temps.R
Last active January 31, 2018 02:02
Hourly January temperatures for all reporting sensors for 2016-2018
#based on https://cran.r-project.org/web/packages/ggjoy/vignettes/gallery.html
library(viridis)
library(ggridges)
library(aire.zmvm)
library(lubridate)
library(ggplot2)
library(dplyr)
library(tidyr)
library(stringr)
library(lubridate)
library(directlabels)
library(ggplot2)
library(scales)
library(tidyr)
df = data.frame(Canada = c(522, 609, 611),
US = c(15872, 17793, 19362),
Mexico = c(20010, 20762, 24559))
df = data.frame(apply(df, 2, function(x) x = x/x[1]))
df$year = 2014:2016
pop <- read.csv("../downloader/data/pop_muns.csv") %>% filter(date == '2010-06-01 00:00:00')
mex <- injury.intent %>%
filter(year_reg == 2016 & intent %in% c("Homicide", "Legal Intervention")) %>%
group_by(state_occur_death, mun_occur_death) %>%
rename(state_code = state_occur_death, mun_code = mun_occur_death) %>%
summarise(count = n()) %>%
left_join(read.csv("../downloader/data/pop_muns.csv") %>% filter(date == '2016-06-01 00:00:00'),
by = c("state_code", "mun_code")) %>%
mutate(rate = count / population * 10^5) %>%
#based on https://cran.r-project.org/web/packages/ggjoy/vignettes/gallery.html
library(viridis)
library(ggridges)
#devtools::install_github('diegovalle/aire.zmvm')
library(aire.zmvm)
library(lubridate)
library(ggplot2)
library(dplyr)
library(tidyr)
@diegovalle
diegovalle / .block
Last active August 2, 2017 16:47
Density map of homicides in Monterrey
license: mit