Skip to content

Instantly share code, notes, and snippets.

View wchargin's full-sized avatar

wchargin wchargin

View GitHub Profile
@wchargin
wchargin / difmap.sh
Last active April 25, 2024 17:57
difmap: diff files under a Unix filter, like difmap -c 'jq .' f1 f2
#!/bin/sh
set -eu
set -x
usage() {
cat <<'EOF'
difmap: diff two files after mapping them through a shell filter
Examples:
@wchargin
wchargin / cmp.js
Created February 5, 2024 23:07
sortAsciinumeric, extractNumbers: numeric-aware string sorting
/**
* A comparator that follows elements' natural ordering. Useful for comparing
* numbers: `[8, 9, 10].sort()` is broken, but `[8, 9, 10].sort(natural)` works
* as expected. Also useful as a "neutral" comparator to give to combinators.
*/
function natural(a, b) {
if (a > b) return 1;
if (a < b) return -1;
return 0;
}
@wchargin
wchargin / multiplyFloat.js
Created April 13, 2020 04:24
multiply bigint by float in JS (spoiler alert: BigInt has no useful functions)
/**
* For a finite normal 64-bit float `f`, extracts integers `sgn`,
* `exponent`, and `mantissa` such that:
*
* - `sgn` is -1 or +1
* - `exponent` is between -1023 and 1024, inclusive
* - `mantissa` is between 0 and 2^51 - 1, inclusive
* - the number given by `f` equals `sgn * 2^exponent * (1 + mantissa / 2^52)`
*
* The results are all bigints within the range of safe integers for
@wchargin
wchargin / words
Created February 11, 2014 01:14
/usr/share/dict/words
This file has been truncated, but you can view the full file.
A
A's
AA's
AB's
ABM's
AC's
ACTH's
AI's
AIDS's
AM's
@wchargin
wchargin / chances.dat
Last active October 30, 2023 00:21
plot backpack battles item chances
round common rare epic legend godly
1 90 10 0 0 0
2 84 15 1 0 0
3 75 20 5 0 0
4 64 25 10 1 0
5 45 35 15 5 0
6 29 40 20 10 1
7 20 35 25 15 5
8 20 30 25 15 10
9 20 28 25 15 12
@wchargin
wchargin / Caddyfile
Last active October 29, 2023 06:07
Caddy x GCS reverse proxy via storage.googleapis.com
# requires caddyserver/cache-handler module
{
order cache before rewrite
cache
log default {
output stdout
# http.handlers.cache logs the entire contents of request
# bodies at info level(??!)
exclude http.handlers.cache
@wchargin
wchargin / art.rs.patch
Created October 11, 2023 20:16
dump flow fields before and after disturbances
diff --git a/src/art.rs b/src/art.rs
index bcba7e0..1d99457 100644
--- a/src/art.rs
+++ b/src/art.rs
@@ -548,10 +548,84 @@ impl FlowField {
} => Self::raw_circular(*circularity, *direction, *rotation, traits.version, rng),
};
let disturbances = Disturbance::build(traits, rng);
+ ff.dump(&[], "flowfield0_initial.png").unwrap();
+ ff.dump(&disturbances, "flowfield1_disturbances.png")
@wchargin
wchargin / art.rs.patch
Created October 4, 2023 19:28
color bullseyes by ring count in qqlrs
diff --git a/src/art.rs b/src/art.rs
index 953bf99..ffec2d1 100644
--- a/src/art.rs
+++ b/src/art.rs
@@ -1431,14 +1431,21 @@ fn draw_ring_dot(pt: &Point, pctx: &mut PaintCtx, rng: &mut Rng) {
variance_adjust * rescale(num_rings as f64, (1.0, 7.0), (0.022, 0.008))
};
+ // https://personal.sron.nl/~pault/
+ const SEQ: [Rgb; 7] = [
@wchargin
wchargin / art.rs.patch
Created October 3, 2023 19:14
hacky patch to qqlrs to force wide margin and specific background color
diff --git a/src/art.rs b/src/art.rs
index 953bf99..f605dfd 100644
--- a/src/art.rs
+++ b/src/art.rs
@@ -521,8 +521,9 @@ impl ColorScheme {
let splatter_center = (rng.uniform(w(-0.1), w(1.1)), rng.uniform(h(-0.1), h(1.1)));
let splatter_odds = *rng.wc(splatter_odds_choices);
+ let bg_override: ColorKey = color_db.color_key_by_name("Fidenza Brown").unwrap();
ColorScheme {
@wchargin
wchargin / art.rs.patch
Created September 14, 2023 15:49
qqlrs animation schedule patch to slow down around larger rings
diff --git a/src/art.rs b/src/art.rs
index 97a18d1..cf2b600 100644
--- a/src/art.rs
+++ b/src/art.rs
@@ -1646,12 +1646,30 @@ pub fn draw<F: FnMut(Frame)>(
let batch_sizes = match config.animate {
Animation::None => None,
Animation::Groups => Some(group_sizes.0),
- Animation::Points { step } => {
- let step = step as usize;