Skip to content

Instantly share code, notes, and snippets.

View phrmendes's full-sized avatar

Pedro Mendes phrmendes

View GitHub Profile
@phrmendes
phrmendes / neovim.nix
Created September 10, 2023 03:29
Download neovim plugins from GitHub using Nix and home-manager
{
pkgs,
lib,
...
}: let
fromGitHub = ref: repo:
pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "${lib.strings.sanitizeDerivationName repo}";
version = ref;
src = builtins.fetchGit {
@phrmendes
phrmendes / has_unit_root.R
Created January 12, 2023 17:14
Unit root test in R
library(urca)
has_unit_root <- function(serie) {
trend_model <- urca::ur.df(serie, type = "trend", selectlags = "BIC")
summary_model <- summary(trend_model)
test_value <- summary_model@teststat[1]
tau_3 <- summary_model@cval[1, 2]
if (test_value < tau_3) {
return(FALSE)
@phrmendes
phrmendes / strict_dominance.R
Last active August 22, 2022 00:56
The code tests for strict dominance in a zero-sum game.
# packages ----------------------------------------------------------------
packages <- c("glue", "purrr", "rlang")
# install.packages(packages)
invisible(lapply(packages, require, character.only = TRUE))
# variables ---------------------------------------------------------------
@phrmendes
phrmendes / get_from_pdf.R
Last active August 21, 2022 20:48
Function that CNPJ's and CEP's data in .pdf documents
# packages ----
packages <- c("curl", "glue", "pdftools", "stringr", "tibble", "purrr", "tesseract")
install.packages(packages)
invisible(lapply(packages, require, character.only = TRUE))
# function ----