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'; | |
let err = 'E11000 duplicate key error collection: home.users index: name_1 dup key: { : "francis" }'; | |
let err = 'E11000 duplicate key error collection: home.users index: email.personal_1 dup key: { : "[email protected]" }'; | |
let [i, field, input] = err.match(/index:\s([.a-z]+).*{\s?\:\s?"(.*)"/i); | |
console.log(field, input); |
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'; | |
class Shufflr { | |
constructor () { | |
process.argv.splice(0, 2); | |
this.people = process.argv.sort(); | |
this.selectedPeople = []; |
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'; | |
module.exports = function stringWeaver(stringArray, sortByLength) { | |
sortByLength = sortByLength || true; | |
var result = [], | |
index = 0, | |
lastIndex = 0; |
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
/** | |
* Simplest web page scrape | |
* | |
* sudo port install phantomjs | |
* npm install -g casperjs | |
*/ | |
var casper = require('casper').create(), | |
links = [], | |
images = [], |
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 express = require('express'), | |
app = express(); | |
app.use(function (req, res, next) { | |
req.prettify = function(json) { | |
json = json || this.body; | |
return console.log(JSON.stringify(json, null, 2)); | |
}; | |
next(); | |
}); |
NewerOlder