Skip to content

Instantly share code, notes, and snippets.

View FilipeChagasDev's full-sized avatar

Filipe Chagas FilipeChagasDev

View GitHub Profile
@FilipeChagasDev
FilipeChagasDev / crypto.py
Last active December 7, 2024 03:49
This module provides utilities for cryptographic operations, including HMAC-based message authentication and RSA encryption/decryption. It includes functions for generating and verifying HMAC signatures, as well as RSA key generation, encryption, and decryption.
'''
This module provides utilities for cryptographic operations, including HMAC-based message authentication and RSA
encryption/decryption. It includes functions for generating and verifying HMAC signatures, as well as RSA key
generation, encryption, and decryption. The module uses the `cryptography` library for RSA operations.
'''
import hmac
import hashlib
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives import serialization, hashes
@FilipeChagasDev
FilipeChagasDev / julia_regression.py
Last active November 23, 2023 19:02
This code is a Python implementation of the Julia Regression method for calculating the square root of a natural number.
def sqrt_julia_regression(x, first_trial_root=1):
"""
Function that calculates the square root of an natural number using the Julia Regression Method.
Params:
x (int) - Natural input number
first_trial_root (int) - First root to try
Return (int): natural root found or None
"""
current_root = first_trial_root
current_square = first_trial_root**2
@FilipeChagasDev
FilipeChagasDev / PluginProcessor.cpp
Created January 8, 2022 10:40
buggy plugin audio processor in Juce
/*
==============================================================================
This file contains the basic framework code for a JUCE plugin processor.
==============================================================================
*/
#include "PluginProcessor.h"
#include "PluginEditor.h"
@FilipeChagasDev
FilipeChagasDev / ccw_sort.c
Created October 24, 2021 23:58
Counter clockwise point sorting with C
/*
Author: Filipe Chagas
filipe.ferraz0@gmail.com
*/
#include "ccw_sort.h"
#include <math.h>
#define ABS(v) ((v >= 0) ? v : -v)
#define PI 3.14159265359
@FilipeChagasDev
FilipeChagasDev / make_dir_tree.py
Created March 17, 2021 16:01
Function that creates a directory tree described in a dictionary
'''
By Filipe Chagas
'''
import os
from os.path import join as pjoin
from typing import *
def make_dir_tree(dir_tree: Union[dict, list], root: str = '', verbose: bool = False):
"""Creates a directory tree described in a dictionary.
def buscar (cor, e_inicial):
fila = [e_inicial]
verificados = []
while len(fila) > 0:
#Obter objeto da fila para verificacao
e_obtido = fila.pop()
verificados.append(e_obtido)
#Verificar objeto
def buscar (e_inicial, cor):
fila = [e_inicial]
while len(fila) > 0:
#Obter um objeto da fila
e_obtido = fila.pop()
if e_obtido.cor == cor:
#Encontrado!!
return e_obtido
class Elemento:
def __init__(self, cor):
self.cor = cor
self.adjacencias = []
#Elementos do grafo
A = Elemento('Cinza')
B = Elemento('Roza')
C = Elemento('Vermelho')
D = Elemento('Verde')
def buscar(nodo, nome):
if nodo <> None:
if nodo.nome == nome:
return nodo
else:
recebido = buscar(nodo.menor, nome)
if recebido <> None:
return recebido
else:
recebido = buscar(nodo.maior, nome)
def percorrer_arvore(nodo):
if nodo <> None:
percorrer_arvore(nodo.menor)
nodo.imprimir()
percorrer_arvore(nodo.maior)