This file contains hidden or 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
// Timer to continue counting while using bcrypt. | |
// Demonstrates that the bcrypt functions are asynchronous. | |
;(function() { | |
console.log('start timer'); | |
var x = 1; | |
setInterval(function() { | |
console.log('Timer: ' + x); | |
x++; | |
}, 1000); | |
}()); |
This file contains hidden or 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 Promise = require('bluebird'); | |
Promise.longStackTraces(); | |
//var Promise = require('q'); | |
Promise.reject('first thingy') | |
.then(function (a) { | |
console.log('then 1 ' + a); | |
}) | |
.finally(function (x) { | |
console.log('finally 1'); |
This file contains hidden or 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 m = require('mithril'); | |
function requestWithFeedback(args) { | |
var completed = m.prop(false); | |
var complete = function() { | |
completed(true); | |
} | |
var data = m.prop(); | |
args.background = true |
This file contains hidden or 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 mountWrapper(component) { | |
var origCtrl = component.controller; | |
component.controller = function () { | |
setImmediate(function () { | |
var orgid = m.route.param('orgid'); | |
var org = m.prop(null); | |
var route = m.route(); | |
var routeSplit = m.route().split('/'); | |
if (orgid) { |
This file contains hidden or 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
------ | |
built in rejection: | |
Promise.reject(new Error('ether')) | |
(no error console output with V8 promise rejection, nothing shown on screen, no non-zero exit code on process, etc.) | |
-------- | |
Promise = require('bluebird') |
This file contains hidden or 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
const jade = require('jade') | |
app.use((req, res) => { | |
const locals = req.locals // get your template locals from where ever | |
locals.cache = process.env.NODE_ENV === 'production' // set the template cache | |
const html = jade.renderFile('templates/home.jade', locals) // render the template | |
res.setHeader('Content-Length', Buffer.byteLength(html)) | |
res.setHeader('Content-Type', 'text/html; charset=utf-8') // set the content type header | |
res.end(html) // send the response | |
}) |
This file contains hidden or 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 store = redux.createStore(function(state, action) { | |
var defaultState = { | |
view: LOGIN, | |
subview: '', | |
} | |
if (!state) { | |
return defaultState; | |
} | |
switch(action.type) { |
This file contains hidden or 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
<html> | |
<head> | |
<title>DOMContentLoaded vs jQuery</title> | |
</head> | |
<body> | |
<h1> | |
With jQuery (2.1.4) if a function throws in a $(document).ready listener, it will prevent subsequent | |
$(document).ready listeners from executing. This demonstrates that it does not happen with jQuery 3.1.1 or document.addEventListener. | |
</h1> |
This file contains hidden or 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
'use strict'; | |
/** | |
"One line" QueryString parser | |
Initial question-mark optional | |
Handles repeated parameters (turns into array) | |
Handles null parameters | |
Handles + sign in parameters |
This file contains hidden or 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
** Node 8 ** | |
results for 10000 parallel executions, 1 ms per I/O op | |
file time(ms) memory(MB) | |
callbacks-baseline.js 156 31.35 | |
callbacks-suguru03-neo-async-waterfall.js 189 39.54 | |
promises-bluebird-generator.js 246 41.37 | |
promises-bluebird.js 322 48.27 | |
promises-cujojs-when.js 393 61.61 | |
promises-tildeio-rsvp.js 503 78.96 |
OlderNewer