Skip to content

Instantly share code, notes, and snippets.

View flushentitypacket's full-sized avatar

Ronald Hong flushentitypacket

View GitHub Profile
@flushentitypacket
flushentitypacket / gevent_thread_demo.py
Created July 18, 2020 18:55
Difference between python thread vs gevent greenlet
#!/usr/bin/python
# Output is NOT interleaved
import gevent
def print_numbers(name):
count = 0
while count < 500:
count += 1
@flushentitypacket
flushentitypacket / http_load_test.sh
Last active July 18, 2020 16:56
Bash script to execute a parallel load test against some endpoint and print out the network latency data
#!/usr/bin/env bash
seq 1000 | \
time xargs -Idonotmatch -P 1000 \
curl "https://some.domain.here/path/to/resource?param=foo" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--write-out 'http_code:%{http_code} time_appconnect:%{time_appconnect} time_connect:%{time_connect} time_namelookup:%{time_namelookup} time_pretransfer:%{time_pretransfer} time_starttransfer:%{time_starttransfer} time_total:%{time_total}\n' \
--http1.1 -s -o /dev/null
# short test script to check whether request timeouts are affected by thread lock
import gevent
import gevent.monkey
import requests
import time
gevent.monkey.patch_all()
@flushentitypacket
flushentitypacket / foundations.md
Last active November 26, 2018 20:16
Foundational readings for a t0tal n00b trying to break into React
@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]>>(
@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 / 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 / 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 / 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 / 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,