Skip to content

Instantly share code, notes, and snippets.

View fraserxu's full-sized avatar
🐢
No idea

Fraser Xu fraserxu

🐢
No idea
View GitHub Profile
const array = [1, 2, 3, 4, 5]
const fetchData = i => {
console.log(`fetching ${i}...`)
return new Promise(resolve =>
setTimeout(() => {
console.log(`finished ${i}`)
resolve()
}, 1000)
)
➜ market-shopfront-api git:(master) ✗ while true; do time ./node_modules/.bin/tsc; sleep 2; done
./node_modules/.bin/tsc 3.56s user 0.19s system 177% cpu 2.105 total
./node_modules/.bin/tsc 2.81s user 0.14s system 189% cpu 1.556 total
./node_modules/.bin/tsc 2.64s user 0.14s system 191% cpu 1.453 total
./node_modules/.bin/tsc 2.53s user 0.14s system 182% cpu 1.458 total
./node_modules/.bin/tsc 2.69s user 0.14s system 188% cpu 1.497 total
./node_modules/.bin/tsc 2.77s user 0.16s system 179% cpu 1.632 total
./node_modules/.bin/tsc 2.62s user 0.14s system 186% cpu 1.476 total
./node_modules/.bin/tsc 2.59s user 0.14s system 187% cpu 1.456 total
./node_modules/.bin/tsc 2.90s user 0.16s system 188% cpu 1.623 total
@fraserxu
fraserxu / README.md
Created August 27, 2018 23:03 — forked from mchelen/README.md
JSON Resume Browser Example
@fraserxu
fraserxu / dev_setup.txt
Last active January 20, 2018 01:14 — forked from brndnblck/dev_setup.txt
Local Setup for .test Domains (dnsmasq + nginx)
sudo -v
brew install dnsmasq nginx
echo "address=/test/127.0.0.1" > /usr/local/etc/dnsmasq.conf
vim /usr/local/etc/nginx/nginx.conf
vim /usr/local/etc/nginx/servers/market-shopfront.conf
tee /usr/local/etc/nginx/nginx.conf > /dev/null << EOF
#user nobody;
@fraserxu
fraserxu / upgrade.md
Last active March 7, 2017 04:39
The great node yarn upgrade guide

Install node

We recommend use nvm instead of nodenv, you can install nvm with brew install nvm. And then you can use it to install the version we are using.

nvm install 6.10.0

Use the version

@fraserxu
fraserxu / appActions.js
Created January 5, 2017 00:06
handle chained async actions in redux
const loadUserRequest = { type: 'loadUserRequest' }
const loadUserSuccess = (user) => ({ type: 'loadUserSuccess', payload: user })
const loadUserFailure = (err) => ({ type: 'loadUserFailure', err })
const loadPostsRequest = { type: 'loadPostsRequest' }
const loadPostsSuccess = (posts) => ({ type: 'loadPostsSuccess', payload: posts })
const loadPostsFailure = (err) => ({ type: 'loadPostsFailure', err })
const loadUser = () => {
return (dispatch) => {
@fraserxu
fraserxu / button.js
Last active August 30, 2016 00:35
getQueriesTree
import React from 'react'
class Button extends React.Component {
static fetchData (props, context) {
return 'test'
}
render () {
return <button>not a button</button>
}
@fraserxu
fraserxu / kill all running node process
Created May 31, 2016 04:40
kill all running node process
ps aux | grep node | awk 'FNR > 1 {print $2}' | xargs kill -9
@fraserxu
fraserxu / set_npm.sh
Last active January 7, 2017 23:00
npm versioning in nodenv
#!/bin/bash
set -e
# /opt/boxen/nodenv/versions/4.4.4/bin/node
NODE_BIN_DIR="$(nodenv which node)"
# /opt/boxen/nodenv/versions/4.4.4/lib
NODE_LIB_DIR="${NODE_BIN_DIR%%bin*node}lib"