Skip to content

Instantly share code, notes, and snippets.

Avatar

wchargin wchargin

View GitHub Profile
@wchargin
wchargin / prelude1thomas.ly
Created October 26, 2022 18:43
transcription (slightly modified) of "Prelude 1 (Recomposed)" by Sebastian Thomas
View prelude1thomas.ly
\version "2.20.0"
md = \markup \italic { m.d. }
mg = \markup \italic { m.g. }
\header {
title = "Prelude 1 (Recomposed)"
composer = "Sebastian Thomas"
tagline = ##f
}
View qqlrng.js
var $t=Math.pow(2,-32),ge=32557,Le=19605,ze=62509,Jt=22609,Qt=33103,en=63335,tn=31614,nn=5125;
var De=class{constructor(){this._state=new Uint16Array(4),this._dv=new DataView(this._state.buffer),this._nG=null,this._hNG=!1}setSeed(t){this._hNG=!1,this._nG=null;let l=~~((t.length-2)/2),c=[];for(let b=0;b<l;b++){let k=2+2*b;c.push(parseInt(t.slice(k,k+2),16))}let e=1690382925,d=72970470,f=qe(c,e),g=qe(c,d);this._dv.setUint32(0,f),this._dv.setUint32(4,g)}rnd(){let t=this._state,l=t[0],c=t[1],e=t[2],d=t[3],f=Qt+ge*l|0,g=en+ge*c+(Le*l+(f>>>16))|0,b=tn+ge*e+Le*c+(ze*l+(g>>>16))|0,k=nn+ge*d+(Le*e+ze*c)+(Jt*l+(b>>>16));t[0]=f,t[1]=g,t[2]=b,t[3]=k;let L=(d<<21)+((d>>2^e)<<5)+((e>>2^c)>>11),B=L>>>(d>>11)|L<<(-(d>>11)&31);return $t*(B>>>0)}uniform(t=1,l=null){return l===null&&([t,l]=[0,t]),this.rnd()*(l-t)+t}gauss(t=0,l=1){if(this._hNG){this._hNG=!1;var c=this._nG;return this._nG=null,t+l*c}else{var e=0,d=0,f=0;do e=this.rnd()*2-1,d=this.rnd()*2-1,f=e*e+d*d;while(f>=1||f===0);var g=Math.sqrt(-2*Math.log(f)/f);return this
View OptionalUint.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;
/// @dev
/// An `OptionalUint` is either absent (the default, uninitialized value) or a
/// `uint256` from `0` through `type(uint256).max - 1`, inclusive. Note that an
/// `OptionalUint` cannot represent the max value of a `uint256`.
type OptionalUint is uint256;
/// @dev
@wchargin
wchargin / difmap.sh
Last active March 14, 2023 23:26
difmap: diff files under a Unix filter, like difmap -c 'jq .' f1 f2
View difmap.sh
#!/bin/sh
set -eu
usage() {
cat <<'EOF'
difmap: diff two files after mapping them through a shell filter
Examples:
# How has this minified JSON changed since my last commit?
@wchargin
wchargin / pct.sh
Last active March 14, 2023 23:26
unix filter for computing percentiles / quantiles
View pct.sh
#!/bin/sh
die() {
printf >&2 'fatal: %s\n'
exit 1
}
case $# in
0) die 'no percentiles provided' 'usage: pct P [P ...]' ;;
1) ps="$1" ;;
*)
View torimichi.ly
\version "2.20.0"
\header {
title = "Torimichi"
subtitle = "(second half, from 2:30 onward)"
composer = "Coddneck"
arranger = "arr. wchargin"
tagline = ##f
}
View current_owners_for_project.sql
SELECT
projects.slug,
token_index,
current_owner
FROM (
SELECT
token_id,
to_address AS current_owner
FROM (
SELECT
View current_owner_check.sql
EXPLAIN ANALYZE
SELECT
projects.slug,
token_index,
current_owner
FROM (
SELECT
token_id,
to_address AS current_owner
FROM (
View pg_dump_remove_comments.log
$ 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
View trait_changes
<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