Skip to content

Instantly share code, notes, and snippets.

View RedHatter's full-sized avatar

Ava Johnson RedHatter

View GitHub Profile
@RedHatter
RedHatter / hardcover-app-copy-authors.user.js
Last active March 8, 2026 03:36
Greasemonkey script for Hardcover.app to copy "Authors & Contributions" from one edition to another.
// ==UserScript==
// @name Hardcover.app: Copy authors
// @namespace https://gist.github.com/RedHatter/
// @match https://hardcover.app/*
// @version 1.1
// @author Ava Johnson (ava.johnson@zohomail.com)
// @description Copies "Authors & Contributions" from one edition to another.
// @license MIT
// @downloadURL https://gist.github.com/RedHatter/c716ecb4b7f84872c644126977a3fb3d/raw/hardcover-app-copy-authors.user.js
// @grant GM.getValue
@RedHatter
RedHatter / hardcover-app-edition-checkmark.user.js
Last active March 8, 2026 03:26
Automatically adds a checkmark to editions that have already been edited and saved. Adds a button to manually add a checkmark to books.
// ==UserScript==
// @name Hardcover.app: Edition checkmark
// @namespace https://gist.github.com/RedHatter/
// @match https://hardcover.app/*
// @version 1.6
// @author Ava Johnson (ava.johnson@zohomail.com)
// @description Automatically adds a checkmark to editions that have already been edited and saved. Adds a button to manually add a checkmark to books.
// @license MIT
// @downloadURL https://gist.github.com/RedHatter/081d7efe9ec89969b6a3cba049dc3444/raw/hardcover-app-edition-checkmark.user.js
// @grant GM.getValue
@RedHatter
RedHatter / useDeepMemo.ts
Created August 29, 2024 20:16
A simple react form handling hook
import { DependencyList, useMemo, useRef } from 'react'
import * as R from 'remeda'
/**
* `useDeepMemo` will only recompute the memoized value when one of the
* `dependencies` has changed by value.
*
* Warning: `useDeepMemo` should not be used with dependencies that
* are all primitive values. Use `React.useMemo` instead.
{
"name": "OnShape",
"start_url": "https://cad.onshape.com/documents/",
"icons": [
{
"src": "https://cad.onshape.com/favicon.png",
"sizes": "144x144",
"type": "image/png"
}
],
@RedHatter
RedHatter / main.js
Created October 4, 2022 08:25
Scrap amazon order history and download invoices as PDFs
import puppeteer from "puppeteer";
function clickLink(page, selector) {
return Promise.all([page.click(selector), page.waitForNavigation()]);
}
const USERNAME = "jane.doe@gmail.com";
const PASSWORD = "************";
const PAGES = 2;
@RedHatter
RedHatter / ButtonGroup.svelte
Created February 11, 2021 05:29
Svelte form and input components with buildt-in validation
<script>
import { onMount, createEventDispatcher } from 'svelte'
import { getContext } from './Form.svelte'
const dispatch = createEventDispatcher()
export let value = ''
export let options = {}
let className
export { className as class }
@RedHatter
RedHatter / main.dart
Created December 22, 2020 02:18
Else if example
main () {
var a = 2;
var b = [
if (a == 1)
1
else if (a == 2)
2
];
print(b);
@RedHatter
RedHatter / format.js
Last active December 8, 2020 23:40
Prettier and postcss formatting
import fs from 'fs'
import transform from 'rollup-plugin-transform-input'
import prettier from 'prettier'
import postcss from 'postcss'
import sorting from 'postcss-sorting'
function formatContents(filepath, source) {
return prettier.format(source, {
filepath,
arrowParens: 'avoid',
@RedHatter
RedHatter / Route.svelte
Created December 4, 2020 01:16
Single file router for svelte.
<script>
import UrlPattern from 'url-pattern'
import location, { navigate, noMatch } from './location.js'
export let path
export let component = undefined
export let redirect = undefined
$: pattern = new UrlPattern(path)
$: router = {
@RedHatter
RedHatter / DateMultiPicker.jsx
Last active August 4, 2021 02:14
Range and multi select for @dmtrKovalenko/material-ui-pickers
import React, { useState, useContext, useRef } from 'react'
import { DatePicker } from 'material-ui-pickers'
import { MuiPickersContext } from 'material-ui-pickers'
export default function DateMultiPicker({
value,
onChange,
labelFunc,
format,
emptyLabel,