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 / 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, ÷.
@rileyjshaw
rileyjshaw / 2019-12-10-copypastas.tidal
Created January 11, 2020 02:18
Testing tidal out with some copypastas
d1 $ sound "bd bd bd bd"
d2 $ sound "hh hh hh hh hh"
d2 $ silence
d3 $ sound "arpy"
d4 $ sound "bd sd hh cp mt arpy drum odx bd arpy bass2 feel future"
@rileyjshaw
rileyjshaw / open_voice_challenge_kpi_analysis.sql
Created December 13, 2019 23:57
Analysis queries for Mozilla Common Voice's Open Voice Challenge Pilot
-- Overall voting accuracy
SELECT client_id,
IF(total, Round (100 * valid / validated, 2), NULL) AS rate
FROM (SELECT user_clients.*,
COUNT(vote_id) AS total,
Coalesce(Sum(agree_count > disagree_count), 0) AS valid,
Coalesce(Sum(( agree_count >= 1
OR disagree_count >= 2 )
AND agree_count <> disagree_count), 0) AS validated
FROM (SELECT user_clients.*,
@rileyjshaw
rileyjshaw / instructions.sql
Created December 12, 2019 21:19
Weekly / overall winner queries for Mozilla's 2019 Open Voice Challenge Pilot (rough draft)
-- To connect to the prod database with write access,
-- $ ssh voice-mysql-prod
-- $ sudo su
-- $ mysql
-- > use voice;
-- > ...
/*
Example team award:
@rileyjshaw
rileyjshaw / cheap-params.js
Last active November 13, 2019 15:07
A very cheap query params object. Fragile!
let p=location.search?.slice(1).split(/&|=/).reduce((o,k,i,a)=>++i%2?(o[k]=a[i],o):o,{})
@rileyjshaw
rileyjshaw / photoshop-crop-1st-bday-photos.jsx
Created October 22, 2019 03:43
Photoshop JS script to resize + frame a bunch of photos
// This is a Photoshop script, not React.
//
var white = new SolidColor();
white.rgb.hexValue = "ffffff";
app.backgroundColor = white;
var doc = app.activeDocument;
doc.changeMode(ChangeMode.RGB);
// Crop and resize.
@rileyjshaw
rileyjshaw / random-words.js
Created August 18, 2019 21:36
print a list of 50 random words (weighted lengths) with scrabble letter frequency
const normalize = a => a.reduce((arr, val, i) => {arr[i + 1] = arr[i] + val; return arr;}, [0]).map((v, i, arr) => v / arr[arr.length - 1]);
const getWeighted = (a, r) => a.findIndex(v => v > r);
const letters = 'abcdefghijklmnopqrstuvwxyz'.split('');
const letterWeights = normalize([9, 2, 2, 4, 12, 2, 3, 2, 9, 1, 1, 4, 2, 6, 8, 2, 1, 6, 4, 6, 4, 2, 2, 1, 2, 1]);
const wordLengthWeights = normalize([0, 1, 7, 4, 4, 4, 5, 3, 4, 2, 1, 1, 1, 1, 1, 1, 1]); // 1, 2, 3...
console.log(Array.from({length: 50}, (_, i) =>
Array.from({length: getWeighted(wordLengthWeights, Math.random())}, () => letters[getWeighted(letterWeights, Math.random())]).join('')
).sort((a, b) => a.length - b.length).join('\n'));
@rileyjshaw
rileyjshaw / dwitter-backup.js
Created August 6, 2019 20:31
Dwitter backup scripts
/*
Dwitter backup scripts.
Is the API up?
Yes: 1. Paste Script A into a Node console.
2. Copy and save the output.
No: 1. Go to https://www.dwitter.net/u/rileyjshaw.
2. Scroll to the bottom so that all dweets are loaded.
@rileyjshaw
rileyjshaw / convert.sh
Last active August 1, 2019 00:44
Convert a bunch of .movs into 128x128 .webps
for f in *.mov; do
ffmpeg -an -i ./"$f" -vcodec libwebp -vsync 0 -s 128x128 -sws_dither none -sws_flags neighbor -q:v 10 ./"${f%.mov}.webp";
ffmpeg -an -i ./"$f" -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -level 3 -s 512x512 -sws_dither none -sws_flags neighbor -crf 35 ./"${f%.mov}.mp4";
done
@rileyjshaw
rileyjshaw / brew-install-ffmpeg-with-all-options.sh
Last active November 22, 2019 22:33
2019-10-07: Install ffmpeg with all options on MacOS using Homebrew
brew cask install xquartz
brew install amiaopensource/amiaos/decklinksdk
brew tap homebrew-ffmpeg/ffmpeg
brew install homebrew-ffmpeg/ffmpeg/ffmpeg $(brew options homebrew-ffmpeg/ffmpeg/ffmpeg --compact)