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 / 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 / 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"
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",
@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 / cumsum.R
Last active March 31, 2020 19:52
cumsum.R
## Auto-Install the following packages
.packs <- c("ggplot2", "tabulizer", "dplyr", "stringr",
"rvest", "hrbrthemes", "scales", "tidyr",
"lubridate", "directlabels")
.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)
}
library(aire.zmvm)
library(rsinaica)
library(ggplot2)
library(tidyverse)
library(lubridate)
library(zoo)
library(hrbrthemes)
pm25_2019 <- sinaica_param_data("PM2.5", "2019-05-01", "2019-05-16")
library(aire.zmvm) #devtools::install_github('diegovalle/aire.zmvm')
library(ggplot2)
library(tidyverse)
library(lubridate)
library(zoo)
library(hrbrthemes)
df <- get_station_month_data("HORARIOS", "PM25", 2019, 5)
df <- df %>%
filter(station_code %in% c("SAC", "NEZ")) %>%
library(lubridate)
library(aire.zmvm)
library(ggplot2)
library(dplyr)
library(hrbrthemes)
get_latest_imeca()
df <- get_zone_imeca("HORARIOS", "TC", "TZ", "2019-05-01", "2019-05-14")
df$datetime <- ymd_h(paste0(df$date, " ", df$hour))
library(rsinaica)
library(dplyr)
library(zoo)
library(gghighlight)
df_pm25 <- sinaica_param_data("PM2.5", "2018-12-23", "2019-01-02")
df_pm10 <- sinaica_param_data("PM10", "2018-12-23", "2019-01-02")
plot_top <- function(df, title = "", ylab = "", exclude = c("")) {
df_max <- df %>%