knitr::opts_chunk$set(echo = TRUE)
pacman::p_load(tidyverse, rvest)
Sys.setenv("api_a" = "e4b6967c-6921-4784-8bba-d78a212fc52a", 
           "api_b" = "47bb53dc-f0fb-401c-af62-e54fc011a05c", 
           "api_c" = "c42c9cea-a0ef-47af-9427-bbaf7810a299", 
           "api_d" = "87fda554-5eb3-4e4e-bb2a-09ed72a55d8d")

Sys.unsetenv("api_a") 
Sys.unsetenv("api_b") 
Sys.unsetenv("api_c")
Sys.unsetenv("api_d")

Get servers

get_config_file(country = NULL, city = NULL, region = NULL, ip = NULL, credential_path <- "/etc/openvpn/auth.txt"){

  return(config_file)
}

usethis::use_readme_rmd()
tictoc::tic()
servers <- get_servers()
tictoc::toc()

servers %>% 
  dplyr::mutate(us_server = stringr::str_detect(server, "^us"), 
         us_geo = country == "US") %>%
  dplyr::count(us_server, us_geo)

tictoc::tic()
get_servers(country = "US")
tictoc::toc()

library(tidyverse)
servers <- get_servers()

servers %>%
  filter(region != "") %>%
  group_by(region) %>%
  filter(n() > 10) %>%
  mutate(mean_latency = mean(latency, na.rm = T)) %>%
  ungroup %>%
  mutate(region = fct_reorder(paste(country, region, sep = "-"), mean_latency)) %>%
  ggplot(aes(x = region, y = latency)) + geom_boxplot(outlier.alpha = 0) + coord_flip() +
  theme_bw() +
  labs(x = "region", y = "Latency (in ms)")
servers %>%
  group_by(country) %>%
  filter(n() > 10) %>%
  mutate(mean_latency = mean(latency, na.rm = T)) %>%
  ungroup %>%
  mutate(country = fct_reorder(country, mean_latency)) %>%
  ggplot(aes(x = country, y = latency)) + geom_boxplot(outlier.alpha = 0) + coord_flip() +
  theme_bw() +
  labs(x = "Country", y = "Latency (in ms)")
workflow <- ghactions::workflow(name = "update")
ghactions::use_ghactions(workflow)


benjaminguinaudeau/nordvpn documentation built on May 4, 2023, 1:53 a.m.