Skip to content

Instantly share code, notes, and snippets.

View GGontijo's full-sized avatar
💭
Escovando bits..

Dercilio GGontijo

💭
Escovando bits..
View GitHub Profile
@GGontijo
GGontijo / deploy.py
Last active September 16, 2024 20:33
webhook deploy
from fastapi import FastAPI, Request, HTTPException
from pydantic import BaseModel
import os
import requests
app = FastAPI()
TELEGRAM_BOT_TOKEN = ""
TELEGRAM_CHAT_ID = ""
@GGontijo
GGontijo / filter_valid_columns.py
Created September 6, 2024 20:51
Filtrar propriedades validas em tabela para uso no sqlalchemy
from sqlalchemy import Table
from sqlalchemy.orm import class_mapper
def filtrar_colunas_validas(data, table):
valid_columns = set(table.columns.keys())
return {key: value for key, value in data.items() if key in valid_columns}
# Exemplo de uso
filtered_data = filter_valid_columns(viagem.model_dump(), viagem_cif_table)
stmt_viagem = insert(viagem_cif_table).values(filtered_data)
@GGontijo
GGontijo / token_manager.py
Created September 5, 2024 11:41
Oauth2 Token Manager
from contextlib import contextmanager
import time
from requests_oauthlib import OAuth2Session
from oauthlib.oauth2 import BackendApplicationClient
class TokenManager:
def __init__(self, client_id, client_secret, token_url, scopes):
self.client_id = client_id
self.client_secret = client_secret
self.token_url = token_url
@GGontijo
GGontijo / boleto.py
Created August 29, 2024 19:49
validar boleto e doc de arrecadação
# AUTHOR https://github.com/viniciusccosta/ClipBarcode/blob/master/clipbarcode/digito_verificador.py
# =============================================================================
import re
from abc import ABC, abstractmethod
from decimal import Decimal
from .datetime_tools import calculate_date
from .digito_verificador import mod10, mod11
@GGontijo
GGontijo / taskTimeKeep.js
Created August 8, 2024 13:51
Obsidian sprint tasks template
<%*
function getMonday(d) {
d = new Date(d);
var day = d.getDay(),
diff = d.getDate() - day + (day == 0 ? -6 : 1); // ajustar quando o dia for domingo
return new Date(d.setDate(diff));
}
function formatDate(date) {
let dd = date.getDate();
@GGontijo
GGontijo / office_client.py
Created June 25, 2024 20:14
Office365EmailClient V2.0
import requests
import json
import time
class Office365EmailClient:
def __init__(self, client_id: str, client_secret: str, tenant_id: str):
self.client_id = client_id
self.client_secret = client_secret
self.tenant_id = tenant_id
self.token = None
@GGontijo
GGontijo / token.py
Created June 25, 2024 13:51
validate jwt fields from microsoft entra id
import time
import jwt
from fastapi import Depends, HTTPException, Response, status
from fastapi.security import OAuth2PasswordBearer
from helpers.config_helper import Config
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
class OAuth2TokenValidation:
def __init__(self):
@GGontijo
GGontijo / Dockerfile
Created March 8, 2024 11:16
Dockerfile acetto-ubuntu-vnc-xfce-chrome-edge-nodejs
FROM accetto/ubuntu-vnc-xfce-g3
USER 0
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt update \
&& apt install -y wget gnupg2 \
&& rm -rf /var/lib/apt/lists/*
@GGontijo
GGontijo / commands
Created March 6, 2024 14:10
Allow Google Chrome / Microsoft Edge to run as root in linux adding --no-sandbox flag to it's launchers
sed -i -e 's@Exec=/usr/bin/microsoft-edge-dev %U@Exec=/usr/bin/microsoft-edge-dev %U --no-sandbox@g' /usr/share/applications/microsoft-edge-dev.desktop
sed -i -e 's@Exec=/usr/bin/google-chrome-stable %U@Exec=/usr/bin/google-chrome-stable %U --no-sandbox@g' /usr/share/applications/google-chrome.desktop
@GGontijo
GGontijo / cli_command
Created February 3, 2024 13:12
linux find text pattern in texts and write something in front of them
palavra="teste"; texto_adicional="deu certo"; for arquivo in teste*; do grep -q "$palavra" "$arquivo" && sed -i "/$palavra/ s/$/ $texto_adicional/" "$arquivo" && echo "Texto adicionado em $arquivo"; done