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 | |
| # usage ch-hadoop production|qa | |
| cd /Users/yranadive/hadoop/etc/hadoop | |
| if [ $1 = 'production' ] | |
| then | |
| rm core-site.xml | |
| rm hdfs-site.xml | |
| rm mapred-site.xml | |
| rm yarn-site.xml |
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
| # Example of webgl rendered with orbitcontrols | |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <title>Vorcel</title> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> | |
| <style> | |
| body { | |
| font-family: Monospace; |
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 PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
| <html lang="en"> | |
| <head> | |
| <title>Dashboard Example</title> | |
| <style type="text/css"> | |
| body, html { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; } | |
| iframe { border: none; width: 100%; height: 100%; display: none; } | |
| iframe.active { display: block;} | |
| </style> | |
| <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script> |
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 Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
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
| //Async load items from a remote API | |
| loadItemsInStore(collection) { | |
| this.setState({ isFetchingItemsFromRemote: true}); | |
| let promises = []; | |
| for(let c of collection.values()) { | |
| promises.push(ItemService.getItems(c.id)); | |
| } | |
| let allPromises = Promise.all(promises); | |
| //Fulfill the Promise |
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
| // THis is for getting the search history on chrome | |
| //Navigate to chrome://history/ | |
| //Search for "google.com/search/?q=" in the search box | |
| function writeChromeHistoryToFile(fileName) { | |
| coln = document.getElementsByTagName("a") | |
| data = [].slice.call(coln).map((x) => x.href) | |
| if(typeof data === "object"){ | |
| data = JSON.stringify(data, undefined, 4) | |
| } |
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
| #################TREES############ | |
| # The TreeNode Class | |
| class Node | |
| attr_accessor :left, :right, :val | |
| def initialize(val) | |
| @val = val | |
| @left = nil | |
| @right = nil | |
| end | |
| end |
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
| # find if a tree is balanced | |
| # i.e. no two nodes are more than 1 level away from root | |
| # i.e. maxdepth - mindepth <= 1 | |
| def max_depth(root) | |
| return 0 if root.nil? | |
| return 1 + [max_depth(root.left) , max_depth(root.right)].max | |
| end | |
| def min_depth(root) | |
| return 0 if root.nil? |
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
| def common_anc(root, p, q) | |
| return root if (root.nil? || p == root.val || q == root.val) | |
| left = common_anc(root.left, p, q) | |
| right = common_anc(root.right, p, q) | |
| left && right ? root : left || right | |
| end | |
| common_anc(head, 4, 5) |
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
| # returns depth and node at the maximum depth | |
| def max_depth(node) | |
| return [0, node] if node.nil? | |
| left = max_depth(node.left) + 1 | |
| right = max_depth(node.right) + 1 | |
| left[0] > right[0] ? left : right | |
| ends |