This file contains 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(); | |
}); |
This file contains 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 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 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 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 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
export PS1="\n\[\033[1;102m\]\[\033[1;30m\] \A \[\033[1;103m\]\[\033[1;30m\] \u \[\033[0;107m\]\[\033[1;30m\] \w \[\033[0m\] \[\`if [ \$? != 0 ]; then echo 😠 ' '; fi \`\]" | |
alias ls='ls -lhaG' | |
alias ..='cd ..' | |
alias ...='cd ../..' | |
alias ....='cd ../../..' | |
alias .....='cd ../../../..' | |
alias gm="grunt nodemon" | |
alias gish="ssh -T [email protected]" |
This file contains 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 heartbeats = [1, 2, 3].map((value) => Promise.resolve({ id: value, date: +new Date() })); | |
Promise.all(heartbeats).then((values) => { | |
console.log(values.map((value) => !value.date ? null : { | |
id: value.id, | |
name: 'location', | |
heartbeat: value.date | |
}).filter(v => v).sort() | |
); | |
}); |
This file contains 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
/** | |
* Element fadeIn plugin for jQuery. | |
* @author Stefan Aichholzer <https://github.com/aichholzer> | |
* @param options -Object defining the animation's end result. | |
* | |
* { | |
* opacity: 1, | |
* marginBottom: 5, | |
* duration: 50 | |
* } |
This file contains 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 sample = { | |
a: 'Hello', | |
b: '', // Will be removed | |
c: null, | |
d: { | |
a: 1, | |
b: '', // Will be removed | |
c: 3, | |
d: { | |
a: 1, |
This file contains 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 http = require('http'); | |
const { readFile } = require('fs'); | |
const { gzip } = require('zlib'); | |
const { promisify } = require('util'); | |
const run = async () => { | |
try { | |
const data = await promisify(readFile)('./menu.json'); | |
const req = http.request({ | |
method: 'POST', |
OlderNewer