I hereby claim:
- I am anthowen on github.
- I am anthowen (https://keybase.io/anthowen) on keybase.
- I have a public key ASAmE0avnfMrHgBJsztetVeYwduvdAJAEVOgvKoLlVCxswo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
ruby '2.7.1' | |
gem 'rails', github: 'rails/rails' | |
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data | |
# Action Text | |
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra' | |
gem 'okra', github: 'basecamp/okra' | |
# Drivers |
import { useEffect, RefObject } from 'react'; | |
/** | |
* Hook that handles outside click event of the passed refs | |
* | |
* @param refs array of refs | |
* @param handler a handler function to be called when clicked outside | |
*/ | |
export default function useOutsideClick( | |
refs: Array<RefObject<HTMLElement> | undefined>, |
import { useState, useReducer, useEffect } from 'react'; | |
import { Nullable } from 'interfaces'; | |
type SearchState<T> = { | |
results: Array<T>; | |
isSearching: boolean; | |
isError: boolean; | |
}; | |
type SearchAction<T> = | |
| { type: 'FETCH_INIT' } |
// Note: I write down only essential parts of the component, because the other part can make sense without itself. | |
import { useFilter } from 'hooks/useFilter.ts'; | |
import debounce from 'lib/debounce'; | |
function InputSearch({...} : InputSearchInterface) { | |
// api - a search api wrapper that returns promise | |
// useFilter - a custom react hook used for search (https://gist.github.com/anthowen/7309f9d54dcdeefcefab1e37a75d716c) | |
const [{ results, isSearching }, doFilter] = useFilter<T>(api, null, []); |
{ | |
// Place your snippets for typescriptreact here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
// "Print to console": { | |
// "prefix": "log", | |
// "body": [ | |
// "console.log('$1');", |
const debounce = <F extends (...args: any[]) => any>( | |
func: F, | |
waitFor: number, | |
) => { | |
let timeout: NodeJS.Timeout; | |
return (...args: Parameters<F>): Promise<ReturnType<F>> => | |
new Promise((resolve) => { | |
if (timeout) { | |
clearTimeout(timeout); |
let [hasNextPage, setHasNextPage] = React.useState(true) | |
const { data } = useInfiniteQuery(key, (key, nextPage) => { | |
const data = fetch('/api?page=' + nextPage) | |
if (data.length) { | |
return data | |
} else { | |
setHasNextPage(false) | |
return [] |
2019 update: this essay has been updated on my personal site, together with a followup on how to get started
2020 update: I'm now writing a book with updated versions of all these essays and 35 other chapters!!!!
If there's a golden rule, it's this one, so I put it first. All the other rules are more or less elaborations of this rule #1.
You already know that you will never be done learning. But most people "learn in private", and lurk. They consume content without creating any themselves. Again, that's fine, but we're here to talk about being in the top quintile. What you do here is to have a habit of creating learning exhaust. Write blogs and tutorials and cheatsheets. Speak at meetups and conferences. Ask and answer things on Stackoverflow or Reddit. (Avoid the walled gardens like Slack and Discourse, they're not public). Make Youtube videos