Skip to content

Instantly share code, notes, and snippets.

View scriptonian's full-sized avatar

I-am Konstantin scriptonian

View GitHub Profile
This must be done in bash_profile
#if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exits
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
open zsh config : vim ~/.zshrc
At the bottom of the file add : source ~/.bash_profile
prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
fi
}
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
@scriptonian
scriptonian / bst-shell-es5.js
Last active August 29, 2017 19:12
Binary Search Tree Class Shell
//ES5 version
function TreeNode(keyValue) {
this.keyValue = keyValue;
this.left = null;
this.right = null;
this.toString = function() {
return this.keyValue;
}
}
@scriptonian
scriptonian / bst-shell-es5.js
Last active September 5, 2017 15:41
Adding the BST methods to class. Insert, find, remove, max, min and traversal
//ES5 version
function TreeNode(keyValue) {
this.keyValue = keyValue;
this.left = null;
this.right = null;
this.toString = function() {
return this.keyValue;
}
}
@scriptonian
scriptonian / bst-insert-es5.js
Last active September 6, 2017 14:13
Binary Search Tree Insert Method
//ES5 VERSION
BinarySearchTree.prototype = {
insert: function(key) {
//create a new tree
var newNode = new TreeNode(key);
//if root is empty set the new node to be the root, else add recursively
this.root === null ? this.root = newNode : this.insertTo(this.root, newNode);
//increment counter
this.count++;
},
@scriptonian
scriptonian / bst-insert-test.js
Created September 6, 2017 14:57
Binary Search Tree - Insert Test
var bst = new BinarySearchTree();
bst.insert(60);
bst.insert(30);
bst.insert(85);
bst.insert(95);
bst.insert(80);
bst.insert(35);
bst.insert(20);
console.log(bst);
BinarySearchTree.prototype = {
/*
other code here
*/
inOrder: function(node){
if (node !== null) {
//print the left subtree recursively
this.inOrder(node.left);
//print the root node
console.log(node.toString());
@scriptonian
scriptonian / bst-inorder-preorder-postorder.js
Last active September 9, 2017 15:32
Binary Search Tree Traversal
BinarySearchTree.prototype = {
/*
other code here
*/
inOrder: function(node){
if (node !== null) {
//print the left subtree recursively
this.inOrder(node.left);
//print the root node