Skip to content

Instantly share code, notes, and snippets.

View kccheung's full-sized avatar
🎯
Focusing

David C kccheung

🎯
Focusing
  • Hong Kong SAR China
View GitHub Profile
@kccheung
kccheung / INSTRUCTIONS_TYPESCRIPT_ENUM.md
Created March 12, 2017 08:20
An simple instructions on how to use enum in typescript

In TypeScript 1.8+, you can create a string literal type to define the type and an object with the same name for the list of values. It mimics a string enum's expected behaviour.

Here's an example:

type MyStringEnum = "member1" | "member2";

const MyStringEnum = {
    Member1: "member1" as MyStringEnum,
    Member2: "member2" as MyStringEnum

};

@kccheung
kccheung / INSTRUCTIONS_MOBX.md
Last active March 12, 2017 08:14 — forked from darklight721/INSTRUCTIONS.md
Using MobX with decorators in React Native

Using MobX with decorators in React Native

The following instructions should work with React Native v0.32:

  1. Install mobx libraries.

    npm install mobx --save
    npm install mobx-react --save
http lib connect timeout (ms) read timeout write timeout concurrency
OkHttp, retrofit, picasso 10,000 10,000 10,000 64 total, 5 per host
Volley 2,500 2,500 2,500 4
HttpUrlConnection up to few minutes up to few minutes n/a 5
@kccheung
kccheung / SingletonDefaultExportInstance.js
Created January 27, 2017 06:14 — forked from dmnsgn/SingletonDefaultExportInstance.js
ES6 singleton pattern: module default exports an instance
class SingletonDefaultExportInstance {
constructor() {
this._type = 'SingletonDefaultExportInstance';
}
singletonMethod() {
return 'singletonMethod';
}
static staticMethod() {
@kccheung
kccheung / Readme.markdown
Created January 11, 2017 07:19 — forked from mat/Readme.markdown
apple-app-site-association —with examples

“apple-app-site-association” file

One file for each domain, both www.example.com and example.com need separate files:

{
    "applinks": {
        "apps": [],
        "details": {
 "9JA89QQLNQ.com.apple.wwdc": {
@kccheung
kccheung / npm-cheat-sheet.md
Created December 26, 2016 09:01 — forked from AvnerCohen/npm-cheat-sheet.md
Node.js - npm Cheat Sheet

Node.js - npm Cheat Sheet

(Full description and list of commands at - https://npmjs.org/doc/index.html)

##List of less common (however useful) NPM commands

######Prepand ./bin to your $PATH Make sure to export your local $PATH and prepand relative ./node_modules/.bin/:

@kccheung
kccheung / iterm2.md
Last active December 26, 2016 08:51
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
Previous Tab + Left Arrow
Next Tab + Right Arrow
Go to Tab + Number
Go to Window + Option + Number
Go to Split Pane by Direction + Option + Arrow
Go to Split Pane by Order of Use + ] , + [
public class WeakSubscriberDecorator<T> extends Subscriber<T> {
private final WeakReference<Subscriber<T>> mWeakSubscriber;
public WeakSubscriberDecorator(Subscriber<T> subscriber) {
this.mWeakSubscriber = new WeakReference<Subscriber<T>>(subscriber);
}
@kccheung
kccheung / Logger
Created August 24, 2016 08:38 — forked from eefret/Logger
Logger class
import android.util.Log;
/**
* @author eefret
* Created by Christopher T. Herrera (eefret) on 4/22/2014 [12:41 AM]
* Wrapper class for android Logging utility will select a tag automatically from class, method and line number executed.
*/
public class Logger {
//TODO Create a detail Enum to define the log detail level.
//TODO Create a method that halt every log possible based on the development mode Ex: (PRODUCTION, DEVELOPMENT, DEBUG) that can manage what can be and can't be logged
@kccheung
kccheung / checkstock.py
Created August 13, 2016 15:13 — forked from t1m0thy/checkstock.py
Script to check stock at apple stores
"""
For more part numbers for other phone models etc, look here:
http://www.everyi.com/by-identifier/ipod-iphone-ipad-specs-by-apple-order-number-part-number.html
"""
import requests
import urllib
BASE_URL = "http://www.apple.com/shop/retailStore/availabilitySearch?"