Skip to content

Instantly share code, notes, and snippets.


Michoel Samuels AnalyzePlatypus

View GitHub Profile
AnalyzePlatypus / getImageKitModifiers.js
Created Sep 5, 2019
Generate image editing modifiers for
View getImageKitModifiers.js
import getImageKitModifierQueryString from "getImageKitModifiers.js";
const myImageKey = "image.jpg";
const modifierQueryString = getImageKitModifierQueryString({
width: 45,

Stripe Checkout: Multiple Checkout buttons on the same page

Suppose you have a Stripe Checkout page setup to sell a product.

To link to your payment page, you must generate a Checkout button HTML snippet for display on your site. However, the default snippet only supports one Checkout button. You cannot have several Checkout buttons for the same product on the same page.

This gist modifies Stripe's generated snippet to support several buttons.


AWS Lambda SAM cli: Using local env vars

To use local env vars, you must follow the following steps:

  1. Declare all env vars in your template.yml, like so:
 Type: AWS::Serverless::Function 

Obtaining Gmail OAuth tokens

To access your Gmail account from the API, you will need to obtain the following values from Google's OAuth system:

clientId clientSecret refreshToken

Part 1: Client secrets

  1. Open

AWS Lambda: Upload code from Command Line

Last update: June 2020

AWS is notorious for it's incredibly complicated security model. This guide will walk you through setting up a fully-featured build & upload script for your Lambda functions.

You will need:

  • An AWS account
View AWS Lambda - Upload `node_modules` without `devDependencies`.md

AWS Lambda - Upload node_modules without devDependencies

By default, ZIPing the project directory will included all of your devDependencies. slowing your upload speed to a crawl as you upload an enormous bundle containing 80% useless code (unless you're testing in production™ )

You only need your production dependencies when deploying, but need you devDependencies for development. But you have to deploy from the same directory, and it must be named node_modules. How can slim down the ol' deploy bundle?

Here's a horrible but effective hack that accomplishes this:

  1. We'll create an additional directory called node_modules__prod for storing production dependencies.
  2. When we deploy we swap the names of the dev and production node_modules directories 😱, so the deploy tool stupidly uploads what it thinks is our full node_modules but actually is our production-only modules directory.
  3. When deploy is done (or fails) we swap the directory names again, restoring us back to developme
AnalyzePlatypus / swBuildEnvVarFile.js
Created Jul 26, 2020
Build an Env Var file for your service workers
View swBuildEnvVarFile.js
By default, service workers cannot access our Vue environment variables.
To allow this, this script collects the variables we want at build time
and places them in a JS file that the service worker can access.
To prevent the leak of sensitive credentials (the SW file is public),
only whitelisted environment variables are built into this file.
Deploy this file alongside your service worker, and import th efile in your service worker (`importScripts('swenv.js');` in Workbox)
AnalyzePlatypus /
Last active Aug 8, 2020
Helper function for line-wrapping in jsPDF
AnalyzePlatypus /
Last active Mar 17, 2021
Node.js - Accessing a spreadsheet using the Google Sheets API

Using the Sheets API

To access the Sheets API, you will need to enable the Sheets API, obtain credentials, and grant access to your Sheet.

Based on these instructions

1. Enabling the Sheets API

  1. Open the Google Developers Console
  2. Select your project or create a new one (and then select it)
View Root Categories

These are the 35 root categories on

Retrieved via Keepa API on April 12, 2021.

API call:<REDACTED>&domain=1&category=0&parents=1