$
=>document.querySelector
$$
=>document.querySelectorAll
$0/$1/$2/$3/$4
: most recently selected elementinspect(elem)
: take you to Element tab for dom inpsectiongetEventListeners(elem)
✨monitorEvents(elem, ...event)
&unmonitorEvents(elem, ...event)
✨debug(fn)
&undebug(fn)
: perfer UI insteadmonitor(fn)
&unmonitor(fn)
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:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function superhero(clazz) { | |
Object.defineProperty(clazz.prototype, 'isSuperHero', {value: true}); | |
return clazz; | |
} | |
@superhero | |
class MySuperHero { | |
constructor(first, last) { | |
this.name = `${first} ${last}`; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class YourConstruct { | |
constructor() {} | |
// implement iterable protocol | |
[Symbol.iterator]() { | |
// return an iterator | |
return { | |
// the iterator is iterable! | |
[Symbol.iterator]() { | |
return this; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// `yield*`: yield delegation | |
function* gen1() { | |
yield gen2(); | |
yield* gen2(); | |
yield [3, 4]; | |
yield* [3, 4]; | |
} | |
function* gen2() { | |
yield 1; |