Skip to content

Instantly share code, notes, and snippets.

View royling's full-sized avatar
🔬
Keep practicing and learning everyday!

Roy Ling royling

🔬
Keep practicing and learning everyday!
View GitHub Profile
@royling
royling / key_rules.md
Last active November 4, 2016 06:17
A git branching model

The key rules of this model are:

  • origin/master always reflects a production-ready state.
  • origin/develop always reflects a state with the latest delivered development changes for the next release.
  • Each time when changes are merged back into master, it's a new production release.
  • Other branch types supporting other purposes:
    1. feature/topic branches: develop new features for the upcoming or a distant future release.
  • branch off from develop and merge back to develop once finished.
@royling
royling / note.md
Last active October 10, 2016 08:25
BEM methodology

BEM (Block, Element, Modifier): a methodology/guideline for scalable web

  • Component based methodology/archetecture (reusable)
  • Guideline for scalable web development (maintainable)

Unified terminology: Block/Element/Modifier

  • Block: independent, reusable (equivalent to component in Web Components)
  • Element: composite part of a block
    • optional
@royling
royling / brew_cask.md
Last active October 9, 2016 09:11
Homebrew formulas

Installation:

brew tap caskroom/cask

Casks (/usr/local/Caskroom)

  • mojibar 👍
@royling
royling / promise.all.ts
Last active October 21, 2016 05:42
Promise.all in short
// inline type declaration for ES6 Promise object
// see full at https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/es6-promise/es6-promise.d.ts
declare class Promise {
constructor(callback: (resolve: (value?: any) => void, reject: (reason?: any) => void) => void);
then(onFulfilled?: (any) => any, onRejected?: (any) => any|void);
}
const isPromise: (p:any) => boolean = p => typeof p === 'object' && typeof p.then === 'function';
const promiseAll: (promises:any[]) => Promise = promises => new Promise((resolve, reject) => {
@royling
royling / webdriver-manager.md
Last active September 21, 2021 21:23
UNABLE_TO_GET_ISSUER_CERT_LOCALLY/"Error: unable to get local issuer certificate" with `webdriver-manager update`

With angular-cli, it helps create an angular2 app quickly. All required tools are provisioned in a simple command ng new, including Protractor - the end-to-end testing tool for angular.

To perform the testing, run ng e2e. It will first run webdriver-manager update to download & install webdrivers, see pree2e script in package.json. However, the below error may be encountered if you are in a corporate network:

[15:10:59] E/downloader - { Error: unable to get local issuer certificate
    at Error (native)
    at TLSSocket.<anonymous> (_tls_wrap.js:1060:38)
    at emitNone (events.js:86:13)
 at TLSSocket.emit (events.js:185:7)
@royling
royling / array-custom-prop-not-iterable.js
Last active September 27, 2016 09:59
JavaScript: Wat!
// A custom property on an array is **not iterable**
const arr = [1,2];
arr[10] = 10; // => [1, 2, undefined*8, 10]
arr['ok'] = 'ok';
// for-in: enumerable properties:
for (const index in arr) console.log(arr[index]); // => 1, 2, 10, 'ok'
// for-of: iterable
for (const value of arr) console.log(value); // => 1, 2, undefined*8, 10
@royling
royling / tmux-iterm2.md
Last active April 24, 2023 19:35
tmux in iTerm2 cheatsheet
@royling
royling / socks_proxy.sh
Last active October 9, 2016 08:53
Turn your Mac/Linux host to a SOCKS server in one cmd
#!/bin/bash
# try to kill existing process
ps aux | awk '/[s]sh -D 7070/ {print $2}' | xargs kill
# delay 1s
sleep 1
# start SOCKS proxy
ssh -D 7070 -fN user@host
@royling
royling / polling-vs-session-timeout.md
Last active September 6, 2016 09:38
Polling vs. Session timeout

Polling vs. Session timeout

TL;DR

In order to keep a page up-to-date or simulate notification push, we can fetching data from server by sending requests (eg. ajax) periodically. This is so-called polling, but this will cause security risks that session never timeout.

Solution/Workaround

It's not easy to fix this issue with a simple configuration in web server (eg. Tomcat),