Skip to content

Instantly share code, notes, and snippets.

@tommystanton
tommystanton / ed
Created September 17, 2012 18:49
GNU ed + GNU readline
#!/bin/sh
# Try to add GNU readline support to GNU ed
hash rlwrap 2>&-
if (( $? == 0 )); then
exec /usr/bin/rlwrap /bin/ed "$@"
else
exec /bin/ed "$@"
fi
@orlp
orlp / ipow.c
Last active October 1, 2025 15:06
int64_t ipow(int64_t base, uint8_t exp) {
static const uint8_t highest_bit_set[] = {
0, 1, 2, 2, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 255, // anything past 63 is a guaranteed overflow with base > 1