Skip to content

Instantly share code, notes, and snippets.

View flushentitypacket's full-sized avatar

Ronald Hong flushentitypacket

View GitHub Profile
@flushentitypacket
flushentitypacket / ron.zsh-theme
Last active November 17, 2016 16:27
ron's oh-my-zsh theme
local ret_status="%(?:%{$fg_bold[green]%}$ :%{$fg_bold[red]%}$ %s)"
PROMPT='%{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info) ${ret_status}%{$fg_bold[blue]%}% %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}%{$fg[yellow]%}*%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%}"
@flushentitypacket
flushentitypacket / redux.d.ts
Created January 20, 2018 19:33
Typescript Redux generic Action
// store/redux.d.ts
import {Action as ReduxAction} from 'redux'
export interface Action<
T extends string,
P = undefined
> extends ReduxAction {
type: T
payload: P
@flushentitypacket
flushentitypacket / addTodo.ts
Created January 20, 2018 19:36
Typescript Redux todo feature
// store/todo/addTodo.ts
import {Reducer} from 'redux'
import {Action} from 'store/redux' // our fancy new generic type!
interface Todo {
id: number
text: string
}
@flushentitypacket
flushentitypacket / addTodo.ts
Created January 20, 2018 19:38
Typescript Redux todo combination feature
// store/todo/addTodo.ts
import {Reducer} from 'redux'
import {Action} from 'store/redux' // our fancy new generic type!
interface Todo {
id: number
text: string
completed: boolean
}
@flushentitypacket
flushentitypacket / index.ts
Created January 20, 2018 19:39
Typescript Redux combine features in index
// store/todo/index.ts
import {combineReducers} from 'redux'
import {
State as TodoState,
reducer as todoReducer,
actions as todoActions,
} from './todo'
import {
State as RewardState,
@flushentitypacket
flushentitypacket / keybase.md
Created April 3, 2018 17:22
keybase: github proof

Keybase proof

I hereby claim:

  • I am flushentitypacket on github.
  • I am flushentitypack (https://keybase.io/flushentitypack) on keybase.
  • I have a public key ASDvnbfDbNd7WbFLT-uvUaBBxjRIKQtPF1dCOWKqGPmDnAo

To claim this, I am signing this object:

@flushentitypacket
flushentitypacket / install-node.sh
Last active August 9, 2018 18:00
Recommended way to set up node and yarn for Mac
# Assumes that you already have Homebrew installed. If not, do that!
# Helpful link: https://brew.sh/
# Install nvm by following instructions at https://github.com/creationix/nvm
nvm install --lts # installs latest LTS version
brew install yarn --without-node # installs yarn, a node package manager
@flushentitypacket
flushentitypacket / DragScrollProvider.tsx
Last active April 4, 2024 22:29
Typescript React component to provide click-and-drag scrolling
import * as React from 'react'
type DragScrollProvisions = {
onMouseDown: React.MouseEventHandler<HTMLElement>,
ref: React.Ref<HTMLElement>,
}
export type Props = {
children: (provisions: DragScrollProvisions) => React.ReactNode,
}
@flushentitypacket
flushentitypacket / HoverProvider.tsx
Last active August 15, 2018 20:10
Typescript React component to provide hover state.
import * as React from 'react'
type HoverProps = {
onMouseEnter: () => void,
onMouseLeave: () => void,
}
type ChildrenArgs = HoverProps & {
hoverProps: HoverProps,
isHover: boolean,
}
@flushentitypacket
flushentitypacket / _wrapSelector.ts
Last active August 30, 2018 22:25
Typescript Redux selector wrapper, useful for keeping selector logic within its own state module
type Selector<State, R = any> = (state: State) => R
// TODO:
// Preferred call signature:
// ```
// wrapSelector<S>(fn, key)
// ```
// But currently not possible due to "all-or-nothing" type arguments:
// https://github.com/Microsoft/TypeScript/issues/10571
export const wrapSelector = <S, SS extends Selector<S[keyof S]>>(