Skip to content

Instantly share code, notes, and snippets.

View leo-aa88's full-sized avatar

Leonardo leo-aa88

View GitHub Profile
@leo-aa88
leo-aa88 / introducao_goroutines.md
Created February 2, 2025 18:28
Uma introdução fácil a goroutines

Uma introdução fácil a goroutines

Se você está começando a programar em Go, provavelmente já ouviu falar de goroutines. Mas o que são elas e como funcionam? Neste artigo, vamos explorar esse conceito fundamental da linguagem de forma simples e prática.

Começando com o básico

Vamos começar com um exemplo simples:

package main
@leo-aa88
leo-aa88 / twoSum.md
Last active January 29, 2025 19:02
O(N) and O(N²) example

Two Sum Problem – O(N²) vs. O(N) Using HashMap

The Two Sum problem is a classic example where a brute-force solution runs in O(N²), but we can optimize it to O(N) using a hashmap.

1. JavaScript Implementation

Brute-Force Solution (O(N²))

function twoSumBruteForce(arr, target) {
    for (let i = 0; i < arr.length; i++) {
@leo-aa88
leo-aa88 / bluetoothctl_guide.md
Created January 12, 2025 01:59
bluetoothctl guide

Guide to Connecting to a Bluetooth Device using bluetoothctl

This guide walks you through the process of connecting to a Bluetooth device on a Linux system using the bluetoothctl command-line tool. It covers initial setup, scanning, pairing, and connecting procedures, along with troubleshooting tips.

Prerequisites

  • A Linux distribution with Bluetooth support (e.g., Arch Linux).
  • The bluez package installed, which provides bluetoothctl and related utilities.
  • A working Bluetooth adapter installed on your system.
  • Sudo privileges to execute commands that require root access.
@leo-aa88
leo-aa88 / brainrot.txt
Created October 25, 2024 22:38
brainrot
skibidi gyatt rizz only in ohio duke dennis did you pray today livvy dunne rizzing up baby gronk sussy imposter pibby glitch in real life sigma alpha omega male grindset andrew tate goon cave freddy fazbear colleen ballinger smurf cat vs strawberry elephant blud dawg shmlawg ishowspeed a whole bunch of turbulence ambatukam bro really thinks he's carti literally hitting the griddy the ocky way kai cenat fanum tax garten of banban no edging in class not the mosquito again bussing axel in harlem whopper whopper whopper whopper 1 2 buckle my shoe goofy ahh aiden ross sin city monday left me broken quirked up white boy busting it down sexual style goated with the sauce john pork grimace shake kiki do you love me huggy wuggy nathaniel b lightskin stare biggest bird omar the referee amogus uncanny wholesome reddit chungus keanu reeves pizza tower zesty poggers kumalala savesta quandale dingle glizzy rose toy ankha zone thug shaker morbin time dj khaled sisyphus oceangate shadow wizard money gang ayo the pizza here P
@leo-aa88
leo-aa88 / gist:3df8f4e6ec7cd46a67a4a9513bfb49e8
Created August 14, 2024 04:59
Generate project tree (go)
exa --tree -I vendor .
@leo-aa88
leo-aa88 / install_docker_arch.sh
Created August 9, 2024 04:03
Install docker in arch linux
#!/bin/bash
sudo pacman -S docker
systemctl start docker.service
sudo docker info
sudo usermod -aG docker $USER
docker run hello-world
@leo-aa88
leo-aa88 / functional.cpp
Created July 19, 2024 03:45
Functional C++ examples
#include <iostream>
#include <cassert>
#include <functional>
#include <algorithm>
class Callable {
public:
int operator()(int x) { return x + 1; };
};
@leo-aa88
leo-aa88 / heart.py
Created June 12, 2024 20:31
Heart shape in Python (matplotlib)
import numpy as np
import matplotlib.pyplot as plt
# Define the implicit function for the heart shape
def heart_shape(x, y):
return (x**2 + y**2 - 1)**3 - x**2 * y**3
# Create a grid of x, y points
x = np.linspace(-1.5, 1.5, 400)
y = np.linspace(-1.5, 1.5, 400)
@leo-aa88
leo-aa88 / guaiba.py
Created May 12, 2024 20:14
Study of correlation between average yearly sunspots and Guaíba river maximum heights
import matplotlib
import pandas as pd
from scipy.stats import pearsonr
from sklearn.preprocessing import MinMaxScaler
matplotlib.use('Qt5Agg') # Or another interactive backend such as 'Qt5Agg', 'GTK3Agg', etc.
import matplotlib.pyplot as plt
# Create a time index
@leo-aa88
leo-aa88 / main.py
Created May 7, 2024 02:09
Return period estimation RS flood 2024
# Fitting a Gumbel distribution using scipy's built-in functions for simplicity and stability
from scipy.stats import gumbel_r
# Provided water heights including the latest years up to 2024
water_heights = [
2.60, 1.48, 0.98, 1.99, 1.45, 1.51, 2.50, 1.53, 2.00, 1.69, 1.52, 1.34, 2.05, 2.13, 1.19,
2.60, 1.91, 1.78, 0.98, 1.49, 2.21, 1.60, 1.58, 1.68, 1.75, 1.61, 1.31, 2.60, 1.56, 3.20,
2.05, 2.35, 1.70, 1.84, 1.34, 1.70, 1.64, 3.24, 2.51, 1.43, 1.60, 2.24, 4.75, 2.33, 1.60,
1.90, 1.26, 1.55, 1.67, 1.68, 1.71, 1.91, 2.10, 2.06, 2.52, 2.91, 1.80, 2.32, 2.08, 2.00,
1.99, 1.77, 2.16, 1.25, 2.67, 1.73, 2.72, 2.61, 3.13, 1.18, 1.36, 1.71, 1.72, 2.21, 1.93,