Skip to content

Instantly share code, notes, and snippets.

Avatar

Jamie Mason JamieMason

View GitHub Profile
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)
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@JamieMason
JamieMason / yarn-audit-to-resolutions-with-jq.md
Last active May 10, 2020
Convert Yarn Audit output into Yarn Resolutions Object using jq
View yarn-audit-to-resolutions-with-jq.md

Convert Yarn Audit output into Yarn Resolutions Object using jq

The following command:

yarn audit --json | grep '"type":"auditAdvisory"' | jq -r '{(.data.advisory.module_name):.data.advisory.patched_versions}' | jq -s add

Will filter and convert the output of yarn audit into an index of overrides to avoid vulnerabilities. It will produce output like this:

@JamieMason
JamieMason / heroku-app-bulk-copy-config.md
Created Apr 30, 2020
JavaScript Snippet to Automate Copying Config Vars from one Heroku App to another using the UI
View heroku-app-bulk-copy-config.md

Automate Copying Config Vars from one Heroku App to another using the UI

Press Reveal Config Vars on the App you want to copy from and run this to put an array of objects in your clipboard containing all the keys and values.

copy(
  document
    .querySelectorAll('.config-vars-list-table tr')
    .map((el) => {
@JamieMason
JamieMason / sublime-keymap.md
Last active Aug 4, 2020
Reconfigure Sublime Text Keyboard Shortcuts to match VS Code
View sublime-keymap.md

Reconfigure Sublime Text Keyboard Shortcuts to match VS Code

Add the following to ~/Library/Application Support/Sublime Text 3/Packages/User/Default (OSX).sublime-keymap.

[
  { "keys": ["alt+down"], "command": "swap_line_down" },
  { "keys": ["alt+z"], "command": "toggle_setting", "args": { "setting": "word_wrap" } },
  { "keys": ["alt+up"], "command": "swap_line_up" },
  { "keys": ["shift+alt+down"], "command": "duplicate_line" },
You can’t perform that action at this time.