Skip to content

Instantly share code, notes, and snippets.

View alexanderbird's full-sized avatar

Alexander Bird alexanderbird

View GitHub Profile
@alexanderbird
alexanderbird / download-google-photos-album-in-order.sh
Last active July 22, 2022 16:57
Download a Google Photos Album in order (a rather hacky approach, but the only one I found)
# Developed for Firefox on Mac
#
# 1. Empty your Downloads folder
# 2. Create a subdirectory under Downloads called `google-photos-download`
# 3. Run the following script with your Downloads folder as the working directory
# 4. Through your browser, one photo at a time (starting with the first until the last), select it with the mouse and press Shift+D to download
# once your browser releases the lock on the file, the script will move it to ./google-photos-download and rename it so its name reflects its order
#
# I found it helpful to have the Downloads and google-photos-download folders open and visible in Finder windows to get feedback about
# what the script is doing. I also have the terminal window in a corner to see the script output, and Firefox on the rest of the screen
@alexanderbird
alexanderbird / highlight-friday-skip.js
Created December 18, 2021 01:15
JavaScript to highlight Skip The Dishes receipts for Friday purchases (and add a link for receipt ID to receipt so you can open in new tab)
/* let each of the order IDs be links to the receipt */
Array.from(document.querySelectorAll('[class*="OrderData"] [class*="OrderDataText"]:first-child')).forEach(orderSpan => {
const orderId = orderSpan.textContent.replace(/^#/, '');
const url = `/user/account/orders/${orderId}/details`;
orderSpan.innerHTML = `<a href="${url}">#${orderId}</a>`;
});
/* let each of the dates show day of week. Highlight the Fridays */
Array.from(document.querySelectorAll('span'))
.filter(span => span.textContent.trim().match(/202[0-9]-\d\d-\d\d/))
@alexanderbird
alexanderbird / eml-to-html.js
Created January 30, 2021 04:39
Convert .eml file to .html with node
const EmlParser = require('eml-parser');
const fs = require('fs');
const inputFile = process.argv[2];
if (!inputFile) throw new Error("Missing input file path argument");
if (!inputFile.match(/\.eml$/)) throw new Error("Only .eml files supported");
if (!fs.existsSync(inputFile)) throw new Error(`Couldn't find file ${inputFile}`);
const emailFile = fs.createReadStream(inputFile);
@alexanderbird
alexanderbird / git-commit--fixup-experiment
Last active November 16, 2020 01:14
Experimenting with git commit --fixup as described in https://twitter.com/jaybazuzi/status/1328091226415894531
 /tmp/fixup ☛ git branch start
 /tmp/fixup ☛ date > $(date +%s) # create a new file with the current date in it, just for something to commit
 /tmp/fixup ☛ git add -A && git commit --fixup start -a
[master c037a95] fixup! good
1 file changed, 1 insertion(+)
create mode 100644 1605488610
 /tmp/fixup ☛ date > $(date +%s)
 /tmp/fixup ☛ git add -A && git commit --fixup start -a
[master 26f9ec1] fixup! good
1 file changed, 1 insertion(+)
@alexanderbird
alexanderbird / list-created-dates-for-all-files.sh
Created April 30, 2020 15:59
List the date that each file in the current directory & subdirectories was created. If you run this from the root of a large repo it will take a while.
OIFS="$IFS"
IFS=$'\n'
for file in `git ls-files`; do
echo "$(git rev-list HEAD "$file" | tail -n 1 | xargs git log -n 1 --date=short --pretty=format:%ad) $file"
done
IFS="$OIFS"
@alexanderbird
alexanderbird / add-jest.patch
Last active January 31, 2020 06:27
Git patch to add Jest with babel to a project set up with the preact cli
commit bf688814118231ecc64365e93e276f7fefa0652f
Author: Alexander Bird <alex@alexanderbird.software>
Date: Thu Jan 30 19:39:22 2020 -0800
Add Jest and 'npm test'
diff --git a/babel.config.js b/babel.config.js
new file mode 100644
index 0000000..8249e41
--- /dev/null
@alexanderbird
alexanderbird / download-site.sh
Created January 7, 2018 05:13
Create a local copy of your website.
wget --mirror --page-requisites --html-extension --convert-links --no-host-directories example.com