This file contains 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
// https://www.reddit.com/r/RNG/comments/19a2q24/collatzweyl_generators/?utm_source=share&utm_medium=web2x&context=3 | |
// $ gcc -Wall -O3 Collatz-Weyl.c -o Collatz-Weyl | |
// $ ./Collatz-Weyl | pv > /dev/null <-- 650MiB/s on 2018 Zeon VM | |
// compared with 400MiB/s for ChaCha20 | |
#include <stdio.h> | |
#include <assert.h> | |
static __uint128_t c[4] = {0, 0, 0, 0}; // c[0] must be odd |
This file contains 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
/* | |
https://math.stackexchange.com/a/3306 | |
A simple (practical, low-computation) approach to choosing among three options with | |
equal probability exploits the fact that in a run of independent flips of an unbiased | |
coin, the chance of encountering THT before TTH occurs is 1/3. So: | |
Flip a coin repeatedly, keeping track of the last three outcomes. (Save time, if you | |
like, by assuming the first flip was T and proceeding from there.) |
This file contains 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
int compare (const void * a, const void * b) | |
{ | |
if (*(double*)a > *(double*)b) return 1; | |
else if (*(double*)a < *(double*)b) return -1; | |
else return 0; | |
} |
This file contains 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
int compare (const void * a, const void * b) | |
{ | |
if (*(double*)a > *(double*)b) return 1; | |
else if (*(double*)a < *(double*)b) return -1; | |
else return 0; | |
} |
This file contains 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
int compare (const void * a, const void * b) | |
{ | |
if (*(double*)a > *(double*)b) return 1; | |
else if (*(double*)a < *(double*)b) return -1; | |
else return 0; | |
} |
This file contains 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <assert.h> | |
// [email protected] February 2021 | |
// tests the 64-bit hardware efficient generation of 1-in-3 choices. | |
// uses the fact that 2^65 is just ~1% larger than 3^41 | |
// whereas 2^2 is 25% larger than 3^1 |
This file contains 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
CC = gcc | |
RM = rm -f | |
INSTRUMENT_FOR_PROMETHEUS := false | |
ifeq ($(INSTRUMENT_FOR_PROMETHEUS),true) | |
CFLAGS = -Wall -DINSTRUMENT_FOR_PROMETHEUS | |
LIBS = -lbcm2835 -lprom -lpromhttp -lmicrohttpd | |
else | |
CFLAGS = -Wall |
This file contains 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
/* | |
Deprecated, see https://gist.github.com/alwynallan/1c13096c4cd675f38405702e89e0c536 | |
If you have to use software PWM, it's still here. | |
*/ | |
This file contains 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
{ | |
"servers":[ | |
{"name":"pool.ntp.org"}, | |
{"name":"asia.pool.ntp.org"}, | |
{"name":"europe.pool.ntp.org"}, | |
{"name":"north-america.pool.ntp.org"}, | |
{"name":"oceania.pool.ntp.org"}, | |
{"name":"south-america.pool.ntp.org"} | |
], | |
"regions":[ |
This file contains 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
var xmlhttp = new XMLHttpRequest(); | |
var url = "http://apa.hopto.org/tz_data.json"; // do we need the domain?? | |
var tzArr; | |
xmlhttp.onreadystatechange = function() { | |
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { | |
tzArr = JSON.parse(xmlhttp.responseText); | |
populateOptions(tzArr); | |
} | |
}; |