Drag and drop upload zone
A Pen by Stéphane Lyver on CodePen.
| var asyncMap = function(tasks, finalCb){ | |
| var results = []; | |
| var completed = 0; | |
| var checkCompleteness = function() { | |
| if (completed === tasks.length) { | |
| finalCb(results); | |
| } | |
| }; | |
| var runTask = function (i) { | |
| var onResult = function(val) { |
Drag and drop upload zone
A Pen by Stéphane Lyver on CodePen.
| // N number of people stand in a circle. | |
| // The people are numbered in order from 1 to N. | |
| // Starting from 1, we remove every other person | |
| // from the circle until there is only one person remaining. | |
| // I would like you to write a function which takes in the number N | |
| // and outputs the number of the last person remaining. For example: | |
| // f(3) outputs 3 | |
| // f(4) outputs 1 | |
| // f(5) outputs 3 |
| // initiating a worker | |
| var karl = new Worker("task.js"); | |
| // receiving messages | |
| karl.onmessage = function(event){ | |
| console.log(event.data); | |
| }; | |
| // in the end | |
| karl.terminate(); |
| var request = require('request'); | |
| var Promise = require('bluebird'); | |
| var authorize = require('./session-keys'); | |
| var BASE_URL = 'http://challenge.shopcurbside.com/'; | |
| var fetch = function(resource, session) { | |
| var options = { | |
| url: BASE_URL + resource, | |
| headers: { 'Session': session } |
| var num = "27019", | |
| base = 16, | |
| output = ''; | |
| while (num > 0) { | |
| digit = num % base; | |
| num = (num - digit) / base; | |
| if (digit > 9) { | |
| digit = String.fromCharCode(digit + 55); | |
| } |
| function solution(A) { | |
| var n = A.length - 1, | |
| lSum = 0, | |
| rSum = 0, | |
| diffs = new Array(n), | |
| diff, | |
| min = Infinity; | |
| for (var p = 0; p < n; p++) { | |
| lSum += A[p]; | |
| rSum += A[n - p]; |
| function wrap (text, limit) { | |
| if (text.length > limit) { | |
| // find the last space within limit | |
| var edge = text.slice(0, limit).lastIndexOf(' '); | |
| if (edge > 0) { | |
| var line = text.slice(0, edge); | |
| var remainder = text.slice(edge + 1); | |
| return line + '\n' + wrap(remainder, limit); | |
| } | |
| } |
| module.exports = function () { | |
| var c = []; | |
| return { | |
| push: function (item) { | |
| c.push(item); | |
| }, | |
| print: function () { | |
| console.log(c); | |
| } | |
| }; |
| var handlers = { | |
| onConnect: function () { | |
| console.log('Connected!'); | |
| }, | |
| onMessage: function () { | |
| console.log('Message!'); | |
| } | |
| }; | |
| var map = { |