Skip to content

Instantly share code, notes, and snippets.

//First way
Promise.resolve(userModel.findOneAndUpdate({uid: myUserId}, updatedUserModel, {
upsert: true,
"new": false
}).exec())
.then(function (user) {
...
})
.spread(function markNotificationsAsRead(unreadNotifications) {
...
'use strict'
const router = require('express').Router()
const Project = require('../models/project')
const Build = require('../models/build')
// require('mongoose').Promise = require('bluebird') this is already done elsewhere
router.param('projectname', (req, res, next, id) => {
if (!id) {
@Nepoxx
Nepoxx / app.js
Last active November 27, 2015 21:20
// ...
config.map([
{route: ['arraytest', 'arraytest/:test'], name: 'test', moduleId: 'arraytest/arraytest', title: 'test'}
]);
// ...
import {inject, LogManager} from 'aurelia-framework';
import {HttpClient} from 'aurelia-fetch-client';
import _ from 'lodash';
import 'fetch';
const refreshRateInSeconds = 30;
@inject(HttpClient, LogManager)
export class Users {
heading = 'Current Builds';
@Nepoxx
Nepoxx / Thing.js
Last active December 10, 2015 17:05
testing module that uses bluebirdd
var Thing = {
load: function() {
var resolve, reject;
function finished() {
resolve({})
}
function errored() {
reject({});
config:
target: 'http://mydomain.com/myApi'
phases:
# Warm Up
- duration: 30
arrivalRate: 5
# Ramp Up
- duration: 60
arrivalRate: 5
/*class Neuron {
Neuron(x, y) {
this.location = {x: x, y: y};
this.connections = [];
this.sum = 0;
}
feedForward(input) {
this.sum +=input;
if(this.sum >1) {
this.fire();
this.addNewListener = function(user) {
joinChannel(user.name);
return addNewChannelCache(user)
.then(function(data) {
return cache.getAsync(user.name);
})
.then(function(obj) {
if (obj == null) {
throw new Exception('Object was not in cache');
<template>
<require from="~/_templates/sidebar/sidebar"></require>
<require from="~/_templates/topbar/topbar"></require>
<div class="container body">
<div class="main_container">
<!-- sidebar menu -->
<side-bar class="side-bar"></side-bar>
<!-- /sidebar menu -->
<!-- top navigation -->
'use strict';
const Benchmark = require('benchmark');
const benchmarkOutput = require('beautify-benchmark');
var suite = new Benchmark.Suite;
function litteral() {
return {
a: 3,