Skip to content

Instantly share code, notes, and snippets.

View evidanary's full-sized avatar

evidanary evidanary

View GitHub Profile
@evidanary
evidanary / gist:67fe12cb2bfeca21e2e4
Created August 20, 2014 17:43
ch-hadoop - a simple script to change where the hadoop configs point to on a machine
#!/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
@evidanary
evidanary / basic.webgl.html
Last active August 29, 2015 14:09
Basic Webgl Starter code - OrbitControls with a WebGLRenderer
# 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;
@evidanary
evidanary / team_dashboard.html
Created December 19, 2014 08:14
Simple Javascript that cycles through multiple webpages. This can be displayed on a TV.
<!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>
@evidanary
evidanary / 0_reuse_code.js
Created October 29, 2015 22:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@evidanary
evidanary / promise_all.js
Created March 29, 2016 18:04
Demonstrating Promise.all
//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
@evidanary
evidanary / gist:d02d89c632530878163f256fe993d5a4
Created July 27, 2016 00:57
Export search history from chrome
// 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)
}
@evidanary
evidanary / Trees.rb
Last active October 24, 2017 07:07
Basic Stuff for Trees
#################TREES############
# The TreeNode Class
class Node
attr_accessor :left, :right, :val
def initialize(val)
@val = val
@left = nil
@right = nil
end
end
# 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?
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)
# 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