Skip to content

Instantly share code, notes, and snippets.

stop all containers:
docker kill $(docker ps -q)
remove all containers
docker rm $(docker ps -a -q)
remove all docker images
docker rmi $(docker images -q)
@pinkmomo027
pinkmomo027 / jsClass.js
Last active June 11, 2018 16:41
trying out javascript class
class TNode {
constructor (value) {
this.value = value;
this.left = null;
this.right = null;
}
print (level=0) {
@pinkmomo027
pinkmomo027 / randomize.js
Created June 11, 2018 17:45
generate random nodes
class TNode {
constructor (value) {
this.value = value;
this.left = null;
this.right = null;
}
print (level=0) {
@pinkmomo027
pinkmomo027 / org char illustration.js
Created June 11, 2018 21:05
hash to tree illustration
// A - B, C
// B - X,
// C - T, W
class Node {
constructor(value) {
this.value = value;
this.children = [];
}
@pinkmomo027
pinkmomo027 / parse html.js
Last active June 11, 2018 21:58
build html tree with stack
class Node {
constructor(value, parent) {
this.value = value;
this.parent = parent;
this.children = [];
}
add(child) {
this.children.push(child);
function traverse(node, level=0) {
let indent = "";
for (let i = 0; i < level; i++) {
indent += "*";
}
console.log(`${indent}${node.nodeName}`);
if (node.childNodes.length > 0 ){
node.childNodes.forEach(traverse, level+1);
}
}
@pinkmomo027
pinkmomo027 / TrieNode.js
Last active June 12, 2018 20:41
Trie Node
class TrieNode {
constructor (value, note="") {
this.value = value;
this.note = note;
this.children = new Array(26);
}
addChildNode (char, value=null) {
let index = char.charCodeAt(0) - 97;
this.children[index] = this.children[index] || new TrieNode(null, char);
@pinkmomo027
pinkmomo027 / clonetree.js
Last active June 13, 2018 00:06
Clone Tree
class Node {
constructor(value) {
this.value = value;
this.children = [];
}
add(child) {
this.children.push(child);
}
@pinkmomo027
pinkmomo027 / path.js
Last active June 13, 2018 03:51
find path to a node
class Node {
constructor(value) {
this.value = value;
this.children = [];
}
add(child) {
this.children.push(child);
}
@pinkmomo027
pinkmomo027 / lowestAncestor.js
Created June 13, 2018 04:00
Lowest Ancestor
class Node {
constructor(value) {
this.value = value;
this.children = [];
}
add(child) {
this.children.push(child);
}