Skip to content

Instantly share code, notes, and snippets.

View wchargin's full-sized avatar

wchargin wchargin

View GitHub Profile
@wchargin
wchargin / pct.sh
Last active March 14, 2023 23:26
unix filter for computing percentiles / quantiles
#!/bin/sh
die() {
printf >&2 'fatal: %s\n'
exit 1
}
case $# in
0) die 'no percentiles provided' 'usage: pct P [P ...]' ;;
1) ps="$1" ;;
*)
\version "2.20.0"
\header {
title = "Torimichi"
subtitle = "(second half, from 2:30 onward)"
composer = "Coddneck"
arranger = "arr. wchargin"
tagline = ##f
}
SELECT
projects.slug,
token_index,
current_owner
FROM (
SELECT
token_id,
to_address AS current_owner
FROM (
SELECT
EXPLAIN ANALYZE
SELECT
projects.slug,
token_index,
current_owner
FROM (
SELECT
token_id,
to_address AS current_owner
FROM (
$ createdb test_input
$ psql test_input -c "CREATE TABLE strs(s text); INSERT INTO strs(s) VALUES('-- hi');"
INSERT 0 1
$ createdb test_output
$ pg_dump test_input | sed -e '/^--/d' | psql test_output
SET
SET
SET
SET
SET
<https://token.artblocks.io/19>: at 2021-10-12T21:58:50.735+00:00, feature `Steps Between` had value `200`; now, it has value `"200"`
<https://token.artblocks.io/29>: at 2021-10-12T21:58:51.821+00:00, feature `Color Spread` had value `27`; now, it has value `"27"`
<https://token.artblocks.io/110>: at 2021-10-12T21:58:52.191+00:00, feature `Color Spread` had value `31`; now, it has value `"31"`
<https://token.artblocks.io/17>: at 2021-10-12T21:58:50.839+00:00, feature `Height` had value `3`; now, it has value `"3"`
<https://token.artblocks.io/168000208>: at 2021-10-13T00:47:26.581+00:00, feature `Number of Leaves` had value `30`; now, it has value `"30"`
<https://token.artblocks.io/168000014>: at 2021-10-13T00:46:55.105+00:00, feature `Number of Leaves` had value `34`; now, it has value `"34"`
<https://token.artblocks.io/168000013>: at 2021-10-13T00:46:55.539+00:00, feature `Number of Petals` had value `40`; now, it has value `"40"`
<https://token.artblocks.io/168000123>: at 2021-10-13T00:47:13.818+00:00, feat
@wchargin
wchargin / test.out
Created December 25, 2021 22:36
index on projected expression of jsonb vs text
$ psql -f test.sql
DROP TABLE
CREATE TABLE
INSERT 0 900000
CREATE INDEX
COPY 200000
COPY 200000
COPY 200000
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------
@wchargin
wchargin / badslugs.js
Created December 25, 2021 00:12
scratch script to find conflicting or otherwise bad feature/trait slugs
const pg = require("pg");
const slugify = require("./src/util/slugify");
async function main() {
require("dotenv").config();
const client = new pg.Client();
await client.connect();
try {
const featureNamesRes = await client.query(
`
@wchargin
wchargin / README
Last active October 21, 2021 18:05
combo: simple parser combinator library for JavaScript
This is `combo.js` as of SourceCred commit fb669962a030, modified to convert
Flow type annotations to comment syntax and to group ES6 exports to the end of
the file (for easier conversion to Node-style `module.exports`). The code of
`combo.js` up to this point in history was written entirely by me. Its tests
still pass.
@wchargin
wchargin / xmonad.hs
Last active October 18, 2021 19:27
xmonad 2021-10-18
import XMonad
import XMonad.Config.Gnome (gnomeConfig)
import XMonad.Hooks.ManageHelpers (doCenterFloat)
import XMonad.Hooks.ManageDocks (manageDocks, avoidStruts)
import XMonad.Layout.NoBorders (noBorders)
import qualified XMonad.Layout.Dwindle as Dwindle
import XMonad.Actions.CycleWS (nextWS, prevWS, shiftToNext, shiftToPrev)
import XMonad.Util.EZConfig (additionalKeys)
import qualified XMonad.StackSet as W