Skip to content

Instantly share code, notes, and snippets.

View Dombo's full-sized avatar

Dom Hutton Dombo

  • Hashicorp
  • Netherlands
View GitHub Profile
WITH longrunners AS (
SELECT pid, age(query_start, clock_timestamp()), query_start, usename, query
FROM pg_stat_activity
WHERE
now() - query_start > '3 minutes'::interval
AND
query NOT ILIKE '%vacuum%'
ORDER BY query_start desc
)
SELECT pg_cancel_backend(pid)
@Dombo
Dombo / async_chains_serially.js
Last active October 11, 2018 05:02
Handle a collection of asynchronous actions, serially & blocking, with a consistent API regardless of what happens during execution.
# <3 leon
const Objects = [{}, {}, {}];
const PromiseBuilders = Objects.map(o => () => promise(o))
const serial = ([first, ..rest], results = []) =>
first === undefined
? Promise.resolve(results)
: first()
@Dombo
Dombo / Gödel numbering pyth-seudocode
Created October 13, 2015 18:34
An interesting homework problem I got - algorithms from the 19th & 3rd century in pseudocode
Pyth-seudocode time!
erasto(n): // circa 240 BC haha
a[1] := 0
for i := 2 to n do a[i] := 1
p := 2
while p^2 < n do