Skip to content

Instantly share code, notes, and snippets.

View lulalachen's full-sized avatar
🎯
Focusing

Lulala Chen lulalachen

🎯
Focusing
View GitHub Profile
@lulalachen
lulalachen / index.js
Created May 14, 2014 17:52
requirebin sketch
// example using the raf module from npm. try changing some values!
var requestAnimationFrame = require("raf")
var canvas = document.createElement("canvas")
canvas.width = 500
canvas.height = 500
document.body.appendChild(canvas)
var context = canvas.getContext("2d")
@lulalachen
lulalachen / index.js
Created May 14, 2014 17:52
requirebin sketch
// example using the raf module from npm. try changing some values!
var requestAnimationFrame = require("raf")
var canvas = document.createElement("canvas")
canvas.width = 500
canvas.height = 500
document.body.appendChild(canvas)
var context = canvas.getContext("2d")
class Solution(object):
def gameOfLife(self, board):
"""
:type board: List[List[int]]
:rtype: void Do not return anything, modify board in-place instead.
"""
answer = copy.deepcopy(board)
row = len(board)
col = len(board[0])
@lulalachen
lulalachen / orderFood.js
Last active June 7, 2016 06:19
Redux Action Inprovemnet
import { genAuthHeaderFromState } from '../api';
import { default as apiFetcher } from '../api/apiFetcher';
// redux-api-middleware
export const orderList = () => ({
[CALL_API]: ({
endpoint: 'http://food.com/order/list/',
method: 'GET',
headers: genAuthHeadersFromState,
})
@lulalachen
lulalachen / .aliases
Last active March 11, 2016 06:53
Useful Aliases
# ~/.aliases
# Put alias under this file
## Directory
alias wk="cd ~/Documents/workspace"
## Alias
alias sourcealias="source ~/.zshrc" # source new alias
alias newalias="createAlias && sourcealias" # eg: $newalias goToHomeAndSayHello "cd ~ && echo 'hello'"
createAlias() {
const fetcherCreateReduxStandardAPIActionMiddleware = () => {
return next => action => {
const { promise, type, ...rest } = action
if (!promise) return next(action)
const SUCCESS = type + '_SUCCESS'
const REQUEST = type + '_REQUEST'
const FAILURE = type + '_FAILURE'
next({ ...rest, type: REQUEST })

Structure

actions 
  |—— oneAction
      |—— constants.js
      |—— index.js
  |—— otherAction
      |—— constants.js
      |—— index.js
var options = {
method: 'GET',
headers: myHeaders,
}
fetch(url, options)
.then(response => console.log(response))
.catch(err => console.log(err))
@lulalachen
lulalachen / initializeServer.sh
Created July 19, 2016 13:58
Initialize Ubuntu Server 14.04.4 x64
# Update apt-get sources
sudo apt-get update
# Install git
sudo apt-get install git
# Install nvm
# To install or update nvm, you can use the install script using cURL:
# Check newest version: [release](https://github.com/creationix/nvm/releases)
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh | bash # OR
// ES6
const add = firstNumber = secondNumber => firstNumber + secondNumber
// ES5
var add = function (firstNumber) {
return function (secondNumber) {
return firstNumber + secondNumber
}
}