Skip to content

Instantly share code, notes, and snippets.

View guissalustiano's full-sized avatar
📚
Studing and building stuff

Guilherme Salustiano guissalustiano

📚
Studing and building stuff
View GitHub Profile
@guissalustiano
guissalustiano / gtag.diff
Last active May 10, 2024 21:30
Add google analytics 4 (gtag) in liveview
diff --git a/assets/js/app.js b/assets/js/app.js
index ad4168c..74b2716 100644
--- a/assets/js/app.js
+++ b/assets/js/app.js
@@ -32,7 +32,20 @@ let liveSocket = new LiveSocket("/live", Socket, {
// Show progress bar on live navigation and form submits
topbar.config({barColors: {0: "#29d"}, shadowColor: "rgba(0, 0, 0, .3)"})
window.addEventListener("phx:page-loading-start", _info => topbar.show(300))
-window.addEventListener("phx:page-loading-stop", _info => topbar.hide())
+window.addEventListener("phx:page-loading-stop", info => {
@guissalustiano
guissalustiano / chunkedBy.kt
Last active January 8, 2024 16:01
Naive `Iterable<T>.chunkedBy` implemention to Kotlin
inline fun <T> Iterable<T>.chunkedBy(
predicate: (T) -> Boolean
): List<List<T>> {
val iterator = this.iterator()
if (!iterator.hasNext()) {
return emptyList()
}
var lastElem = iterator.next()
var lastList = mutableListOf(lastElem)
# Based in https://github.com/cuducos/chunk
from asyncio import Semaphore, gather, run
import httpx
from loguru import logger
url = "https://dadosabertos.rfb.gov.br/CNPJ/Empresas1.zip"
default_chunk_size = 2**20 # 1MB
# DefaultMaxRetries sets the maximum download attempt for each chunk
@guissalustiano
guissalustiano / copy-of-atividademapreduce-1.ipynb
Last active July 25, 2023 23:26
AtividadeMapReduce-1.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
from math import ceil
from sympy import Symbol
from prettytable import PrettyTable
# [a0, a1, a2, ...]
k = Symbol('k')
# coef = [1, 2, 3, 4, 5]
coef = [1, 8, 32, k]
@guissalustiano
guissalustiano / test_numerico.py
Created January 27, 2022 11:21
Testes para o EP1 de numerico da Comp EPUSP
import numpy as np
from numpy import isclose
from ex1 import eig_pot
from ex2 import crit_sassenfeld, solve_sor, eig_potinv
def assertVector(a, b, **kwargs):
for exp, act in zip(a, b):
assert isclose(exp, act, **kwargs)
@guissalustiano
guissalustiano / etl_ans.py
Created January 21, 2022 00:26
extract data from http://ftp.dadosabertos.ans.gov.br and save in s3
from datetime import datetime
from ftputil import FTPHost
import tempfile
import awswrangler as wr
import zipfile
from io import BytesIO
import pandas as pd
host = FTPHost('ftp.dadosabertos.ans.gov.br', 'anonymous')
BUCKET_NAME = 'vidi-gift'
input: '$11#1#'
blank: ' '
start state: start
table:
start:
$: {R: soma1}
soma1:
1: {write: X, R: procuraBranco1}
'#': {R: soma2}
procuraBranco1:
@guissalustiano
guissalustiano / sisprog_tm.yml
Last active January 11, 2022 21:44
Maquina de turing para validar 0^n 1^n | n > 0
# use in https://turingmachine.io/
input: '0111' # try 1100
blank: ' '
start state: passo2
synonyms:
accept: {R: accept}
reject: {R: reject}
table:
DEBUG::Isso é uma log de debug
INFO::Isso é uma log de info
WARNING::Isso é uma log de warning
ERROR::Isso é uma log de erro
DEBUG::Chamado em root