Skip to content

Instantly share code, notes, and snippets.

View rileyjshaw's full-sized avatar
💭
Riley is typing…

Riley Shaw rileyjshaw

💭
Riley is typing…
View GitHub Profile
@rileyjshaw
rileyjshaw / download.sh
Created January 3, 2022 05:17
Download a collection of PDFs from the Internet Archive
#!/bin/bash
# Dependency: https://archive.org/services/docs/api/internetarchive/cli.html
# Usage example: ./download.sh byte-magazine
ia search "collection:$1" --itemlist | parallel 'ia download {} --glob="*.pdf"'
@rileyjshaw
rileyjshaw / make_woffs.sh
Created May 3, 2021 02:32
A one-liner to convert a folder of TTFs (also works with OTFs) to WOFF and WOFF2
mkdir -p woff && for f in *.ttf; do sfnt2woff "$f"; woff2_compress "$f"; done && mv *.woff* woff
@rileyjshaw
rileyjshaw / bracket-parse.js
Created April 20, 2021 02:11
Parse a string with [[enclosed [[nested]] double bracket pairs]]. I used this for https://github.com/rileyjshaw/font-comparison-tool.
/**
* Parse takes a string and returns a nested array. The array nests
* to a deeper level for each [[enclosed double bracket pair]].
*
* eg:
*
* // Output: ['It goes ', ['deeper and ', ['deeper.']]]
* parse('It goes [[deeper and [[deeper.]]]]');
*/
function parse(str, startIdx = 0, isChild = false) {
@rileyjshaw
rileyjshaw / mini-deep-array-comparison-fns.js
Created February 22, 2021 06:28
Golfing to come up with a deep array comparison function for simple arrays.
// These comparison functions only work for arrays with the following child types:
//
// - Arrays
// - Values that can be directly compared with ===
//
// If your array contains functions or objects, go away!
// Solution 1: recursive comparison; 94 chars.
let f=Array.isArray,c=(x,y)=>f(y)&&x.length==y.length&&x.every((a,i)=>f(a)?c(a,y[i]):a===y[i])
@rileyjshaw
rileyjshaw / µason.css
Created November 11, 2020 03:43
Typography for a deprecated masonry drop-in; part of something I was working on called "µss.css". The emphasis was on vertical rhythm, simplicity, and a small footprint.
/*
.m Masonry class
.v Vertical align
.s_ Size
*/
.s7 {
font-size: var(--s7);
}
.v .s7 {
line-height: 1.42606336em;
@rileyjshaw
rileyjshaw / alphanumeric_segment_sequence_generator.js
Last active October 18, 2020 01:22
Quick metaprogram for 16-segment display animations using my "Seg16" C library.
console.log('20CEBA954FB7301896D'.split('').map(n => {
const b = `segments.writeStream(0b${(1 << parseInt(n, 16)).toString(2)});`;
return `blinkDots();\n${b}\n${b}\ndelay(100);\n`;
}).join(''));
@rileyjshaw
rileyjshaw / NAND-heart.js
Last active May 25, 2022 23:08
A quick script I wrote to generate a 5-bit heart image (Persistence of Vision) using a 555 timer, a binary counter, 16 NAND gates, and some LEDs.
const ENABLE_IMAGE_ROTATIONS = true;
const ITERATIONS_PER_ROTATION = 10000000;
const MAX_GATES_TOTAL = 20;
const MAX_TREE_DEPTH = 6;
const rand = array => array[Math.floor(Math.random() * array.length)];
const unique = (x, i, array) => array.indexOf(x) === i;
const limit = (name, f, lo, hi = lo) => (...args) => {
const { length: l } = args;
if (l < lo || l > hi)
@rileyjshaw
rileyjshaw / bitswap.js
Last active September 12, 2020 01:13
Quick silly scratchpad for swapping bits. Used as a quick generator for my alphanumeric display library.
function swap(str, a, b) {
const ceil = str.length - 1;
a = Math.min(Math.max(0, a), str.length - 1) || 0;
b = Math.min(Math.max(0, b), ceil) || 0;
if (a === b) return str;
if (a > b) [a, b] = [b, a];
return (
str.slice(0, a) + str[b] + str.slice(a + 1, b) + str[a] + str.slice(b + 1)
);
}
From 66880db1f100c345004710deab0c28c54e035a1e Mon Sep 17 00:00:00 2001
From: Riley Shaw <rileyjshaw@gmail.com>
Date: Mon, 8 Jun 2020 21:35:33 -0700
Subject: [PATCH] Merge remote-tracking branch 'upstream/gsoc' into
layout/datasets-page
---
web/locales/ast/messages.ftl | 10 +-
web/locales/be/messages.ftl | 102 ++++++++++++++++++++-
web/locales/ml/messages.ftl | 44 +++++++--
@rileyjshaw
rileyjshaw / ffmpeg-add-voiceover.sh
Created May 30, 2020 01:19
Quick one-liner to merge audio narration with a video
ffmpeg -i narration.mp3 -i original.mp4 -filter_complex "[0:a][1:a]amerge,pan=stereo|c0<c0+c2|c1<c1+c3[a]" -map 1:v -map "[a]" -c:v copy -c:a aac -shortest output.mp4