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
;; Link to KATA: http://www.codewars.com/kata/5592e3bd57b64d00f3000047/train/clojure | |
;; Your task is to construct a building which will be a pile of n cubes. The cube at the bottom will have a volume of n^3, the cube above will have volume of (n-1)^3 and so on until the top which will have a volume of 1^3. | |
;; You are given the total volume m of the building. Being given m can you find the number n of cubes you will have to build? | |
;; The parameter of the function findNb (find_nb, find-nb) will be an integer m and you have to return the integer n such as n^3 + (n-1)^3 + ... + 1^3 = m if such a n exists or -1 if there is no such n. | |
;; EXAMPLES | |
;; findNb(1071225) --> 45 |
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
module.exports = (function() { | |
function EventManager() { | |
this.events = {}; | |
} | |
// Will throw if there is no existing event to trigger | |
EventManager.prototype.trigger = function(msg) { | |
// grab all arguments passed after the first argument | |
var args = Array.prototype.splice.call(arguments, 1); | |
for (var i = 0, len = this.events[msg].length; i < len; i++) { |
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 obj = {a: 123, b: "4 5 6"}; | |
var container = document.getElementById('container'); // some div on the page | |
container.addEventListener('click', function() { | |
var data = "text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(obj)); | |
window.open("data://" + data, "_blank"); | |
}) |
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 AWS = require('aws-sdk'); | |
AWS.config.update({ | |
endpoint: "http://localhost:8000", | |
region: "us-west-2", | |
accessKeyId: "myKeyId", | |
secretAccessKey: "secretKey" | |
}); | |
var dyn = new AWS.DynamoDB(); | |
var docClient = new AWS.DynamoDB.DocumentClient(); |
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
for(var i = 0; i < 5; i++) { | |
setTimeout(function(printMe) { | |
console.log(printMe); | |
}.bind(null, i), i * 1000); | |
} |
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
(function() { | |
"use strict" | |
const microwave = { | |
_timer: null, | |
_eventListener: null, | |
start: function(timeMS, callback) { | |
this._eventListener = callback | |
this._timer = setTimeout((() => { | |
this._timer = null |
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
(function() { | |
"use strict" | |
function Microwave() { | |
this.timer = null | |
this.eventListener = null | |
} | |
Microwave.prototype.start = function(timeMS, callback) { | |
this.eventListener = callback |
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
(function() { | |
'use strict'; | |
// Define a generic prototype for our skiiers to inherit | |
const skiierPrototype = { | |
name: 'fred', | |
greet: function() { | |
return 'Hi, I am ' + this.name | |
} | |
} |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Babel Test</title> | |
<meta name="description" content="Babel Test Site"> | |
<meta name="author" content="Ben Hofferber"> | |
<script src="node_modules/babel-polyfill/dist/polyfill.min.js"></script> | |
</head> |
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
(function (window, document) { | |
"use strict" | |
const NAME = 'Ben Hofferber' | |
let div = document.getElementById('appendToMe') | |
let h1 = document.createElement('h1') | |
h1.textContent = `Hello ${NAME}!` | |
div.appendChild(h1) |
OlderNewer