Mocha is a unittest framework for Node. In this document, we explain how you can test your javascript code and also your HTTP servers.
Use npm
to install Mocha:
npm install mocha
app.post('/login', function(req, res) { | |
console.log(res); | |
passport.authenticate('local', function(err, user) { | |
if (req.xhr) { | |
//thanks @jkevinburton | |
if (err) { return res.json({ error: err.message }); } | |
if (!user) { return res.json({error : "Invalid Login"}); } | |
req.login(user, {}, function(err) { | |
if (err) { return res.json({error:err}); } | |
return res.json( |
var url = "http://cdn1.giltcdn.com/images/share/uploads/0000/0001/7250/172502872/420x560.jpg"; | |
var encoded = new Buffer(url).toString('base64'); | |
var decoded = new Buffer(encoded, 'base64').toString('ascii') | |
console.log(encoded); | |
console.log(decoded); |
import com.google.common.base.Function; | |
import com.google.common.collect.Lists; | |
import com.google.common.primitives.Ints; | |
import lombok.Data; | |
import org.junit.Test; | |
import java.math.BigDecimal; | |
import java.util.List; | |
@Data |
package springbatch; | |
import common.Greeting; | |
import org.springframework.batch.core.Job; | |
import org.springframework.batch.core.Step; | |
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; | |
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; | |
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; | |
import org.springframework.batch.core.launch.JobLauncher; | |
import org.springframework.batch.core.launch.support.SimpleJobLauncher; |
FROM node:0.12.7-wheezy | |
# Install tools & libs to compile everything | |
RUN apt-get update && apt-get install -y build-essential libssl-dev libreadline-dev wget && apt-get clean | |
# Install imagemagick with support to native library | |
RUN apt-get install -y imagemagick libmagick++-dev libmagic-dev && apt-get clean | |
ENV PATH=$PATH:~/opt/bin:~/opt/node/bin:/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16 | |
# Install global CLIs |
Mocha is a unittest framework for Node. In this document, we explain how you can test your javascript code and also your HTTP servers.
Use npm
to install Mocha:
npm install mocha
// Returns the value at a given percentile in a sorted numeric array. | |
// "Linear interpolation between closest ranks" method | |
function percentile(arr, p) { | |
if (arr.length === 0) return 0; | |
if (typeof p !== 'number') throw new TypeError('p must be a number'); | |
if (p <= 0) return arr[0]; | |
if (p >= 1) return arr[arr.length - 1]; | |
var index = arr.length * p, | |
lower = Math.floor(index), |
function throttle(callback, wait, immediate = false) { | |
let timeout = null | |
let initialCall = true | |
return function() { | |
const callNow = immediate && initialCall | |
const next = () => { | |
callback.apply(this, arguments) | |
timeout = null | |
} |
// Returns the value at a given percentile in a sorted numeric array. | |
// "Linear interpolation between closest ranks" method | |
function percentile(arr, p) { | |
if (arr.length === 0) return 0; | |
if (typeof p !== 'number') throw new TypeError('p must be a number'); | |
if (p <= 0) return arr[0]; | |
if (p >= 1) return arr[arr.length - 1]; | |
var index = (arr.length - 1) * p, | |
lower = Math.floor(index), |
/* | |
* Migration | |
*/ | |
'use strict'; | |
module.exports = { | |
up: function(queryInterface, Sequelize) { | |
return queryInterface.createTable('Users', { | |
firstName: { | |
type: Sequelize.STRING | |
}, |