Skip to content

Instantly share code, notes, and snippets.

View dfrankland's full-sized avatar
🏕️
Catching Pokemon

Dylan Frankland dfrankland

🏕️
Catching Pokemon
View GitHub Profile
@dfrankland
dfrankland / optional-properties-to-undefined.ts
Created March 25, 2024 04:55
Convert TypeScript optional properties to required with `undefined` unions
/*
* [Try on the TypeScript Playground](https://www.typescriptlang.org/play?#code/PTAEDkHkBUFEC5QBcAWBLAzsgngBwKagYoD2ArgDYAmoAdiUqAEaEDGJAtriRvlQDR0SdfH1AAzEgCdQaRkmEtQAQ1qzaSfFPHLW+AFBI8hALLKpAay2gAvKADeoKfmVUStCtlAB9b2+-0SN4KZKwo3hzmVlTeuFIkBFJGvohktGgAjmSEGNgcTCQUoAC+ANz6hsagAEr4WWjOANL42BhmlpC4SGjuyhQACvGJ3fgYADzQAHy2DvqgoCAQMAigAKq8oJGW1iysymQbAAYAtAD8h074HCQAbqOgh2lU+OJotHwXCiRzoADa-epQFZsCRxKBoCosP0ALpnVK0Z6vd40fAAD00CKw0H+0NAp3BONAAB9QO0rDJENiYeUyhUjAQavhcBRdPgyVpBgktCNxtBBAA1GZPF5vPjTOz2H7-QHA0HgyGgGGIdkyNEYqhYwn42Co1gUMjPCY4wQq6YkwWUnE08qVBmdbq9AZDbloUbQEirBEi5ETcWM5mslWc4au8a1epNFptKL2nq0PrBl2jX2TG30wjQUaMOyxx2JpKh92exGiqhjRwJB3xiinRAYJBSN4AcxKqZ+iwAeqcgA)
*/
// NOTE: this type should not be composed, no need for it to be an interface
type Marker = { readonly __do_not_touch_marked_property__: unique symbol };
type RequireKeysMarkOptionalProperties<T> = {
// NOTE: Use marker because `-?` removes `undefined` too
[P in keyof T as P]-?: undefined extends T[P] ? T[P] | Marker : T[P];
@dfrankland
dfrankland / nix-derivation-outputs.sh
Created October 11, 2023 07:00
An example of getting all outputs of a nix derivation
#!/bin/bash
nix derivation show nixpkgs#zstd | jq 'to_entries[].value.outputs'

Google Nest Wifi QR Code Generation

Create a QR Code for one that is destroyed, misplaced, or removed from Google Nest Wifi access points.

  1. Use the following template to generate the text value for the QR code:

    1V:E100$P:3$R:1$D:700101$S:______________$L:641666004ADA471E$W:F072EA4C4100$H:____.ybc$C:________$
                              ^ ID                                               ^ Wifi ID  ^ Setup Code
    
@dfrankland
dfrankland / Building QMK firmware on Mac.md
Created October 4, 2022 01:18
Building QMK firmware on Mac

Building QMK firmware on Mac

Just edit the make command in utils/docker_build.sh and then run the utils/docker_build.sh file (you may still need to provide the keyboard:keymap:target though).

Example for faux fox v2

Edit the last line of utils/docker_build.sh:

@dfrankland
dfrankland / prisma-utils.ts
Created August 16, 2022 14:55 — forked from rsaryev/prisma-utils.ts
Prisma analogue migrate rest command only programmatically, for testing purposes.
import { Prisma, PrismaClient } from '@prisma/client';
import { exec } from 'child_process';
import * as util from 'util';
const execPromisify = util.promisify(exec);
const prisma = new PrismaClient();
const tables = Prisma.dmmf.datamodel.models
.map((model) => model.dbName)
.filter((table) => table);
@dfrankland
dfrankland / README
Created March 3, 2022 04:53 — forked from jmatsushita/README
Setup nix, nix-darwin and home-manager from scratch on an M1 Macbook Pro
# I found some good resources but they seem to do a bit too much (maybe from a time when there were more bugs).
# So here's a minimal Gist which worked for me as an install on a new M1 Pro.
# Inspired by https://github.com/malob/nixpkgs I highly recommend looking at malob's repo for a more thorough configuration
#
# Let's get started
#
# Let's install nix (at the time of writing this is version 2.5.1
curl -L https://nixos.org/nix/install | sh
# I might not have needed to, but I rebooted
#!/bin/bash
# !!WARNING!!
# This will DELETE all efforts you have put into configuring nix
# Have a look through everything that gets deleted / copied over
nix-env -e '.*'
rm -rf $HOME/.nix-*
rm -rf $HOME/.config/nixpkgs
@dfrankland
dfrankland / ascii-pretzel.txt
Created February 14, 2022 21:58
ascii art pretzel
_ _
/ X \
\/_\/
' '
@dfrankland
dfrankland / add-anki-card-with-js-on-ankiweb.js
Last active January 25, 2022 22:01
Quickly add cards with plain text using AnkiWeb
// Go to https://ankiuser.net/edit/
(async ({ cardType, nameOfDeck, data }) => {
const body = [
["nid", ""],
["data", encodeURIComponent(JSON.stringify(data))],
["csrf_token", editor.token],
["mid", editor.mode.notetypes.find(({ name }) => name === cardType).id],
["deck", editor.mode.decks.find(({ name }) => name === nameOfDeck).id],
]
@dfrankland
dfrankland / get-innova-discs.sh
Last active November 11, 2021 00:07
Curl Innova discs available from the factory store
#! env bash
# Checking which full production discs are available in Champion Glow plastic
curl -sL 'https://proshop.innovadiscs.com/full-production/?_bc_fsnf=1&Plastic+Type=Glow+Champion&list_all=Disc%20Model' | grep -ie 'Disc+Model=.*"' | sed 's/.*Disc+Model=\(.*\)"/\1/' | sed 's/+/ /' | perl -pe 's/\%(\w\w)/chr hex $1/ge'
# Checking which full production discs are available in Champion plastic
curl -sL 'https://proshop.innovadiscs.com/full-production/?_bc_fsnf=1&Plastic+Type=Champion&list_all=Disc%20Model' | grep -ie 'Disc+Model=.*"' | sed 's/.*Disc+Model=\(.*\)"/\1/' | sed 's/+/ /' | perl -pe 's/\%(\w\w)/chr hex $1/ge'
# Checking which limited discs are available in Champion Glow plastic
curl -sL 'https://proshop.innovadiscs.com/limited/?_bc_fsnf=1&Plastic+Type=Glow+Champion&list_all=Disc%20Model' | grep -ie 'Disc+Model=.*"' | sed 's/.*Disc+Model=\(.*\)"/\1/' | sed 's/+/ /' | perl -pe 's/\%(\w\w)/chr hex $1/ge'