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
.container
- for i in 1..3
.shaker
ul.group
- for j in 1..14
li.line
@rileyjshaw
rileyjshaw / ffmpeg-slit-scan.sh
Created March 5, 2024 02:57
Create an ultra-wide photograph out of a slow dolly shot video. FFMPEG is amazing!
#!/bin/bash
# Default values
start_time=0
rtl_flag=false
output_file="output.png"
downscaling_factor=1
aspect_ratio="16:9"
# Parse arguments
@rileyjshaw
rileyjshaw / convert_to_mp3.sh
Created November 17, 2023 20:11
Convert a folder of .flac albums to 192kbps MP3s to save space on my OpenSwim headphones
#!/bin/bash
# Define the source and target directories.
SOURCE_DIR="./originals"
TARGET_DIR="./processed"
# Ensure ffmpeg is installed.
if ! command -v ffmpeg &> /dev/null
then
echo "ffmpeg could not be found, please install it."
@rileyjshaw
rileyjshaw / heic-convert.sh
Created May 30, 2023 03:15
Adding this to remind myself that the `mogrify` command exists
# heic-convert() {
# local ext
# ext="${1:-jpg}"
# for img in *.heic; do
# convert "$img" "${img%.heic}.$ext"
# done
# }
# Instead of ^this^, do this:
mogrify -format jpg *.heic
@rileyjshaw
rileyjshaw / convert.sh
Last active March 22, 2024 11:01
Download all issues of Emigre Magazine from Letterform Archive’s Online Archive
# Move the results into their own folder, drag that parent folder into imageOptim, `cd` into it, then:
for d in Issue\ */; do
cd "$d"
convert -compress jpeg -quality 33 -resize 2388x2388\> *.jpg "../${d%/}.pdf"
cd ..
done
@rileyjshaw
rileyjshaw / prattle.sh
Created March 29, 2023 23:26
Multiple shell `say` instances at once
curl https://raw.githubusercontent.com/dariusk/corpora/master/data/technology/new_technologies.json | jq '.technologies[]' | while read technology; do say -v zarvox "$technology" & done
@rileyjshaw
rileyjshaw / move-component.js
Created March 10, 2023 03:58
A quick script to organize loose React components
/**
* Moves a React component into its own folder in <src>/components/, adds an index.js for
* cleaner imports, and updates the import path in other files.
*
* Based loosely on the structure shown in https://www.joshwcomeau.com/react/file-structure.
*
*
* Usage
* =====
*
@rileyjshaw
rileyjshaw / DndProviderWrapper.jsx
Created March 10, 2023 00:59
A small wrapper around React DnD’s provider that switches to a touch backend as soon as a touch event is detected.
// This is a small wrapper around React DnD’s provider that switches to a touch
// backend as soon as a touch event is detected.
import { useEffect, useState } from 'react';
import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
const TOUCH_EVENTS = ['touchstart', 'touchmove', 'touchend', 'touchcancel'];
function DndProviderWrapper({ children }) {
const [dndProps, setDndProps] = useState({ backend: HTML5Backend });
@rileyjshaw
rileyjshaw / generate-theme.js
Created February 6, 2023 17:37
Convert a list of 10 colors to a Firefox theme manifest.
// Convert a list of 10 colors (eg. generated by https://primer.style/prism/)
// to a Firefox theme manifest.
//
// name: The name of the theme.
// colors: An array of 10 colors.
// id: The ID of the theme. Format: "your-add-on-name@your-domain.com".
// version (optional): The version of the theme. Format: "<major>.<minor>".
//
// Docs: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/theme
//
@rileyjshaw
rileyjshaw / potato.js
Created January 27, 2023 20:22
Playing Oliver Darkshire’s “Potato” a million times
// Game rules: https://twitter.com/deathbybadger/status/1567425842526945280
const resultCounter = {
whisked: 0,
burrowed: 0,
eaten: 0,
};
const gameState = {};
const roll = () => Math.floor(Math.random() * 6);