Skip to content

Instantly share code, notes, and snippets.

Avatar

Jared Palmer jaredpalmer

View GitHub Profile
@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) {
@jaredpalmer
jaredpalmer / ValidateUtil.java
Created Jul 21, 2020
US Phone Validation w/ext
View ValidateUtil.java
package org.formium.util;
import com.google.i18n.phonenumbers.NumberParseException;
import com.google.i18n.phonenumbers.PhoneNumberUtil;
import com.google.i18n.phonenumbers.Phonenumber;
import java.util.Optional;
public class ValidateUtil {
public static Optional<String> validatePhone(String phone) {
@jaredpalmer
jaredpalmer / Video.js
Created Jul 8, 2020
Better <video> with intersection observer.
View Video.js
import { useRef, useCallback, useEffect } from 'react'
import { useInView } from 'react-intersection-observer'
import 'intersection-observer'
export default ({ src, caption, ratio }) => {
const [inViewRef, inView] = useInView({
threshold: 1,
})
const videoRef = useRef()
@jaredpalmer
jaredpalmer / react-scripts+3.4.1.patch
Created May 26, 2020
Speed up Create React App with TypeScript in development
View react-scripts+3.4.1.patch
diff --git a/node_modules/react-scripts/config/webpack.config.js b/node_modules/react-scripts/config/webpack.config.js
index 25840d9..25c3c41 100644
--- a/node_modules/react-scripts/config/webpack.config.js
+++ b/node_modules/react-scripts/config/webpack.config.js
@@ -172,7 +172,7 @@ module.exports = function(webpackEnv) {
// The build folder.
path: isEnvProduction ? paths.appBuild : undefined,
// Add /* filename */ comments to generated require()s in the output.
- pathinfo: isEnvDevelopment,
+ pathinfo: false,
View gist:534f11e860152864a850b498c42ab3bc
1) Create a branch with the tag
git branch {tagname}-branch {tagname}
git checkout {tagname}-branch
2) Include the fix manually if it's just a change ....
git add .
git ci -m "Fix included"
or cherry-pick the commit, whatever is easier
git cherry-pick {num_commit}
@jaredpalmer
jaredpalmer / .zshrc
Last active Mar 26, 2020
some zsh utils
View .zshrc
# Take a screenshot every n seconds
# Fun for making timelapse gifs later
# run `creep 20` for every 20 seconds
function creep() {
while :; do; echo "📸" $(date +%H:%M:%S); screencapture -x ~/Screenshots/wes/$(date +%s).png; sleep $1; done
}
alias db="cd ~/Dropbox/"
alias zs="source ~/.zshrc"
alias gum="git pull upstream master"
View forwardRefWithAs.tsx
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> =
| {
View 20111011_SteveYeggeGooglePlatformRant.md

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

You can’t perform that action at this time.