Apply for early acccess.
Start here: https://github.com/openfaas/community-cluster
//function to print CSV from an array for robomongo | |
//place this in .robomongorc.js which should be present in your home directory | |
//inspired by https://github.com/Studio3T/robomongo/wiki/How-to-export-to-CSV | |
function toCSV(array) { | |
let deliminator = ','; | |
let textQualifier = '\"'; | |
let headers = []; | |
var data = {}; | |
var count = -1; |
let regex; | |
/* matching a specific string */ | |
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello" | |
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO" | |
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes... | |
/* wildcards */ | |
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo" | |
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo" |
Apply for early acccess.
Start here: https://github.com/openfaas/community-cluster
// Instructions: | |
// npm install --save d3 jsdom | |
const fs = require('fs'); | |
const d3 = require('d3'); | |
const jsdom = require('jsdom'); | |
const { JSDOM } = jsdom; | |
const fakeDom = new JSDOM('<!DOCTYPE html><html><body></body></html>'); |
function fieldSorterOptimized(fields) { | |
var dir = [], i, l = fields.length; | |
fields = fields.map(function(o, i) { | |
if (o[0] === "-") { | |
dir[i] = -1; | |
o = o.substring(1); | |
} else { | |
dir[i] = 1; | |
} | |
return o; |
/** | |
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken | |
* It was requested to be introduced at as part of the jsonwebtoken library, | |
* since we feel it does not add too much value but it will add code to mantain | |
* we won't include it. | |
* | |
* I create this gist just to help those who want to auto-refresh JWTs. | |
*/ | |
const jwt = require('jsonwebtoken'); |
// https://webreflection.medium.com/using-the-input-datetime-local-9503e7efdce | |
Date.prototype.toDatetimeLocal = | |
function toDatetimeLocal() { | |
var | |
date = this, | |
ten = function (i) { | |
return (i < 10 ? '0' : '') + i; | |
}, | |
YYYY = date.getFullYear(), | |
MM = ten(date.getMonth() + 1), |
By default date.toISOString returns UTC time instead of local time. So you'll need to calculate the timezone offset first.
//Get the local date in ISO format
var date = new Date();
date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
var datestr = date.toISOString().substring(0, 10);
/* modified from https://codingwithspike.wordpress.com/2014/12/29/using-deferreds-with-the-cordova-file-api/ */ | |
/* requires rsvp.js */ | |
/* tested and working in iOS and Android on latest Cordova (5.2.0) and File plugin (4.0.0) */ | |
/* uses dataDirectory which is not synced to iCloud on iOS. You can replace each reference to syncedDataDirectory, but then you will need to set cordova.file.syncedDataDirectory = cordova.file.dataDirectory on Android to maintain compatibility */ | |
window.fileStorage = { | |
write: function (name, data) { | |
var name_arr = name.split('/'); | |
var name_index = 0; |
var a = ["sdfdf", "http://oooooolol"], | |
handleNetErr = function(e) { return e }; | |
Promise.all(fetch('sdfdsf').catch(handleNetErr), fetch('http://invalidurl').catch(handleNetErr)) | |
.then(function(sdf, invalid) { | |
console.log(sdf, invalid) // [Response, TypeError] | |
}) | |
.catch(function(err) { | |
console.log(err); | |
}) |