Skip to content

Instantly share code, notes, and snippets.

View Pezmc's full-sized avatar

Pez Cuckow Pezmc

View GitHub Profile
@Pezmc
Pezmc / rewrite-webpack-alias.js
Last active April 3, 2023 14:52
Re-write webpack alias into relative imports
const fs = require('fs')
const { cwd } = require('node:process')
const path = require('path')
const readline = require('readline')
const {
glob
@Pezmc
Pezmc / download-all-invoices-bills.js
Last active May 11, 2022 09:39
Download all invoices/bills from Xero
/*
* Xero doesn't offer a way to natively download all attachments on a page.
* This script just manually opens every attachment and clicks the download button
*/
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
async function start() {
for (const pdf_button of document.querySelectorAll(".attachment a")) {
pdf_button.click();
await sleep(2000);
@Pezmc
Pezmc / fake-scan-automator.sh
Last active October 6, 2023 08:26 — forked from andyrbell/scanner.sh
Make a pdf look scanned with macOS automator as a quick action
#!/bin/bash
# This script takes a PDF or list of PDFs and outputs a file(s)
# named <file>_scanned.pdf that looks like it has been scanned
#
# Requires imagemagic and popper to be installed (brew install imagemagick poppler)
#
# Accepts: a list of files
# Usage: ./<scriptfilename> pdf1.pdf pdf2.pdf
#
# To use as a macOS automator quick action you need to:
@Pezmc
Pezmc / grab-prices-from-octopus-comparison.js
Created May 11, 2020 11:55
OctopusComparison quick scraping script
// Grabs prices from https://octopuscomparison.netlify.app/ and totals them up
// Simply paste this into the javascript console
// Relies on some hacks to trigger React onchange events
let allPrices = [];
(function() {
function setNativeValue(element, value) {
const valueSetter = Object.getOwnPropertyDescriptor(element, 'value').set;
const prototype = Object.getPrototypeOf(element);
@Pezmc
Pezmc / nickname.json
Last active August 21, 2019 18:23
nickname.json
{
"nickname": "Name here",
"subtitle": "Subtitle here",
"background": [255, 0, 0],
"fg_color": [255, 255, 255],
"fg_sub_color": [0, 255, 255],
"background_night": [128, 0, 0],
"fg_color_night": [255, 255, 255],
"fg_sub_color_night": [0, 0, 255]
}
@Pezmc
Pezmc / basecamp_url_to_markdown
Created July 26, 2019 11:49
Bookmarklet to get the current Basecamp URL as a helpful markdown link
function copytext(a) {
var b = document.createElement("textarea");
b.innerText = a, document.body.appendChild(b), b.select(), document.execCommand("copy"), b.remove()
}
parts = new Set();
parts.add(document.querySelector('meta[name="current-bucket-name').content);
parts.add(document.querySelector('meta[name="current-dock-tool-title"]').content);
parts.add(document.querySelector('meta[name="current-recording-title"]').content);
page_name = Array.from(parts).join(" › ");
@Pezmc
Pezmc / old-pr-deploy.js
Last active October 19, 2020 14:48
Copy the current PR to your clipboard
function copytext(a) {
var b = document.createElement("textarea");
b.innerText = a, document.body.appendChild(b), b.select(), document.execCommand("copy"), b.remove()
}
copytext("@cobot deploy harvestapp: PR " + document.querySelector('.gh-header-number').innerText + " - " + document.querySelector('.js-issue-title').innerText.trim() + ", see " + window.location);
@Pezmc
Pezmc / parseRunGap.sh
Last active March 2, 2019 11:02
Parse RunGap Metadata
cat *.metadata.json | jq -c '"\(.distance), \(.duration), \(.startTime.time), \(.avgHeartrate), \(.maxHeartrate), \(.activityType.internalName)"' | grep "Running" | grep -v "Treadmill"
JSON.stringify($('.filter-susd-recommends').map(function() { return $(this).find('.eg-games-page-element-1').text() }).toArray())
@Pezmc
Pezmc / bgg-geeklist-game-adder.js
Created August 1, 2018 16:06
Automatically add a list of games to a Board Game Geek GeekList
//= Usage
// Update the config below
// Paste this file into the console on the edit geeklist page
// Call addAllGames()
// Config
let gamelist = []; // Set this to an array containing the names of games you wish to add
// e.g. let gamelist = ["Azul", "Carcassonne", "Codenames"];
// Exposed so they can be logged