This file contains 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
// reduce boils down a list of values into a single value | |
// var callback = function (previousValue, currentValue, index, array) { | |
// return previousValue + currentValue | |
// } | |
// [].reduce(callback, initialValue) | |
// | |
// Reduce invokes the callback on each item in the array. | |
// On the first invocation, the first item is passed to the callback as currentValue. | |
// and the initialValue is passed as the previousValue. | |
// The returned value of that is then passed into the next invocation of the second item as previousValue. |
This file contains 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
var x = [ {node: "ip2", app: "dbsyncer", containerId: "1234"}, | |
{node: "ip2", app: "logforwa", containerId: "3423"}, | |
{node: "ip4", app: "dbsyncer", containerId: "2213"}, | |
{node: "ip4", app: "logforwa", containerId: "3434"} ] | |
var newObj = {}; | |
x.forEach(function (item) { | |
newObj[item.node] = newObj[item.node] || []; | |
This file contains 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
(defn register-dom-complete [] | |
(aset js/document "onreadystatechange" | |
(fn [x] | |
(let [ready-state (.-readyState js/document)] | |
(if (= ready-state "complete") | |
(js/alert "DOM has completely loaded: invoke your callbacks here.") | |
))))) |
This file contains 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
(ns animation.core | |
(:require [reagent.core :as reagent])) | |
(enable-console-print!) | |
(def css-transition-group | |
(reagent/adapt-react-class js/React.addons.CSSTransitionGroup)) | |
(def style | |
".my-item { |
This file contains 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
# Remove Docker Images | |
docker rmi $(docker images -q) | |
docker rmi <img id> | |
# Remove Docker All Containers. | |
docker rm $(docker ps -a -q) | |
# Build Docker Image | |
docker build - < Dockerfile | |
doccker build -t <img name> </path/to/Dockerfile> |
This file contains 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
#user nobody; | |
worker_processes 1; | |
#error_log logs/error.log; | |
#error_log logs/error.log notice; | |
#error_log logs/error.log info; | |
#pid logs/nginx.pid; |
This file contains 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
//////////////////////// | |
// Solution #1 -- Adnan | |
//////////////////////// | |
function pairs (obj) { | |
var arr = [], key | |
for (key in obj) arr.push([key, obj[key]]) | |
return arr | |
} | |
var string = document.body.innerText | |
var counts = {}, order |
This file contains 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
// Given a string of text, output the characters ordered from | |
// highest to lowest, with each character paired with | |
// the number of times it occurs. | |
function displayCharOccuraces(text) { | |
window.charObj = {} | |
window.arr = [] | |
for (var i = 0; i < text.length; i++) { | |
if (!charObj[text[i]]) { |
Suppose we could access yesterday's stock prices as an array, where:
- The indices are the time in minutes past trade opening time, which was 9:30am local time.
- The values are the price in dollars of Apple stock at that time.
So if the stock cost $500 at 10:30am,
stockPricesYesterday[60] = 500
.
Write an efficient function that takes stockPricesYesterday and returns the best profit I could have made from 1 purchase and 1 sale of 1 Apple stock yesterday.
OlderNewer