Skip to content

Instantly share code, notes, and snippets.

View idrise's full-sized avatar

Idris Elliott idrise

View GitHub Profile
@idrise
idrise / gist:1022010472e40b5a2419052d87777b9b
Created December 23, 2024 16:07
CRC32 Learning Example
/**
* Builds a lookup table (256 elements) for fast CRC-32 calculations.
*
* The table is built using the standard polynomial 0xEDB88320 (also known as
* the 'reverse' polynomial used in the CRC-32 algorithm). Each of the 256
* possible byte values is processed to find the remainder when treated as
* input to the polynomial division used in CRC-32.
*/
function buildLookupCRC32LookupTable(): Uint32Array {
// Create a new 32-bit unsigned integer array of length 256.
@idrise
idrise / l.ts
Created October 20, 2024 13:21
/**
* Calculates the Damerau-Levenshtein distance between two strings.
*
* The Damerau-Levenshtein distance is a measure of the similarity between two strings,
* which considers the minimum number of operations (insertions, deletions, substitutions,
* and transpositions of two adjacent characters) required to change one string into the other.
*
* @param source - The first string.
* @param target - The second string.
* @param limit - An optional limit to the maximum distance calculated.
function check_package_manager() {
current_dir=$(pwd)
while [ "$(pwd)" != "/" ]; do
if [ -f "pnpm-lock.yaml" ]; then
if [ "${1}" != "pnpm" ]; then
echo "Looks like you're using the wrong package manager, partner!"
echo "It's pnpm time, cowboy."
cd "${current_dir}"
return 1
@echo off
echo Grab a cuppa! Here there be dependencies...
mkdir -p ~/.capicli/main
git clone git@github.com:guardian/capicli.git ~/.capicli/main
cd ~/.capicli/main
npm install
npm run build
npm link
@echo off
echo Grab a cuppa! Here there be dependencies...
git clone git@github.com:guardian/capicli.git ~/.capicli/main
cd ~/.capicli/main
npm install
npm run build
npm link
@idrise
idrise / install-powerline.sh
Last active November 14, 2020 23:27
Script : Installs Powerline Font on Mac OSX.
pushd /tmp
# clone
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
rm -rf fonts
popd
"C:\Program Files\Scan Tailor\scantailor-cli.exe" -v --margins=0 --layout=1 --deskew=auto --content-detection=normal --alignment-vertical=bottom --alignment-horizontal=center --white-margins=true --color-mode=black_and_white --dpi=600 --output-dpi=600 --despeckle=off --tiff-compression=lzw --start-filter=1 --end-filter=6 C:\input\ C:\output
sudo apt install libjpeg zlib libpng libtiff libboost
or
sudo apt install libjpeg-dev zlib1g-dev libpng-dev libtiff5-dev libboost-all-dev
sudo apt install qt5-default
sudo apt install cmake