Skip to content

Instantly share code, notes, and snippets.

View dbaynard's full-sized avatar

David Baynard dbaynard

  • Fore Stun Ltd
View GitHub Profile
@dbaynard
dbaynard / pg16-exts-failures
Last active October 4, 2023 22:13
Build failures (and successes) for postgres extensions
> for i in 'age' 'apache_datasketches' 'cstore_fdw' 'jsonb_deep_sum' 'override' 'overrideDerivation' 'periods' 'pg_auto_failover' 'pg_bigm' 'pg_cron' 'pg_ed25519' 'pg_hint_plan' 'pg_hll' 'pg_ivm' 'pg_net' 'pg_partman' 'pg_rational' 'pg_relusage' 'pg_repack' 'pg_safeupdate' 'pg_similarity' 'pg_topn' 'pgaudit' 'pgjwt' 'pgroonga' 'pgrouting' 'pgsql-http' 'pgtap' 'pgvector' 'pipelinedb' 'plpgsql_check' 'plr' 'plv8' 'postgis' 'promscale_extension' 'recurseForDerivations' 'repmgr' 'rum' 'smlar' 'tds_fdw' 'temporal_tables' 'timescaledb' 'timescaledb-apache' 'timescaledb_toolkit' 'tsearch_extras' 'wal2json'; do
nix build -L "n#postgresql15Packages.${i}" && print -l -- "\nBuilt ${i} (15)\n"
nix build -L "n#postgresql16Packages.${i}" && print -l -- "\nBuilt ${i} (16)\n"
done
error:
… in the condition of the assert statement
at /nix/store/i6hq63805y784dml4j8pgkrz3lryxzld-source/lib/customisation.nix:222:17:
221| in commonAttrs // {
@dbaynard
dbaynard / video-toggle.js
Created November 25, 2022 17:33
Toggle double video playback rate
// ==UserScript==
// @name Toggle double playback rate
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Sets video playback rate to (3 - current rate)
// @author You
// @match *://*/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// @run-at context-menu
@dbaynard
dbaynard / to_csv.jq
Last active July 31, 2022 01:06
Convert json to csv with jq
def to_csv:
( [.[] | keys | .[]] | unique ) as $keys
| ( $keys | @csv )
, ( .[]
| . as $row
| reduce ($keys | .[]) as $key ([]; [.[], ($row | .["\($key)"])])
| @csv
);
def uniform_array_to_csv:
@dbaynard
dbaynard / job-pool.js
Last active March 16, 2022 23:13
JS Console bounded async
const applyAsync = (f, pool) => (x, i) =>
Promise.resolve(x)
.then((v) => new Promise((r) => pool.push({ i, v, r })))
.then(f);
const worker = (getTimeout) => (it, i) => {
const { done, value } = it.next();
if (done) return;
const { v, r } = value;
setTimeout(
@dbaynard
dbaynard / script.js
Created October 22, 2021 13:17
Convert CMS2021 schedule to local time
// ==UserScript==
// @name Convert CMS2021 Schedule to Local Time
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Convert CMS2021 schedule to local time
// @author David Baynard
// @match https://cms21.io/agenda/
// @icon https://www.google.com/s2/favicons?domain=cms21.io
// @grant none
// ==/UserScript==
@dbaynard
dbaynard / gist:523700a1a5bed1628fd817c833460c6e
Created June 23, 2021 15:06
Creating nixos lxc image for crostini
Install arch https://wiki.archlinux.org/title/Chrome_OS_devices/Crostini
lxc config set arch security.nesting true
Within arch, configure downloads
mkdir ~/Downloads && sudo mount -o bind /mnt/chromeos/MyFiles/Downloads ~/Downloads
Install nix (just use the standard multi-user nix installer)
Install lxd
Add user to group lxd
sudo systemctl enable lxd.service
logout cycle for arch
lxd init
@dbaynard
dbaynard / basket.js
Last active August 24, 2021 01:38
Show price changes in amazon basket or after adding item
// Paste into dev console
[...document.querySelectorAll(".a-list-item, .huc-v2-item-msg")].map(x => {
const lims = x.innerText.match(/from £([0-9.]+) to £([0-9.]+)/)?.slice(1,3);
if (!!lims) {
const p = lims[1] - lims[0];
const y = 100*p/lims[0];
return [p, ${p.toFixed(2)} (${y.toFixed(1)} %): ${x.innerText}`];
}
}).filter(x => !!x).sort((a,b) => b[0] - a[0]).forEach(([_,v]) => console.log(v));
@dbaynard
dbaynard / git-review.sh
Created February 11, 2019 16:19
Pull github PRs for review
#!/usr/bin/env zsh
#
# Review github PRs.
#
# This script makes reviewing github PRs simple. Supply the requester's branch
# in the form it is presented at the top of the PR on github (i.e. user:branch).
# This adds:
#
# - a new remote corresponding to the user, with only the PR branch
# - a new local branch (unless a branch with that name exists already, in
@dbaynard
dbaynard / jindosh.lhs
Created January 17, 2019 11:23
Jindosh
---
title: Jindosh puzzle
author: David Baynard
date: 16 Jan 2019
fontfamily: libertine
csl: chemical-engineering-science.csl
link-citations: true
abstract: |
...
@dbaynard
dbaynard / diagonal-span.hs
Last active December 17, 2018 22:19
A correct-by-construction AST representation of typographic tables, using diagonalization
-- |
-- Module : diagonal-span
-- Copyright : David Baynard 2018
-- License : BSD-3-Clause OR Apache-2.0
--
-- Maintainer : haskell@baynard.me
-- Stability : experimental
-- Portability : unknown
--
-- A proposal for a correct by construction abstract syntax tree for pandoc