Skip to content

Instantly share code, notes, and snippets.

View jaredpalmer's full-sized avatar

Jared Palmer jaredpalmer

View GitHub Profile
@jaredpalmer
jaredpalmer / forwardRefWithAs.tsx
Created February 26, 2020 14:56
forwardRefWithAs
import * as React from 'react';
/**
* React.Ref uses the readonly type `React.RefObject` instead of
* `React.MutableRefObject`, We pretty much always assume ref objects are
* mutable (at least when we create them), so this type is a workaround so some
* of the weird mechanics of using refs with TS.
*/
export type AssignableRef<ValueType> =
| {

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

@jaredpalmer
jaredpalmer / banned.txt
Created August 7, 2019 18:02
Banned Strings
.htaccess
.htpasswd
.well-known
(null)
+++ATH0
2 girls 1 cup
2g1c
400
401
403
@jaredpalmer
jaredpalmer / useQuery.ts
Created May 14, 2019 20:24
Suspense-ready useQuery
import { ApolloError } from 'apollo-boost';
import { print } from 'graphql/language/printer';
import React from 'react';
const queries = new Map();
const getCacheKey = ({ query, ...opts }) =>
`${print(query)}@@${JSON.stringify(opts)}`;
const invalidateCachedQuery = options =>
@jaredpalmer
jaredpalmer / easing.css
Created April 20, 2019 19:15 — forked from bendc/easing.css
Easing CSS variables
:root {
--ease-in-quad: cubic-bezier(.55, .085, .68, .53);
--ease-in-cubic: cubic-bezier(.550, .055, .675, .19);
--ease-in-quart: cubic-bezier(.895, .03, .685, .22);
--ease-in-quint: cubic-bezier(.755, .05, .855, .06);
--ease-in-expo: cubic-bezier(.95, .05, .795, .035);
--ease-in-circ: cubic-bezier(.6, .04, .98, .335);
--ease-out-quad: cubic-bezier(.25, .46, .45, .94);
--ease-out-cubic: cubic-bezier(.215, .61, .355, 1);
@jaredpalmer
jaredpalmer / codegen.sh
Last active October 10, 2023 17:41
Swagger Codegen TypeScript Axios
#!/bin/bash
# Required: mvn, java, prettier
# Assume you have your API running on port 8080 and swagger is available at http://localhost:8080/swagger.json
# Assume this script file is in a folder called web that is a sibling to swagger codegen
if [[ ! -d ../swagger-codegen/modules/swagger-codegen-cli/target ]]; then
cd ../swagger-codegen # path to codegen
mvn clean package -DskipTests
cd ../web # path to your app
fi
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Formik, FormikProps, ErrorMessage } from '../src';
import { noop } from './testHelpers';
import { act } from 'react-dom/test-utils';
interface TestFormValues {
name: string;
email: string;
}
@jaredpalmer
jaredpalmer / build.js
Created January 15, 2019 13:17
Cross-repo Netlify Webhook Build
var shell = require('shelljs');
var fs = require('fs-extra');
var path = require('path');
console.log('WEBHOOK_BODY', process.env.WEBHOOK_BODY);
if (!shell.which('git')) {
shell.echo('Sorry, this script requires git');
shell.exit(1);
}
@jaredpalmer
jaredpalmer / Postinstall.js
Created September 19, 2018 13:36
Netlify Webhook Codeload from different website
var shell = require('shelljs');
var fs = require('fs-extra');
var path = require('path');
console.log('WEBHOOK_BODY', process.env.WEBHOOK_BODY);
if (!shell.which('git')) {
shell.echo('Sorry, this script requires git');
shell.exit(1);
}
@jaredpalmer
jaredpalmer / all-html-elements.html
Created September 17, 2018 16:13
All HTML Elements
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML5 Test Page</title>
</head>
<body>
<div id="top" class="page" role="document">
<header role="banner">