Skip to content

Instantly share code, notes, and snippets.

@Alrecenk
Alrecenk / fastexp.java
Last active August 12, 2022 23:05
Very fast accurate approximation to Math.exp in java using floating point bit hacks.
/* fast floating point exp function
* must initialize table with buildexptable before using
Based on
A Fast, Compact Approximation of the Exponential Function
Nicol N. Schraudolph 1999
Adapted to single precision to improve speed and added adjustment table to improve accuracy.
Alrecenk 2014
@umezawatakeshi
umezawatakeshi / utf8codepoint.cpp
Last active November 28, 2021 17:00
count UTF-8 codepoint
#include <functional>
#include <utility>
#include <algorithm>
#define NOMINMAX
#include <Windows.h>
#include <intrin.h>
#include <cstdlib>
const double clock_cycle = 3.4 * 1000 * 1000 * 1000; // Core i7-4770 @3.4GHz
@jacobemcken
jacobemcken / java.sh
Created December 21, 2023 18:49
Script helping to install newer Java versions on Netlify required by Shadow-cljs
#!/bin/bash
CACHE_DIR=$NETLIFY_BUILD_BASE/cache
rm -rf $HOME/.m2/
cp -a $NETLIFY_BUILD_BASE/cache/.m2/ $HOME/.m2/
JAVA_DOWNLOAD_URL="https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_linux-x64_bin.tar.gz"
JAVA_RELEASE=jdk-17.0.2 # Must match directory inside archive in JAVA_DOWNLOAD_URL
currentver="$(java -version 2>&1 |head -n1 | cut -d'"' -f2 |cut -d'.' -f1)"