Skip to content

Instantly share code, notes, and snippets.

Avatar

Jamie Mason JamieMason

View GitHub Profile
@JamieMason
JamieMason / zondicons.sh
Created Oct 22, 2020
Convert Zondicons to TypeScript React Components (~80%, still some small manual cleanup to do)
View zondicons.sh
#!/usr/bin/env bash
echo "export const AddOutline: React.FC<{ className?: string }> = ({ className }) => $(cat "./add-outline.svg")" > "./add-outline.tsx"
echo "export const AddSolid: React.FC<{ className?: string }> = ({ className }) => $(cat "./add-solid.svg")" > "./add-solid.tsx"
echo "export const Adjust: React.FC<{ className?: string }> = ({ className }) => $(cat "./adjust.svg")" > "./adjust.tsx"
echo "export const Airplane: React.FC<{ className?: string }> = ({ className }) => $(cat "./airplane.svg")" > "./airplane.tsx"
echo "export const Album: React.FC<{ className?: string }> = ({ className }) => $(cat "./album.svg")" > "./album.tsx"
echo "export const AlignCenter: React.FC<{ className?: string }> = ({ className }) => $(cat "./align-center.svg")" > "./align-center.tsx"
echo "export const AlignJustified: React.FC<{ className?: string }> = ({ className }) => $(cat "./align-justified.svg")" > "./align-justified.tsx"
echo "export const AlignLeft: React.FC<{ className?: string }> = ({ className }) => $(ca
@JamieMason
JamieMason / delete-whatsapp-messages.js
Last active Nov 22, 2020
Bulk Delete every WhatsApp Chat Message
View delete-whatsapp-messages.js
// Delete every Chat in WhatsApp, by Jamie Mason (https://twitter.com/fold_left)
// https://gist.github.com/JamieMason/f8992ebf95423244b730b2c393c321ef
//
// 1. Go to https://web.whatsapp.com/ and sign in.
// 2. Archive any messages you don't want deleting, you can unarchive them after.
// 3. Open the Developer Console. (COMMAND+ALT+I on Mac)
// 4. Paste this into the Developer Console and run it.
// 5. If it gets stuck, scroll up and down in the list of chats.
// 6. Refresh the page and run again if you have any problems.
// 7. This Script does not Exit Groups or clear messages in them.
@JamieMason
JamieMason / copy-names-of-all-github-issue-labels.md
Created Aug 20, 2020
Copy names of all GitHub Issue Labels
View copy-names-of-all-github-issue-labels.md
@JamieMason
JamieMason / next.config.js helpers.md
Last active Aug 12, 2020
next.config.js helpers
View next.config.js helpers.md

next.config.js Helpers

Mutate next.js internal config to make changes which are not officially available to you. Be sure to know what you're doing.

Helpers

const getPluginsByConstructorName = (constructorName, plugins) =>
  plugins.filter((plugin) => plugin.constructor.name === constructorName);
View machine.js
// @TODO: Handle US Taxes
// @TODO: Handle Abandoned Checkout
// @TODO: Handle guest checkout
// @TODO: What/when do we tell PayPal when a gift card is redeemed?
// @TODO: What/when do we tell PayPal when a coupon code is redeemed?
// @TODO: Handle when to mount and unmount the paypal library/iframe safely
// @TODO: Include how we handle errors
// @TODO: What side-effects do we need to fire and when?
// @TODO: What response data do we need to store from requests and when?
// @TODO: Loqate?
View machine.js
// @TODO: handle US Taxes
// @TODO: handle guest checkout
// @TODO: what/when do we tell PayPal when a gift card is redeemed?
// @TODO: what/when do we tell PayPal when a coupon code is redeemed?
// @TODO: handle when to mount and unmount the paypal library/iframe safely
// @TODO: include how we handle errors
// @TODO: what side-effects do we need to fire and when?
// @TODO: what response data do we need to store from requests and when?
// @TODO: Loqate?
// @TODO: Redeeming Coupons - this can be done at any stage of checkout
@JamieMason
JamieMason / inline-styles.md
Created Jul 23, 2020
Inline all user-defined styles on an Element and its descendants
View inline-styles.md

Inline all user-defined styles on an Element and its descendants

A lot of styles can depend on context, such as .foo a so this doesn't work brilliantly.

var toCamelCase = (str) =>
  str
    .split("-")
    .map((word, index) =>
      index == 0
View machine.js
const formMachine = Machine(
{
id: 'form',
initial: 'editing',
context: {
apiError: '',
formSchema: null,
formData: null,
},
states: {
@JamieMason
JamieMason / machine.js
Last active Jul 13, 2020
authMachine: Generated by XState Viz: https://xstate.js.org/viz
View machine.js
const loginMachine = Machine(
{
id: 'login',
initial: 'idle',
context: {
apiError: '',
email: '',
fieldError: '',
password: '',
shouldRememberMe: false,
@JamieMason
JamieMason / machine.js
Last active Jul 13, 2020
checkoutMachine: Generated by XState Viz: https://xstate.js.org/viz
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
You can’t perform that action at this time.