This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Faz dump de uma tabela em arquivos rds | |
#' | |
#' @param conn Connexão | |
#' @param schema Schema | |
#' @param table Tabela | |
#' @param n Número de linhas arquivo | |
#' @param diretorio Diretório onde os arquivos serão salvos | |
#' | |
#' @details Esta função é particularmente útil para fazer dump de tabelas muito grandes | |
#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Extrai tabela de commits realizados em repositório. | |
#' | |
#' @param owner Proprietário | |
#' @param repo Repositório | |
#' @param since data inicial no formato "yyyy-mm-dd". Padrão "1970-01-01" | |
#' @param until data final no formato "yyyy-mm-dd". Padrão data atual. | |
#' @param limit Número máximo de commits. Padrão para Inf. | |
#' @param ... Outros argumentos passados para `gh::gh` | |
#' | |
#' @return tibble |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dir_size <- function(x){ | |
purrr::map_dfr(x, purrr::possibly(~{ | |
system(glue::glue("du -s {.x}"), intern = T) |> | |
stringr::str_split_1("\\s+") |> | |
setNames(c("tamanho","diretorio")) | |
},NULL)) |> | |
dplyr::mutate(tamanho = as.numeric(tamanho)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ibge_ftp <- paste0("https://ftp.ibge.gov.br/Trabalho_e_Rendimento/", | |
"Pesquisa_Nacional_por_Amostra_de_Domicilios_anual/", | |
"microdados/") | |
r1 <- ibge_ftp |> | |
httr2::request() |> | |
httr2::req_perform() |> | |
httr2::resp_body_html() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Baixa e atualiza versão do chromedriver com a versão do chrome. | |
#' | |
#' @return OK! | |
#' @export | |
#' | |
compatibilizar_chromever <- function(){ | |
driver <- binman::list_versions("chromedriver") |> | |
unlist() |> | |
utils::tail(1) |> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Conta tokens de textos com base em modelos da OPENAI | |
#' | |
#' @param x Vetor de textos | |
#' @param modelo Modelo a ser utilizado. | |
#' | |
#' @details Para usar esta função você tem de ter instalado o pacote | |
#' tiktoken do Python, o qual será chamado via reticulate. | |
#' | |
#' @return Vetor com quantidade de tokens em cada texto. | |
#' @export |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
msql_colacao <- function(conn, schema = NULL, table = NULL, ...){ | |
dots <- rlang::ensyms(...) |> | |
purrr::map_chr(rlang::as_string) | |
### Verifica se as colunas existem | |
q <- glue::glue_sql("select top 0 * from {`schema`}.{`table`}", .con = conn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openai | |
import tiktoken | |
from scipy import spatial | |
import pandas as pd | |
df=pd.read_csv('./data/oscars.csv') | |
print(df.head()) | |
df=df.loc[df['year_ceremony'] == 2023] | |
df=df.dropna(subset=['film']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from zeep import Client | |
import xmltodict | |
import json | |
from dotenv import load_dotenv | |
import os | |
import getpass | |
def consultar_processo( | |
usuario= None, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from lxml import etree | |
from datetime import datetime | |
def tpu_get_data_ultima_versao(): | |
body = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sgt="https://www.cnj.jus.br/sgt/sgt_ws.php"> | |
<soapenv:Header/> | |
<soapenv:Body> | |
<sgt:getDataUltimaVersao/> | |
</soapenv:Body> |
NewerOlder