Skip to content

Instantly share code, notes, and snippets.

Avatar

Jared Palmer jaredpalmer

View GitHub Profile
@jaredpalmer
jaredpalmer / oauth-device-flow.md
Last active Sep 1, 2021
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 Feb 17, 2021
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 Jan 9, 2021
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 Sep 26, 2020 — 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 Aug 9, 2020
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
View SuspenseRedirect.tsx
import { globalHistory, navigate, RedirectProps, History } from '@reach/router';
import React from 'react';
type ReachHistory = History & {
_onTransitionComplete: () => void;
};
/**
* Why is `SuspenseRedirect` necessary when @reach/router has `Redirect`?
*
@jaredpalmer
jaredpalmer / SearchUtil.java
Created Jul 21, 2020
Search String parser
View SearchUtil.java
package org.formium.util;
import java.util.HashMap;
import java.util.Map;
import java.util.StringJoiner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class SearchUtil {
public static Map<String,String> parseSearchQuery(String query) {