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
if (stupid && works) stupid = false; |
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
// Promise can be q.Promise in Node < 11.13 | |
function wait(ms) { | |
return function(data) { | |
return Promise(functoin(resolve, reject) { | |
setTimeout(resolve, ms, data); | |
}); | |
} | |
} |
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
// http://www.2ality.com/2014/04/call-stack-size.html | |
function computeMaxCallStackSize() { | |
try { | |
return 1 + computeMaxCallStackSize(); | |
} catch (e) { | |
// Call stack overflow | |
return 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 now = new Date(); | |
var lastSunday = new Date(); | |
var nextSunday = new Date(); | |
lastSunday.setDate(now.getDate() - now.getDay()); | |
nextSunday.setDate(lastSunday.getDate() + 7); |
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
// http://pag.forbeslindesay.co.uk/#/22 | |
// | |
function async(makeGenerator){ | |
return function (){ | |
var generator = makeGenerator.apply(this, arguments) | |
function handle(result){ // { done: [Boolean], value: [Object] } | |
if (result.done) return result.value | |
return result.value.then(function (res){ |
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 objectify = require('./objectify'), | |
fs = require('fs'); | |
var source = fs.createReadStream(__dirname+'/file.csv'); | |
var objects = source.pipe(objectify); | |
objects.on('data', function(object) { | |
// do something with the object | |
}); |
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 uuid = /[a-f0-9]{8}(\-[a-f0-9]{4}){3}\-[a-f0-9]{12}/; |
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
hint format ["%1", [(configFile >> "CfgGroups" >> "INDEP" >> "PG_Services" >> "Infantry"),1, true, true ] call BIS_fnc_returnChildren]; |
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
// https://variadic.me/posts/2013-10-22-bind-call-and-apply-in-javascript.html | |
var bind = Function.prototype.call.bind(Function.prototype.bind); | |
var Ping = function(host, option) { | |
// do stuff | |
return this; | |
} | |
Ping.prototype.send = function() { | |
// do more stuff |
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
// http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html | |
var chart = require('ascii-chart'), | |
_ = require('lodash'); | |
var data = []; | |
var out = process.stdout; | |
out.write('\033[2J'); // clear the screen |