Skip to content

Instantly share code, notes, and snippets.

View AmrSaber's full-sized avatar

Amr Saber AmrSaber

View GitHub Profile
@AmrSaber
AmrSaber / de_bruijn.rs
Created March 7, 2023 17:05
Generating a de Bruijn sequence (in Rust)
fn main() {
let args: Vec<_> = std::env::args().collect();
if args.len() < 4 {
eprintln!("You must enter the alphabet and the sequence size");
return;
}
let alphabet = &args[2];
let count = args[3]
@AmrSaber
AmrSaber / split-string.go
Last active March 2, 2023 11:39
Meaningful text splitting by chunk size (in Golang)
package main
import (
"flag"
"fmt"
"io"
"math"
"os"
"strings"
"time"
@AmrSaber
AmrSaber / SecureRandomFloat.js
Last active April 11, 2020 19:36
JS Secure Random Float
const crypto = require('crypto')
function getSecureFloat() {
// Generate 7 random bytes
const bytes = crypto.randomBytes(7);
// Shift 5 bits from first bytes by 5 to the right
let randomValue = (bytes[0] % (2 ** 5)) / (2 ** 5);
// For each of the following 6 bytes, add its value and shift it 8 bits to the right