Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢
No idea

Fraser Xu fraserxu

🐢
No idea
View GitHub Profile
View for-loop-with-async.js
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)
)
View 3.4-with-increment.txt
➜ 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 / dev_setup.txt
Last active Jan 20, 2018 — forked from brblck/dev_setup.txt
Local Setup for .test Domains (dnsmasq + nginx)
View dev_setup.txt
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 Mar 7, 2017
The great node yarn upgrade guide
View upgrade.md

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 Jan 5, 2017
handle chained async actions in redux
View appActions.js
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 Aug 30, 2016
getQueriesTree
View button.js
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
kill all running node process
View kill all running node process
ps aux | grep node | awk 'FNR > 1 {print $2}' | xargs kill -9
@fraserxu
fraserxu / set_npm.sh
Last active Jan 7, 2017
npm versioning in nodenv
View set_npm.sh
#!/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"
You can’t perform that action at this time.