Skip to content

Instantly share code, notes, and snippets.

View jjesusfilho's full-sized avatar
🏠
Working from home

José de Jesus Filho jjesusfilho

🏠
Working from home
View GitHub Profile
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()
@jjesusfilho
jjesusfilho / compatibilizar_chromever.R
Last active January 26, 2024 20:54
Compatibiliza o chromdriver com o google chrome
#' 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) |>
@jjesusfilho
jjesusfilho / openai_contar_tokens.R
Created January 10, 2024 17:16
Chama o tiktoken do python para contar os tokens.
#' 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
@jjesusfilho
jjesusfilho / msql_colacao.R
Last active December 18, 2023 20:28
Aplica colação ao SQL server para ignorar acentuação e caixa #'
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)
@jjesusfilho
jjesusfilho / Oscar_bot.py
Created November 24, 2023 16:30 — forked from janakiramm/Oscar_bot.py
Implementing RAG with OpenAI
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'])
@jjesusfilho
jjesusfilho / mni.py
Last active November 1, 2023 15:04
Consulta processo do tjsp via mni
from zeep import Client
import xmltodict
import json
from dotenv import load_dotenv
import os
import getpass
def consultar_processo(
usuario= None,
@jjesusfilho
jjesusfilho / get_data_ultima_versao_requests.py
Created August 27, 2023 13:53
TPUs com python requests e zeep.
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>
@jjesusfilho
jjesusfilho / python-zeep-example.md
Created August 20, 2023 23:02 — forked from FilBot3/python-zeep-example.md
Python Zeep SOAP Example Write Up

Python Zeep SOAP Client

First, we'll look at the SOAP URL and see what Prefixes, Global Elements, Global Types, Bindings, and Services are provided by the SOAP Service.

You can do this by running zeep as a CLI tool.

export WSDL_URL="http://www.dneonline.com/calculator.asmx?WSDL"
python -m zeep $WSDL_URL
@jjesusfilho
jjesusfilho / tjal_baixar_cpopg_par.R
Created August 2, 2023 18:06
Baixa processos do TJAL pelo nome das partes
tjal_baixar_cpopg_par <- function(consulta = NULL,
parametro = NULL,
distribuidor = "-1",
diretorio = ".") {
httr::set_config(httr::config(ssl_verifypeer = FALSE))
url1<-"https://www2.tjal.jus.br/cpopg/search.do?"
url2<- "https://www2.tjal.jus.br/cpopg/trocarPagina.do?"
@jjesusfilho
jjesusfilho / gist:324864d2dd2ab0c6686f39ab1ae11391
Created June 26, 2023 10:19
Tutorial para instalar o airflow
https://towardsdatascience.com/how-to-run-apache-airflow-as-daemon-using-linux-systemd-63a1d85f9702