This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Algorithm that performs a branchless 4-word right shifting, which shifts | |
| // 256bit numbers in 64bit systems or 128bit in 32bit systems. | |
| // | |
| // @author Lohann Paterno Coutinho Ferreira <developer@lohann.dev> | |
| #[cfg(target_pointer_width = "64")] | |
| pub type Limb = u64; | |
| #[cfg(target_pointer_width = "32")] | |
| pub type Limb = u32; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Implementation of itoa (integer to ASCII), which converts an 64-bit to decimal string. | |
| // | |
| // Rust's `format!("{num}")` requires heap `alloc` and bloats the code with panic messages, | |
| // I needed something simpler for support basic tracing in Wasm targets. | |
| // This implementation focus on smaller binary instead raw performance, ideal for | |
| // no_std environements like wasm32-unknown-unknown or embeeded. | |
| // | |
| // @author Lohann Paterno Coutinho Ferreira <developer@lohann.dev> | |
| #[unsafe(no_mangle)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # single quote arguments using only pure shell, this | |
| # script doesn't require any external programn such as `sed`. | |
| quote () | |
| { | |
| test $# -gt 0 || return 0 | |
| while test $# -gt 1 | |
| do | |
| quote "$1" || return $? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| set -eu | |
| # This script prepares a macOS virtual machine for SSH-Only access. | |
| # it is based on https://github.com/sickcodes/osx-optimizer | |
| # Safety check to prevent executing this script in the HOST machine | |
| # instead the macOS virtual machine. | |
| VM_USERNAME='<VM-USERNAME-HERE>' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| # Prevent locale nonsense from breaking basic text processing. | |
| LC_ALL=C | |
| export LC_ALL | |
| # display a message then exit | |
| abort() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Prints recursively what is the current shell emulator. | |
| pid=$$ | |
| printf 'pid="%s"\n' "${pid}" | |
| test "${pid}" = '1' && exit 1 | |
| die(){ | |
| echo "${1}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "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", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 <developer@lohann.dev> | |
| #include "itoa.h" | |
| // lookup table of powers of 10, used by `ilog10` and `itoa`. | |
| static uint64_t const powers_of10[20] = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 { |
NewerOlder