Skip to content

Instantly share code, notes, and snippets.

View h5law's full-sized avatar

h5law h5law

View GitHub Profile
@h5law
h5law / fib.go
Created May 10, 2024 16:57
A series of functions for computing the nth fibonacci number
// Package main provides numerous implementations of functions for calculating
// the nth Fibonacci number - detailing their time and space complexities as
// well as their limitations on how large of n they can actually compute.
// Playground link: https://go.dev/play/p/mW_-C9mRr5u
package main
import (
"fmt"
"math"
"math/big"
@h5law
h5law / solana_compat.py
Created January 4, 2024 22:34
Python program to check whether a Rust crate and its dependencies can be used in Solana Programs
import os
# List of modules to check for no access and limited access
no_access_modules = [
"rand",
"std::fs",
"std::net",
"std::future",
"std::process",
"std::sync",
@h5law
h5law / cursorsort.go
Last active November 27, 2023 22:12
CursorSort - A QuickSort implementation using cursor based partitioning
// quicksort sorts in place the given slice by first finding
// a correctly placed pivot point and then recursively sorting
// the subarrays left and right of the pivot elements
// go.dev/play run this code: https://go.dev/play/p/9SJRhamZO_Q
func quicksort(array []int) []int {
if len(array) <= 1 {
return array
}
// Choose the initial cursors as the first and last indexes
c1 := 0
@h5law
h5law / pokt-key-converter.go
Created May 23, 2023 09:51
Simple CLI tool to convert V0 to V1 keys
package main
import (
"crypto/aes"
"crypto/cipher"
crand "crypto/rand"
"encoding/base64"
"encoding/hex"
"encoding/json"
"errors"
@h5law
h5law / cfrac.go
Created December 13, 2022 15:57
CFRAC and SQUFOF methods to completely factorise any number into its prime roots. [SLOW AFTER 30+ digits]
package main
import (
"fmt"
"log"
"math/big"
"os"
"time"
)
@h5law
h5law / primes.go
Last active December 3, 2023 23:13
Useful tools around generating and checking prime numbers and factorising integers
package main
import (
"fmt"
"math"
"math/big"
"math/rand"
"sort"
"time"
)
@h5law
h5law / shiftCipher.js
Last active March 25, 2022 19:16
Simple alphabet shift that cycles through latin alphabet only.
const range = (size, startAt = 0) => {
return [...Array(size).keys()].map(i => i + startAt);
};
const includedIn = (v, ...arrays) => {
let arr = [];
for (let i = 0; i < arrays.length; i++) {
if (arrays[i].includes(v)) {
arr.push(arrays[i]);
}