Skip to content

Instantly share code, notes, and snippets.

@potluckgame
potluckgame / find.winner.js
Last active November 6, 2016 23:26
Potluck Winner calculation logic
const isaac = require('isaac'); // https://github.com/rubycon/isaac.js
/**
* generate a random number using isaac RNG
* @param {String} seed - the seed for isaac RNG
* @returns {Number} Random number between 0.0 and 1.0
*/
function isaacRandom(seed) {
isaac.seed(seed);
return isaac.random();
}
@potluckgame
potluckgame / server.seeds.chain.js
Last active August 25, 2023 03:34
Potluck Server seed chain generator
const Bluebird = require('bluebird');
/**
* Create a `sha256` hash of the seed.
* @param {String} seed - Previous server `seed`
* @returns {String} `sha256` hash of the `seed`
*/
function createHash(seed) {
return crypto.createHash('sha256').update(seed).digest('hex');
}