Skip to content

Instantly share code, notes, and snippets.

@Lohann
Lohann / settings.json
Last active October 9, 2025 23:27
Rust VSCode Settings
{
"editor.inlineSuggest.enabled": true,
"editor.semanticHighlighting.enabled": true,
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer"
},
"rust-analyzer.check.command": "clippy",
"rust-analyzer.check.extraArgs": [
"--",
"-Dwarnings",
#define SQLITE_ENABLE_NORMALIZE
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <openssl/rand.h>
#include <pthread.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <stdio.h>
@Lohann
Lohann / itoa.c
Last active August 21, 2025 21:04
// Implementation of itoa (int to ASCII), which converts an 64-bit to decimal string.
//
// Based on Tigran Hayrapetyan Algorithm: `34% faster Integer to String conversion algorithm`
// ref: https://towardsdatascience.com/34-faster-integer-to-string-conversion-algorithm-c72453d25352/
//
// @author Lohann Paterno Coutinho Ferreira <[email protected]>
#include "itoa.h"
// lookup table of powers of 10, used by `ilog10` and `itoa`.
static uint64_t const powers_of10[20] = {
@Lohann
Lohann / heaps_algorithm.rs
Last active August 16, 2025 04:45
Heap's Permutation Algorithm in Rust
// Author: Lohann Paterno Coutinho Ferreira
//
// Heap's Permutation Algorithm
/// Move all duplicated elements to the end of the array.
/// Returns the number of distinct elements.
fn move_duplicated<T: PartialEq>(array: &mut [T]) -> usize {
let mut n = array.len();
let mut i = 0;
while i < n {
/*
* @author Lohann Paterno Coutinho Ferreira <[email protected]>
*
* Example on how to add numbers using only bitwise operators:
* - xor: ^
* - and: &
* - not: ~
* - or: |
*
* # Motivation
// Script auxiliar para fazer a chamada automaticamente no WebAluno a partir do
// arquivo `.csv` gerado pelo Microsoft Teams, para utilizar o script basta logar
// no WebAluno e abrir a chamada, então basta copiar e colar a função abaixo no
// console do navegador, o script então:
// 1 - Irá pedir para vc abrir o Report CSV gerado pelo Microsoft Teams.
// 2 - Irá extrair os alunos automaticamente da primeira coluna do CSV.
// 3 - Irá marcar as checkbox dos alunos que faltaram, e desmarcar dos que vieram.
// 4 - Os nomes que estavam no Teams, mas não na lista de chamada serão reportados no final da execuçãp.
// Aproveite!
//
// WasteGas
// This contract spends 100% of the gas you provide to it, always, and return success.
// @author Lohann Paterno Coutinho Ferreira <[email protected]>
//
JUMPDEST
PUSH1 52
GAS
GT
PUSH0
JUMPI
@Lohann
Lohann / Cargo.toml
Last active November 5, 2024 22:20
WebAssembly Base Project
[package]
name = "rust-wasm-minimal"
version = "0.1.0"
edition = "2021"
[lib]
name = "rust_wasm_minimal"
crate-type = ["cdylib"]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
[package]
name = "wasm-executor"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow = "1.0.91"
wasmtime = { version = "26.0.0", default-features = false, features = ["cache", "cranelift", "wat", "parallel-compilation", "pooling-allocator"] }
// -- package.json --
// "dependencies": {
// "wabt": "^1.0.36"
// }
/**
* The WAT code (WebAssembly Text Format) which must be compiled to WASM (binary).
* - Library used to compile: https://github.com/WebAssembly/wabt
* - WebAssembly instructions set: https://webassembly.github.io/spec/core/text/instructions.html
*/