Skip to content

Instantly share code, notes, and snippets.

View villegar's full-sized avatar

Roberto Villegas-Diaz villegar

View GitHub Profile
if (!require("httr2")) install.packages("httr2")
httr2::request("pkmn.li") |>
httr2::req_perform() |>
httr2::resp_body_string() |>
cat()
@villegar
villegar / country-bounding-boxes.py
Created February 29, 2024 09:05 — forked from graydon/country-bounding-boxes.py
country bounding boxes
# extracted from http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip
# under public domain terms
country_bounding_boxes = {
'AF': ('Afghanistan', (60.5284298033, 29.318572496, 75.1580277851, 38.4862816432)),
'AO': ('Angola', (11.6400960629, -17.9306364885, 24.0799052263, -4.43802336998)),
'AL': ('Albania', (19.3044861183, 39.624997667, 21.0200403175, 42.6882473822)),
'AE': ('United Arab Emirates', (51.5795186705, 22.4969475367, 56.3968473651, 26.055464179)),
'AR': ('Argentina', (-73.4154357571, -55.25, -53.628348965, -21.8323104794)),
'AM': ('Armenia', (43.5827458026, 38.7412014837, 46.5057198423, 41.2481285671)),
#' Load the gambling dataset
#'
#' Load the "Gambling in England and Scotland, 2012: Combined Data from the
#' Health Survey for England and the Scottish Health Survey".
#'
#' @param URL String with the URL to the gambling dataset.
#' Original URL: https://beta.ukdataservice.ac.uk/Umbraco/Surface/Discover/GetDownload?studyNumber=7631&fileName=7631spss_64b153f5084ba9c47585e4248a2a1677.zip
#' Shorten URL: https://tinyurl.com/ukdata-gambling
#'
#' @return Data frame with the gambling dataset
@villegar
villegar / github.R
Created January 29, 2024 11:48 — forked from z3tt/github.R
Configure GitHub for Rstudio
#### 1. Sign up at GitHub.com ################################################
## If you do not have a GitHub account, sign up here:
## https://github.com/join
# ----------------------------------------------------------------------------
#### 2. Install git ##########################################################
## If you do not have git installed, please do so:
remove_geneid_version <- function() {
seq_file <- file.choose()
seq_file_contents <- read.table(seq_file, header = FALSE)
seq_file_contents$V1 <-
gsub(pattern = ".[0-9]+$", replacement = "", seq_file_contents$V1)
write.table(seq_file_contents, file.choose(new = TRUE),
quote = FALSE,
row.names = FALSE,
col.names = FALSE)
}
@villegar
villegar / uol_pubh110_phdl.R
Last active November 28, 2023 16:23
Load the Gambling in England and Scotland, 2012 dataset from the UK Data Service
#' Load the gambling dataset
#'
#' Load the "Gambling in England and Scotland, 2012: Combined Data from the
#' Health Survey for England and the Scottish Health Survey".
#'
#' @param URL String with the URL to the gambling dataset.
#' Original URL: https://beta.ukdataservice.ac.uk/Umbraco/Surface/Discover/GetDownload?studyNumber=7631&fileName=7631spss_64b153f5084ba9c47585e4248a2a1677.zip
#' Shorten URL: https://tinyurl.com/ukdata-gambling
#'
#' @return Data frame with the gambling dataset
#' Load the gambling dataset
#'
#' Load the "Gambling in England and Scotland, 2012: Combined Data from the
#' Health Survey for England and the Scottish Health Survey".
#'
#' @param URL String with the URL to the gambling dataset.
#' Original URL: https://beta.ukdataservice.ac.uk/Umbraco/Surface/Discover/GetDownload?studyNumber=7631&fileName=7631spss_64b153f5084ba9c47585e4248a2a1677.zip
#' Shorten URL: https://tinyurl.com/ukdata-gambling
#'
#' @return Data frame with the gambling dataset
@villegar
villegar / fingertips_with_R.R
Created December 1, 2022 11:12
Example of fingertipsR
# Install the package ----
# install.packages("remotes")
remotes::install_github("rOpenSci/fingertipsR",
build_vignettes = TRUE,
dependencies = "suggests")
# Data profiles ----
# Retrieve data profiles and filter Publoc Health Outcomes
fingertipsR::profiles() |>
dplyr::filter(stringr::str_detect(ProfileName,
It's been a while since this gist was written. In the meantime the package homeassistant-supervised apt
package was introduced for debian based systems. If you used that way the first thing you should do use
the normal package uninstaller with something like: (sudo) apt remove homeassistant-supervised
If for some reason that doesn't work proceed with the below instructions for a manual cleanup.
1) stop services:
sudo systemctl stop hassio-supervisor.service
sudo systemctl stop hassio-apparmor.service
2) disable services:
# https://data.humdata.org/dataset/cod-ab-cri?
filename <- "~/Downloads/cri_adm_2021_WGS_84.gdb"
sf::st_layers(filename)
# Provincias
cri_adm1 <- sf::st_read(filename, layer = "cri_admbnda_adm1_2021_WGS_84")
cri_adm1
# Distritos
cri_adm2 <- sf::st_read(filename, layer = "cri_admbnda_adm2_2021_WGS_84")
cri_adm2