Skip to content

Instantly share code, notes, and snippets.

View Neo42's full-sized avatar
:shipit:

Johnny (Hao) Jiang Neo42

:shipit:
View GitHub Profile
@Neo42
Neo42 / quickSort.js
Last active March 25, 2022 06:43
Functional quick sort in 8 lines (non in-place)
const quickSort = ([pivot, ...rest]) =>
pivot
? [
...quickSort(rest.filter(x => x < pivot)),
pivot,
...quickSort(rest.filter(y => y >= pivot))
]
: []
@Neo42
Neo42 / io.js
Last active May 7, 2021 04:05
IO monad in JS
const IO = effect =>
({
effect,
run() {
return this.effect()
},
map(fn) {
if (!fn ?? typeof fn !== 'function') {
throw new Error('.map requires a function argument.')
}
@Neo42
Neo42 / vis.sh
Created March 30, 2021 12:32
Code for changing one's own membership visibility in a github organization
curl \ 20:19:16
-H "Accept: application/vnd.github.v3+json" \
# replace :token below with your personal access token
-H "Authorization: token :token" \
-H "Content-Length: 0" \
-X PUT \
# replace ORGNAME with your organization name and USERNAME your username
https://api.github.com/orgs/ORGNAME/public_members/USERNAME