Here's the basic usage of the file that you'll be creating:
var curry = require('./') // <- this is the file you make;
function add(a, b) { return a + b; }
var curried = curry(add); console.log( curried(1)(2) ); // 3
// Promise.all is good for executing many promises at once | |
Promise.all([ | |
promise1, | |
promise2 | |
]); | |
// Promise.resolve is good for wrapping synchronous code | |
Promise.resolve().then(function () { | |
if (somethingIsNotRight()) { | |
throw new Error("I will be rejected asynchronously!"); |
var func = function(a, b) { | |
console.log(“funcLength is”, this.length); | |
var totalArgs = Array.prototype.slice.call(arguments, 0); | |
console.log(“, totalArgs is”, totalArgs.length); | |
} | |
func.call(func, [1]); // Output: funcLength is 2, totalArgs is 1 | |
func.call(func, [1, 2, 3]); // Output: funcLength is 2, totalArgs is 3 |
function currying(func) { | |
// how many args that func needs | |
var totalArgs = func.length; | |
var partial = function(args) { | |
return function() { | |
var newArgs = Array.prototype.slice.call(arguments, 0); | |
return fn.apply(null, args.concat(newArgs)); | |
} | |
} |
Here's the basic usage of the file that you'll be creating:
var curry = require('./') // <- this is the file you make;
function add(a, b) { return a + b; }
var curried = curry(add); console.log( curried(1)(2) ); // 3
function quicksort(array) { | |
var sortedArray = array.slice(0); // clone the array | |
if(sortedArray.length == 0) return []; | |
var left = [], right = [], pivot = sortedArray[0]; | |
for (var i = 1; i < sortedArray.length; i++) { | |
if(sortedArray[i] < pivot) { | |
left.push(sortedArray[i]); | |
} else { |
Here's the basic usage of the file that you'll be creating:
var sort = require('./') // <- this is the file you make;
var arr = [5, 1, 4, 2, 3];
var sorted = sort(arr);
console.log(sorted); // [1, 2, 3, 4, 5]
function map(array, cb, context) { | |
return function(array, cb) { | |
var returnArray = []; | |
for (var i = 0; i < array.length; i++) { | |
returnArray.push(cb(array[i], i, array)); | |
} | |
return returnArray; | |
}.call(null, array, cb.bind(context)); | |
} |
var AWS = require('aws-sdk'), | |
fs = require('fs'); | |
// http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html#Credentials_from_Disk | |
AWS.config.loadFromPath('./aws-config.json'); | |
// assume you already have the S3 Bucket created, and it is called ierg4210-shopxx-photos | |
var photoBucket = new AWS.S3({params: {Bucket: 'ierg4210-shopxx-photos'}}); | |
function uploadToS3(file, destFileName, callback) { |
##What is the problem?
├─┬ grunt@0.4.5
│ ├─┬ findup-sync@0.1.3
│ │ └── lodash@2.4.1
│ ├─┬ grunt-legacy-log@0.1.1
│ │ └── lodash@2.4.1
│ └── lodash@0.9.2
├─┬ grunt-contrib-watch@0.6.1
│ └─┬ gaze@0.5.1
(wherever it says url.com, use your server's domain or IP)
Login to new server as root, then add a deploy user
sudo useradd --create-home -s /bin/bash deploy
sudo adduser deploy sudo
sudo passwd deploy
And Update the new password