Skip to content

Instantly share code, notes, and snippets.

View wchargin's full-sized avatar

wchargin wchargin

View GitHub Profile
@wchargin
wchargin / layout-order.patch
Created September 14, 2023 01:18
qqlrs patch: debug pass to show progress of layout through flow line groups
diff --git a/src/art.rs b/src/art.rs
index 78e28bf..970b0e0 100644
--- a/src/art.rs
+++ b/src/art.rs
@@ -813,6 +813,7 @@ impl MarginChecker {
#[derive(Debug, Clone)]
pub struct Point {
+ pub group_idx: u32,
pub position: (f64, f64),
@wchargin
wchargin / art.rs.patch
Created September 14, 2023 00:32
patches to qqlrs to force Margin::Wide and reduce scale changes
diff --git a/src/art.rs b/src/art.rs
index 78e28bf..aaf353f 100644
--- a/src/art.rs
+++ b/src/art.rs
@@ -213,7 +213,7 @@ impl ColorChangeOdds {
}
}
-#[derive(Debug)]
+#[derive(Debug, Clone)]
use std::collections::{HashMap, HashSet};
struct Pawn;
struct Bishop;
struct Rook;
struct Monarch;
struct Knight;
/// A subset of the squares on a chess board.
///
@wchargin
wchargin / telescroll.js
Last active August 29, 2023 07:43
telescroll: trigger a scroll event in the future
import { createContext, useContext, useRef } from "react";
const TelescrollContext = createContext({
provideScroll: () => {},
requestScroll: () => {},
});
export function TelescrollProvider({ children }) {
const requested = useRef(null);
// Visually looks like an ellipsis, like "0x123...def", but the underlying text
// actually has the whole address, so when you select it to copy-paste you get
// the whole thing.
const ShortAddress = ({ address, ensAddress }) => {
if (ensAddress != null) return <span>{ensAddress}</span>;
const nibbles = 3; // to keep, at each side
const prefix = "0x".length;
const start = address.slice(0, prefix + nibbles);
const mid = address.slice(prefix + nibbles, -nibbles);
import shlex
import subprocess
BIN = "./target/release/qql-cli"
SEED = "0x44266f38ea9ef4e85a77310518b1cb6d5a56349bed2514b9d9e2ffff10e2cb2f"
WIDTH = 2400
STEPS = 8
def lerp(a, b, t):
[Unit]
Description=Continuous audio recorder
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/home/pi/start.sh
WorkingDirectory=/home/pi
User=pi
Group=pi
@wchargin
wchargin / .vimrc
Created January 7, 2016 14:12
real-time Haskell expression-internal type inference
let g:airline_section_gutter = "%{MyStatuslineFunction()}%="
function! MyStatuslineFunction()
if &l:ft != "haskell"
return "nope"
else
let l:file = expand("%")
if l:file == ''
return ""
endif
if !filereadable(l:file)
@wchargin
wchargin / a.sh
Created May 30, 2023 04:42
cursed code to get the sequence "!||" to be valid
#!/bin/sh
rustc +nightly --crate-type=staticlib forty_two.rs || exit 1
gcc main.c -L. -lforty_two || exit 1
./a.out
# prints: forty_two() = 42
@wchargin
wchargin / reckless.sh
Created May 11, 2023 21:01
record sound when the mic
#!/bin/bash
# Extended from a work of Jürgen Hötzel: https://stackoverflow.com/a/2613888
noise_threshold=15 # out of 99
base_dir="${HOME}/recordings"
raw_dir="${base_dir}/tmp"
chunk_dir="${base_dir}/chunks"
seg_dir="${base_dir}/seg"
out_dir="${base_dir}/out"
sox_raw_options=( -t raw -r 48k -e signed -b 16 -c 1 )