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 / 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
@rileyjshaw
rileyjshaw / expanded: rjset.css
Created May 18, 2020 20:45
A small CSS reset that I wrote in early 2019
:root {
--co: #eee;
--cr: #ff4136;
--cg: #2ecc40;
--cb: #0074d9;
--cc: #00bcd4;
--cm: #e91e63;
--cy: #ffdc00;
--ck: #0a0b08;
--cbg: #fff;
@rileyjshaw
rileyjshaw / long-mcquade-deal-finder.js
Last active February 12, 2020 22:19
Long & McQuade is having their blowout sale this weekend which means it's time for me to waste money again
// This script finds the best deals from Long & McQuade's annual
// blowout sale and sorts them within their respective categories.
//
// USAGE:
// 1. Navigate to http://promo.long-mcquade.com/SaleFlyer.php
// 2. Select your nearest location under "View Other Locations' Flyers Here"
// 3. Open your browser's Javascript console
// 4. Paste the contents of this file into the console
// 5. Optionally, replace the value of ONLY_SHOW_DEALS_BELOW_THIS_FRACTION_OF_THE_ORIGINAL_COST
// 6. Optionally, replace the value of I_WILL_NOT_EVEN_CONSIDER_ANYTHING_THAT_COSTS_OVER
@rileyjshaw
rileyjshaw / partial-calculator.js
Last active March 4, 2020 00:46
I have some enclosures, and I want to make a puzzle. I wrote a script to help make it an interesting puzzle.
/**
* Partial calculator.
*
* I have some enclosures, and I want to make a puzzle.
*
* I'll turn the enclosures into a calculator, with no
* display but nine LEDs at the top. Some digits will
* be missing.
*
* The calculator will have 4 operations: +, -, x, ÷.