Skip to content

Instantly share code, notes, and snippets.

@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);
@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 / 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 / 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) {
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 / nativeJavaScript.js
Created May 30, 2018 23:21 — forked from alexhawkins/nativeJavaScript.js
Implementation of Native JavaScript Methods (forEach, Map, Filter, Reduce, Every, Some)
'use strict';
/*****************NATIVE forEACH*********************/
Array.prototype.myEach = function(callback) {
for (var i = 0; i < this.length; i++)
callback(this[i], i, this);
};
//tests
@pinkmomo027
pinkmomo027 / docker-cleanup-resources.md
Created May 9, 2018 16:23 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

func Sqrt(x float64) float64 {
i := 1;
z := float64(1)
t := z - (z*z - x) / (2*z)
delta := 0.0000001
for math.Abs(t-z) > delta {
z = t
t = z - (z*z - x) / (2*z)
fmt.Println(z)
package main
import (
"fmt"
)
func Sqrt(x float64) float64 {
i := 0;
z := float64(1)
for i < 10 {
@pinkmomo027
pinkmomo027 / countSetBits.js
Created March 19, 2018 19:58
JS count binary set bits
i.toString(2).replace(/0/,'').length