Skip to content

Instantly share code, notes, and snippets.

View khanghoang's full-sized avatar
😬

Khang Hoang khanghoang

😬
  • Dropbox
  • San Jose, CA
  • 12:07 (UTC -06:00)
  • X @khanght
View GitHub Profile
@khanghoang
khanghoang / Proposal.md
Last active December 23, 2015 10:12
How to handle async in React?

How to handle async in React (with Reflux) app?

Principles

  • All components are dump, they are just view and render from their props.
  • Logic handling should be done in Component Wrapper (we call it container or page).

Async Component

  • Provide the interface for subclasses.
  • The subclass need to implement the idealView(), errorView(), emptyView(), loadingView() or use the defined class decorators, e.g: javascript @defaultLoadingDecorator
@khanghoang
khanghoang / Enum.es6.js
Created December 18, 2015 09:39 — forked from xmlking/Enum.es6.js
JavaScript Enums with ES6, Type Checking and Immutability
export class EnumSymbol {
sym = Symbol.for(name);
value: number;
description: string;
constructor(name: string, {value, description}) {
if(!Object.is(value, undefined)) this.value = value;
if(description) this.description = description;
@khanghoang
khanghoang / gist:33f002128da7f1a2fcf2
Created November 26, 2015 11:58 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@khanghoang
khanghoang / es6.md
Last active November 10, 2015 10:11
ES6 features

##ES6 features ###Symbol #####Another primary type
Among undefined, Null, Boolean, Number, String, Object #####To represent of concepts.

  • As property keys.
    Example: javascript const MY_KEY = Symbol(); let obj = {};
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby

@kangax's ES6 quiz, explained

@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).

Here we go with the explanations:

Question 1:
(function(x, f = () => x) {
@khanghoang
khanghoang / shipit-deployment.md
Last active June 28, 2016 19:48
ShipIt deployment for EC2

##Get started ###On local

  • Install shipit & shipit-deploy
  • Add shipitfile.js
  • Run ssh-add /path/to/pem/file

###Errors ####node: not found Apparently Debian has renamed the command node to nodejs which is causing the problem. For me installing nodejs-legacy fixed the issue.
To fix:

@khanghoang
khanghoang / shipitfile.js
Created November 8, 2015 09:15
ShipIt demo config file
module.exports = function (shipit) {
require('shipit-deploy')(shipit);
shipit.initConfig({
default: {
workspace: '../shipit-temp-folder',
deployTo: '~/express4-es6',
branch: "shipit",
repositoryUrl: 'https://github.com/khanghoang/express4-es6.git',
ignores: ['.git', 'node_modules'],
@khanghoang
khanghoang / UbuntuCommands.md
Last active November 8, 2015 09:04
Linux command cheat sheet
OS Command Meaning
Ubuntu `netstat -punta grep `
Mac OS `lsof -i grep LISTEN`