Skip to content

Instantly share code, notes, and snippets.

-- this role will own all the objects
create role appowner;
create schema app authorization appowner;
-- this is the admin group, which grants the admins the ability to
-- adopt the owner role for admin tasks. The noinherit means that the
-- admins don't get any other permissions from the owner.
create role appadmin noinherit in role appowner;
/*
* vectorized (requires SSSE3) implementation of binary to decimal conversion.
* This was mainly an intellectual exercise, any performance gain over methods
* that do 2-digit conversions with lookup table are not worth the effort.
*
* Currently works with clang but can be adapted to gcc.
*/
#include <stdint.h>
#include <stdbool.h>
@RhodiumToad
RhodiumToad / census2020.sql
Created May 7, 2021 19:44
2020 US census apportionment
--
create table states_orig
(
state text primary key,
pop integer not null,
reps integer,
change integer
);
comment on table states_orig is 'Original data from census.gov';
(define-module (gentst)
#:use-module (oop goops)
#:use-module (gentst1)
#:use-module (gentst2)
#:export (test)
#:re-export (foo)
#:duplicates (merge-generics))
akren:~ % guile3 -q
GNU Guile 3.0.7
scheme@(guile-user)> (load "tst.scm")
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /home/andrew/tst.scm
WARNING: (gentst): `foo' imported from both (gentst1) and (gentst2)
;;; compiled /home/andrew/.cache/guile/ccache/3.0-LE-8-4.5/home/andrew/tst.scm.go
#<<generic> foo (1)>ice-9/boot-9.scm:1685:16: In procedure raise-exception:
@RhodiumToad
RhodiumToad / ryu.lua
Created June 22, 2023 01:29
Translation of Ryu float-to-string algorithm into Lua
--
--[[
ryu.d2string(d) -- convert float number d to shortest-exact string
As this code stands, it will produce output only in exponential
notation (e.g. "1e+00" rather than "1"). IEEE format is required.
It is an error to pass in an integer rather than a float.