Skip to content

Instantly share code, notes, and snippets.

View scalabl3's full-sized avatar

Jasdeep Jaitla scalabl3

View GitHub Profile
@scalabl3
scalabl3 / crc32.js
Created October 15, 2018 16:47
Example of using CRC32 to shard
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
@scalabl3
scalabl3 / xhr.js
Last active January 3, 2019 21:43
Functions XHR Request with Retries
export default (request) => {
const kvstore = require('kvstore');
const xhr = require('xhr');
const vault = require('vault'); // You can use the Vault to store a header/key for your backend
// to validate the request with, alternatively you can use IP whitelist
const host = 'https://f8234c78.ngrok.io';
var url = host + '/v1/webhooks/pubnub';