Skip to content

Instantly share code, notes, and snippets.

View ppg's full-sized avatar

Peter P. Gengler ppg

View GitHub Profile
@ppg
ppg / error.js
Created August 8, 2017 20:13
Demonstration of deep matching issues with errors
'use strict';
const chai = require('chai');
const expect = chai.expect;
const err1 = new Error('test error');
const err2 = new Error('test error');
it('should match exact errors', function() {
expect(err1).to.equal(err1);
@ppg
ppg / mongoose-arrays.js
Last active August 15, 2017 22:00
Demonstration of deep matching issues with sinon-chain calledWith
'use strict';
const chai = require('chai');
const expect = chai.expect;
const mongoose = require('mongoose');
const ObjectId = mongoose.Schema.Types.ObjectId;
const sinon = require('sinon');
const sinonChai = require('sinon-chai');
chai.use(sinonChai);
@ppg
ppg / explainPromises.js
Created March 14, 2017 23:48
Demonstrates how ES6 promises work with respect to traditional callback tasks.
'use strict';
const async = require('async');
// All fN functions should take n and m and return all permutations between the two;
// i.e. for 2, 3:
// ['0 - 0', '0 - 1', '0 - 2', '1 - 0', '1 - 1', '1 - 2']
function workerTraditional(i, j, callback) {
// Put in a sleep
@ppg
ppg / parallelLimitTest.js
Created March 24, 2016 18:19
Tests async.parallelLimit to see how it behaves
var async = require('async');
var tasks = [];
for (var i = 0; i < 25; i++) {
(function(i) {
if (i % 2 === 0) {
tasks.push(function(cb) {
console.log('Start ' + i.toString() + ' - fast');
setTimeout(function() {
console.log('Finish ' + i.toString() + ' - fast');
@ppg
ppg / keybase.md
Last active August 2, 2017 08:17

Keybase proof

I hereby claim:

  • I am ppg on github.
  • I am ppg (https://keybase.io/ppg) on keybase.
  • I have a public key ASACzQSzdI5rxC2H0DDJpw9al7QtEZWpqqu79uu3EqVQtwo

To claim this, I am signing this object:

# foo LWRP
action :create do
service new_resource.name do
action :start
end
end
# Usage in a recipe
foo "bar"
template "something" do