Skip to content

Instantly share code, notes, and snippets.

View diegovalle's full-sized avatar

Diego Valle-Jones diegovalle

View GitHub Profile
@diegovalle
diegovalle / trello.md
Last active February 13, 2024 15:14 — forked from jeremyzilar/trello.md
Copy Trello Board as text or markdown

Copy Trello Board as text or markdown

Wouldn't it be nice to copy out your Trello board as plain text or markdown to be able to put it in a weekly memo, shipping notice or release notes? Now you can!

How to use this

Copy this line of JS and paste it into the CONSOLE in your browser. The results will be saved to your clipboard.

Option 1: Copy your Trello Board as Markdown

This will copy your columns + cards as markdown right to left

var s = []; s.push("# " + jQuery(".board-canvas").children()[0].innerText); jQuery.fn.reverse = [].reverse; jQuery(".list:has(.list-header-name)").reverse().each(function() {s.push("\n## " + jQuery(this).find(".list-header-name-assist")[0].innerText + "\n"); jQuery(this).find(".list-card-title").each(function() {s.push("* " + this.innerText); }); }); copy(s.join("\n"));
@diegovalle
diegovalle / README.md
Last active January 8, 2024 19:24
Topojson of Mexican municipalities and states

How to create the topojson map:

curl -o estados.zip http://mapserver.inegi.org.mx/MGN/mge2010v5_0.zip
curl -o  municipios.zip http://mapserver.inegi.org.mx/MGN/mgm2010v5_0.zip
unzip estados.zip 
unzip municipios.zip
ogr2ogr states.shp Entidades_2010_5.shp -t_srs "+proj=longlat +ellps=WGS84 +no_defs +towgs84=0,0,0"
ogr2ogr municipalities.shp Municipios_2010_5.shp -t_srs "+proj=longlat +ellps=WGS84 +no_defs +towgs84=0,0,0"
topojson -o mx_tj.json -s 1e-7 -q 1e5 states.shp municipalities.shp -p state_code=+CVE_ENT,state_name=NOM_ENT,mun_code=+CVE_MUN,mun_name=NOM_MUN
@diegovalle
diegovalle / censo_2020.sh
Last active July 27, 2023 15:45
Download the shapefiles from the 2020 Mexican census
#!/usr/bin/env bash
####################################################
# Make sure `rename` is available on your system
####################################################
# Exit on error, undefined and prevent pipeline errors,
# use '|| true' on commands that intentionally exit non-zero
set -euo pipefail
# The directory from which the script is running
readonly LOCALDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
readonly TARGET_DIR="$LOCALDIR/censo2020"
@diegovalle
diegovalle / scince_2020.sh
Last active December 15, 2022 18:01
Script to download shapefiles from 2020 Mexican census (including demographic data)
# The directory from which the script is running
readonly LOCAL_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
TEMP_DIR="$(mktemp -d)"
# index starts at zero
declare -a states=("national" "ags" "bc" "bcs" "camp" "coah" "col"
"chis" "chih" "cdmx" "dgo" "gto" "gro" "hgo" "jal"
"mex" "mich" "mor" "nay" "nl" "oax" "pue" "qro"
"qroo" "slp" "sin" "son" "tab" "tamps" "tlax" "ver"
@diegovalle
diegovalle / mx_grid.R
Last active June 17, 2021 14:28
mexico geofacet
library(dplyr)
library(stringr)
library(readr)
library(ggplot2)
library(geofacet)
options(stringsAsFactors = FALSE)
mx_grid <- data.frame(
code = c(2L, 8L, 26L, 3L, 5L, 10L, 19L, 25L, 28L, 1L, 18L, 24L, 32L,
11L, 13L, 14L, 22L, 30L, 6L, 15L, 29L, 9L, 17L, 21L, 31L, 4L,
@diegovalle
diegovalle / key.asc
Last active February 16, 2021 15:52
PGP PUBLIC KEY - Diego Valle-Jones
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFNoG6gBEADUb3F7iVz7k6yt5oVipTv4F0kg6SUoBEPcU/sSwwu40XLyDRm2
fVOgdsr5lWYTpcq4JWOk7S27IOTknZpWMNetdb3XHHdATWoHSEln3acIvZWQxmQ8
nJFIKfgM4WbWBPQMFXs9KU5FrBJC/iETzlgv7yFfvp1eBfz57fUNAE3ZQ496du9w
VPiXscN7Q49KCz/V/QE59agiokEbLpnVC2q8kjM+ydjSjEUNTvqwJPBek6KQDkHT
rHiEw/JKA+/P3FrDdp2LFtLpKmbgOviqV1+2GtQE16qjA0FfsoA3pK9wJeu21Qtv
vajY+Oe864TFkOJG/fO07RzsTfqA63FfDPtm+s/j18OcISab1DPk6guEmTOTqEsB
RAUMUiMyu7HawCSob6vwYrNsRlU6S/KFnC2AlWOfpBStq1tiEbqo/fGn2I84744o
J6eCyP15qG0NbFt+tF53iEMRVPG+VH40v1nymPbe5xUdcvj6kv/1A46PM0zBmM60
@diegovalle
diegovalle / download-mapa-digital.sh
Last active June 11, 2020 00:36
Download the shapefiles contained in the Mapa Digital de México
#! /bin/bash
# Author: Diego Valle-Jones
# Web: http://www.diegovalle.net
# Purpose: Download the shapefiles contained in the Mapa Digital de México
# comunicaciones y transportes
# cultura
# curvas de nivel
# hidrografia
@diegovalle
diegovalle / mapa_covid.R
Created April 15, 2020 16:00
Mapa de casos COVID-19
## Auto-Install the following packages
.packs <- c("tidyverse", "lubridate", "ggrepel", "viridis", "scales")
.success <- suppressWarnings(sapply(.packs, require, character.only = TRUE))
if (length(names(.success)[!.success])) {
install.packages(names(.success)[!.success])
sapply(names(.success)[!.success], require, character.only = TRUE)
}
if (!require(mxmaps))
devtools::install_github("diegovalle/mxmaps")
library(mxmaps)
@diegovalle
diegovalle / mx_geofacet.R
Last active May 22, 2020 16:54
Mexico geofacet
library(dplyr)
library(readr)
library(ggplot2)
library(geofacet)
read_csv("https://data.diegovalle.net/elcrimen/nm-estatal-victimas.csv.gz") %>%
filter(subtipo == "HOMICIDIO DOLOSO") %>%
group_by(subtipo, state_code, state, date) %>%
summarise(count = sum(count, na.rm = TRUE),
library("ggplot2")
library("mxmaps")
df_mxmunicipio$value <- as.factor(sample(letters[1:2], 2457, replace = TRUE) )
df_mxmunicipio$value <- factor(df_mxmunicipio$value, levels = c("a", "b",
"c", "d"))
gg = MXMunicipioChoropleth$new(df_mxmunicipio)
gg$title <- "Municipios a and b"
gg$set_num_colors(4)
gg$ggplot_scale <- scale_fill_manual("type",