Skip to content

Instantly share code, notes, and snippets.

@fanf2
fanf2 / float.c
Last active July 15, 2022 12:48
a hg64 histogram key conversion experiment
/*
* experiments converting uint64_t to a low-precision floating point
* format, KEYBITS wide with 6 bits of exponent (enough to cover the
* range of uint64_t) and MANBITS bits of mantissa.
*
* My original code used CLZ, but I wanted to see if I could get the
* hardware to convert to floating point for me, and extract the bits
* I need.
*
* The main problem was floating point rounding: the shift in
/*
* Tony Finch's CSS fixes for DuckDuckGo
* to be used with the Stylus browser extension
*/
* {
min-width: 0 !important;
border-radius: 0px !important;
box-shadow: none !important;
}
@fanf2
fanf2 / complex.rs
Last active December 6, 2020 23:13
complex numbers with vanishing zeroes
use std::ops::{Add, Mul, Neg, Sub};
pub type Num = f64;
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Zero;
impl From<Zero> for Num {
fn from(_: Zero) -> Num {
0.0
@fanf2
fanf2 / info.sh
Created August 17, 2016 13:40
A Gnu info viewer based on cat and less
#!/bin/sh
try() {
file=$1
echo $file
if [ -f $file-1 -o -f $file-1.gz ]
then
# there must be a better way of doing this
gzip -fdc `ls -f1 $file-* |
sed -e 's/.*\.info-\([0-9]*\)/\1 &/' |
comm -12 <( git ls-tree -r HEAD |
sed '/^[0-9]* commit /!d;s/.* //' |
sort
) <( git diff-tree --name-status -r HEAD devel |
sed 's/.* //' |
sort
)
#!/usr/bin/perl
use warnings;
use strict;
use re 'eval';
our $string_re = qr( " (?: [^"\\] | \\. )* " )x;
our $atom_re = qr( (?! zone \s+ | view \s+ )
[0-9A-Za-z!:._/-]+ )x;
our $stuff_re = qr( $string_re
### Keybase proof
I hereby claim:
* I am fanf2 on github.
* I am fanf (https://keybase.io/fanf) on keybase.
* I have a public key whose fingerprint is 9D2C 3C2F F2C4 A430 C90A C920 B1CD FDC8 2567 C99A
To claim this, I am signing this object: