Skip to content

Instantly share code, notes, and snippets.

View sdtsui's full-sized avatar

Daniel Tsui sdtsui

View GitHub Profile
@sdtsui
sdtsui / Enhance.js
Created June 17, 2016 22:28 — forked from sebmarkbage/Enhance.js
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@sdtsui
sdtsui / pubsub.js
Created June 1, 2016 14:00
pubsub.js
// functional publish/subscribe
let Observers = [];
function subscribe(observer) {
Observers.push(observer);
}
function publish(event) {
Observers.forEach((observer) => {
observer(event);
@sdtsui
sdtsui / stylelint-webpack-plugin-3-package.json
Created May 6, 2016 06:55
stylelint-webpack-plugin-3-package.json
{
"name": "lander",
"version": "0.0.3",
"description": "",
"main": "app.js",
"author": "Sze-Hung Tsui <danielt213@gmail.com>",
"scripts": {
"start": "node .",
"lint": "eslint * --cache --quiet --fix",
"lint-css": "stylelint '**/*.css'"
@sdtsui
sdtsui / stylelint-webpack-plugin-3
Last active May 6, 2016 06:49
stylelint-webpack-plugin-#3
const webpack = require('webpack');
const path = require('path');
const FlowStatusWebpackPlugin = require('flow-status-webpack-plugin');
// const styleLintPlugin = require('stylelint-webpack-plugin');
// const globPath = path.join(__dirname, 'app') + '/**/*.css';
// const globPath = path.join(__dirname, 'app', 'js', 'components', '404Page') + '/404Page.css';
// console.log("PATH ::", globPath);
module.exports = {
@sdtsui
sdtsui / siteRow-fp.js
Created May 3, 2016 06:07
siteRow-fp.js
// @flow
import React from 'react';
import styles from './SiteRow.css';
import classnames from 'classnames';
import _ from 'lodash/fp';
import R from 'ramda';
/**
* Vanilla JS
*/
@sdtsui
sdtsui / server,js
Created April 1, 2016 03:51
Simple Express Server
var express = require('express')
express().use('/',express.static(__dirname)).listen(8080);
console.log("Listening on 8080...");
@sdtsui
sdtsui / marty-to-redux-cliffs-notes.md
Last active March 24, 2016 03:22
marty-to-redux-cliffs-notes.md

1:1 - Constants : const

Action creators : functions

  export function updateEmail (userId, email) {
    return {
      type: 'UPDATE_EMAIL',
      payload: { userId, email }
    }
  }
@sdtsui
sdtsui / marty-to-redux.md
Created March 24, 2016 01:54 — forked from jhollingworth/marty-to-redux.md
Translating Marty to Redux

#Translating Marty to Redux

Some people have asked how I've translated a Marty app to Redux. Once you get your head around how Redux works I found concepts in Marty translated easily. Below is side-by-side comparison of the two libraries to help you along the way.

Also if you're looking for some devtools, check out redux-devtools.

##Constants

Marty

@sdtsui
sdtsui / keybase.md
Created March 22, 2016 18:57
keybase.md

Keybase proof

I hereby claim:

  • I am sdtsui on github.
  • I am dan_t (https://keybase.io/dan_t) on keybase.
  • I have a public key ASAhHccu51UVTRIVwPzgckls7UBdYUYnBjv5Jcwm1QCmpgo

To claim this, I am signing this object:

@sdtsui
sdtsui / smoothScrollUsage.js
Created March 7, 2016 23:24
Smooth Scroll Usage Example
//spike code
import smoothScroll from 'smooth-scroll/dist/js/smooth-scroll';
function goTo(href, offset) {
console.log("goTo:", href, offset);
smoothScroll.animateScroll(href, null, { updateURL: false, offset: offset || 0 })
}
window.goTo = goTo;
console.log('goTo assigned: ', goTo);