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 / gotcha.md
Created May 20, 2016 13:06
gotchas of web app debugging
@royling
royling / note.md
Last active May 9, 2016 07:16
`(0, mod.fn)(args)` in babel transpiled code

Found an interesting snippet in the babel transpiled code.

For the below ES6 code snippet:

import { speak } from './mod_test';
speak('world');

Babel will transpile it to ES5 as below:

@royling
royling / d.sh
Last active February 21, 2016 06:37
shell commands for Node development in Docker containers
#!/bin/bash
# run `npm install` (or any command) in a container of `node:latest` image
# - mount current dir to the working directory /ws in container
# - one-off container
docker run -it --rm -v $PWD:/ws -w /ws node npm install
@royling
royling / index.html
Last active February 25, 2016 02:03
CSS blending
<!DOCTYPE html>
<head>
<title>CSS Blending</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div>
<input id="backdropColor" type="text" placeholder="Backdrop color, eg. #ffffff/white"><br>
<input id="sourceColor" type="text" placeholder="Source color, eg. #000000/black"><br>
<select name="blendingMode" id="blendingMode"></select>
@royling
royling / FuturesB.java
Created January 13, 2016 04:39 — forked from benjchristensen/FuturesB.java
FuturesB.java Example of using Futures for nested calls showing how it blocks inefficiently.
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@royling
royling / bashrc
Created October 18, 2015 09:39
bashrc
alias ls='ls -aGFh'
alias ll='ls -l'
git_repo() {
git rev-parse --is-inside-work-tree &> /dev/null
return $?
}
git_branch() {
git branch --no-color 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
@royling
royling / Minion in Pure CSS.markdown
Created September 6, 2015 01:30
Minion in Pure CSS

Minion in Pure CSS

CSS minion from Despicable Me recreated in pure CSS. This was created with only CSS3 shapes using pseudo classes and box-shadows.

A Pen by Rachel on CodePen.

License.

function superhero(clazz) {
Object.defineProperty(clazz.prototype, 'isSuperHero', {value: true});
return clazz;
}
@superhero
class MySuperHero {
constructor(first, last) {
this.name = `${first} ${last}`;
}
@royling
royling / 1_iterable.js
Last active August 29, 2015 14:27
Implement an iterable and make the iterators also iterable which leads to continuable iteration
class YourConstruct {
constructor() {}
// implement iterable protocol
[Symbol.iterator]() {
// return an iterator
return {
// the iterator is iterable!
[Symbol.iterator]() {
return this;
@royling
royling / es6-generator-yield.js
Created August 12, 2015 05:13
try out ES2015 Generator - yield vs. yield* (delegation)
// `yield*`: yield delegation
function* gen1() {
yield gen2();
yield* gen2();
yield [3, 4];
yield* [3, 4];
}
function* gen2() {
yield 1;