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
/************************** MODULE ***********************************************************************/ | |
'use strict'; | |
/*jshint esnext: true */ | |
import ShipmentDetailsRoute from './shipment-details.routes'; | |
import ShipmentDetailsCtrl from './shipment-details.controller'; |
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
(() => { | |
'use strict'; | |
/************************************************************* | |
* @ngdoc controller | |
* @name dashboard.customer.controller:CustomerCtrl | |
* | |
* @description | |
* | |
* CustomerCtrl Class for Customer Model |
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
//Building Data Structures with closures | |
//What's the plan? Build some data structures without using assignment, | |
//then building some functions which operate on those data structures. | |
//Why? Exploring what we can do with the closure property, and to get a better | |
//understanding of how it works. | |
/* | |
cons, first, rest, list, head, tail, length, each, |
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
//RECURSIVE HI-LIGHT | |
function highlight(word) { | |
var matchExp = new RegExp(word, 'g'); | |
var highlightExp = '<span class="highlight">' + word + '</span>'; | |
var traverseDom = function(tree) { | |
for (var i = 0; i < tree.children.length; i++) { | |
var node = tree.children[i]; | |
traverseDom(node); | |
tree.innerHTML = tree.innerHTML.replace(matchExp, highlightExp); |
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
/** | |
* MURMUR 3 HASH TABLE WITH OBJECT HASHING | |
* | |
* A hash table with `insert()`, `retrieve()`, and `remove()` methods. | |
* It handles hashing collisions correctly. And doubles the storage | |
* limit as soon as the total number of items stored is greater than | |
* 3/4th of the number of slots in the storage array. | |
* It resizes by half whenever utilization drops below 1/4. | |
* It also caches insertions at runtime for even faster retrieval. | |
*/ |
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
/*Once you get your data into a binary search tree, you can recurse it like below. | |
Use Depth First Traversal to keep track of the depth at each node in the tree. | |
On each recursive call, push the node at the current level to a hash table, using the | |
level as your key and the node as your value. | |
In JavaScript, you can use an array or an object literal to do this. I'm storing everything | |
in a JavaScript object literal which is similar to a hash table under the hood. Like this: | |
level = 0 |
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
'use strict'; | |
//implement a queue using two stacks | |
//create a stack data structure | |
function Stack() { | |
var storage = []; | |
this.push = function() { | |
storage.push.apply(storage, arguments); | |
}; |
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
/* Write a funciton to check to see if a binary Tree is balanced. | |
For the purposes of this tree, a balanced tree is defined to be a | |
tree such that the heights of the subtrees of any node never differ | |
by more than one */ | |
BinaryTree.prototype.isBalanced = function() { | |
var checkHeight = function(current) { | |
if (!current) return 0 //height = 0; |
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
'use strict'; | |
function BinarySearchTree() { | |
this.root = null; | |
} | |
BinarySearchTree.prototype.makeNode = function(value) { | |
var node = {}; | |
node.value = value; | |
node.left = null; |
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
//1) reverse a string without using any variables or | |
/*****************************************************/ | |
function reverseString(s) { | |
if (s === '') | |
return ''; | |
else | |
return s.slice(1) + s[0]; | |
} |