Skip to content

Instantly share code, notes, and snippets.

Avatar

Jared Palmer jaredpalmer

View GitHub Profile
View html2pdf.js
import puppeteer from 'puppeteer'
import fs from 'fs'
async function buildPDF(htmlString) {
const browser = await puppeteer.launch({ headless: true })
const page = await browser.newPage();
await page.setContent(htmlString, { waitUntil: 'networkidle0' })
const pdf = await page.pdf({
format: 'A4',
displayHeaderFooter: false,
@jaredpalmer
jaredpalmer / doc-table.md
Created June 13, 2022 14:18 — forked from antfu/doc-table.md
Doc Table in Markdown
View doc-table.md

Example

Name

Description


@jaredpalmer
jaredpalmer / oauth-device-flow.md
Last active September 1, 2021 09:35
OAuth 2.0 Device Flow
View oauth-device-flow.md

OAuth Device Flow

This is flow used by apps on Apple TV / Roku. However, it is also useful for CLIs.

Here is my rundown. Please correct me in comments if something is wrong or if there is a better way to do this.


Device pings the server to begin activation process

@jaredpalmer
jaredpalmer / MarkdownPage.tsx
Created February 17, 2021 13:52
Get headers from MDX in Next.js
View MarkdownPage.tsx
import {MDXProvider} from '@mdx-js/react';
import {MDXComponents} from 'components/MDX/MDXComponents';
import {Toc} from 'components/Toc/Toc';
import * as React from 'react';
export interface MarkdownProps<Frontmatter> {
meta: Frontmatter;
children?: React.ReactNode;
}
View assignExperiment.ts
import { crc32 } from 'common/components/Features/Experiment/crc32';
import { Config } from 'common/api/models/Config';
const sortBy = require('lodash.sortby');
export interface Experiments {
[name: string]: Variant[];
}
export interface Variant {
name: string;
@jaredpalmer
jaredpalmer / outline.md
Last active January 9, 2021 18:38
Formik Tutorial
View outline.md

Formik Tutorial Outline

We're going to build a multi-step wizard for a jobs-to-be-done customer research questionaire from scratch.

Before we start

  • Installation
  • What we're building
  • Getting help
@jaredpalmer
jaredpalmer / postgres-brew.md
Created September 26, 2020 20:50 — forked from ibraheem4/postgres-brew.md
Installing Postgres via Brew (OSX)
View postgres-brew.md

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
View stale-app-link.js
View brotli.js
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
@jaredpalmer
jaredpalmer / replaceValues.ts
Last active August 9, 2020 06:58
Replace all values of a given key
View replaceValues.ts
/**
* Return a copy of an object, but with values of a key replaced with value of provided key-value object.
* Useful for duplicating highly nested object, but generating new values for a key (e.g. `id`)
*
*
* @param obj An object
* @param keyToReplace The key of the values needed to be swapped
* @param mapOfOldToNewValues A key-value object with a keys of old values mapped to new ones (used for swapping)
*
* @example