Skip to content

Instantly share code, notes, and snippets.

View tjwudi's full-sized avatar

Di Wu tjwudi

View GitHub Profile
tjwudi /
Last active August 4, 2017 20:58
Roundtable - React & Redux

We use CodeSandbox for this interactive session.


JSX is just syntax sugar for some React JavaScript API. For example, the following JSX code ...

<DashboardUnit data-index="2">
tjwudi /
Created October 26, 2016 00:45
def sign_in(user_credential, role):
"""Sign in an user.
:param user_credential: User's credential
:param role:
init: function(elevators, floors) {
function Controller (elevator) {
var currentController = this;
this.elevator = elevator;
elevator.on('floor_button_pressed', function (floorNum) {
init: function(elevators, floors) {
function Tour (pickupRequest, direction, startFloorNum) {
this.pickingUp = !!pickupRequest;
this.pickupRequest = pickupRequest;
this.direction = direction; // either 'up' or 'down'
this.startFloorNum = startFloorNum;
function Controller (elevator) {
tjwudi / gist:3d1f98981e52a387015b
Created November 22, 2015 22:54
++ timestamp
+++ date +%s.%N
++ echo 1448231881.012023753
+ scriptstarttime=1448231881.012023753
+ readonly INTERNAL_ERROR_CODE=123
+ exist_file_or_die /mnt/prog_joined.js
+ local file=/mnt/prog_joined.js
+ '[' '!' -f /mnt/prog_joined.js ']'
+ exist_file_or_die /mnt/
tjwudi /
Last active November 23, 2015 07:00
Vim Bullet Points

Command Mode

  • 'a' - append after the cursor
  • 'A' - append at the end of current line


  • :vimgrep can help you to search through multiple files. It also tells you where you are now in the search. You can use :copen to see all matches.
  • :vnew Open an empty buffer as a vertical split
  • :%s/old/new/gc Replace all old with new throughout file with confirmations
tjwudi / main.yml
Created October 14, 2015 05:13 — forked from rothgar/main.yml
Generate /etc/hosts with Ansible
# Idempotent way to build a /etc/hosts file with Ansible using your Ansible hosts inventory for a source.
# Will include all hosts the playbook is run on.
# Inspired from
- name: "Build hosts file"
lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}" state=present
when: hostvars[item].ansible_default_ipv4.address is defined
with_items: groups['all']
echo 1
sudo add-apt-repository ppa:webupd8team/java -y
sudo apt-get update
sudo apt-get install -y oracle-java8-installer
sudo apt-get install -y oracle-java8-set-default
sudo apt-key adv --keyserver --recv E56151BF
DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
CODENAME=$(lsb_release -cs)
echo "deb${DISTRO} ${CODENAME} main" | sudo tee /etc/apt/sources.list.d/mesosphere.list
sudo apt-get -y update
sudo apt-get install -y mesosphere
s = status
co = checkout
p = push
c = commit
a = add
aa = add -A
ap = add -p