- Download the files into a directory.
- Replace the API key with your own in
gpt.js
- Run
npm i
- Run
node .
- Connect to it using
telnet
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
* | |
NAME: SCRIPT NUGGETS | |
DESCRIPTION: Apps Script functions for use with AppSheet | |
SETUP: Replace YOUR_SHEET_ID in first line with the sheet Id from the sheet URL | |
BY: GreenFlux, LLC | |
*////////////////////////////////////////////////////////////////////////////////////////////////////// | |
const ss = SpreadsheetApp.openById('YOUR_SHEET_ID');//(id from sheetURL) |
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
function roundUp(num, prec) { | |
prec = Math.pow(10, prec); | |
return Math.ceil(num * prec) / prec; | |
} | |
function roundDown(num, prec) { | |
prec = Math.pow(10, prec); | |
return Math.floor(num * prec) / prec; | |
} | |
// Built in Math function |
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
// These hashes are for algorithmic use cases, such as bucketing in hashtables, where security isn't | |
// needed and 32 or 64 bits is enough (that is, rare collisions are acceptable). These are way simpler | |
// than sha1 (and all its deps) or similar, and with a short, clean (base 36 alphanumeric) result. | |
// A simple, *insecure* 32-bit hash that's short, fast, and has no dependencies. | |
// Output is always 7 characters. | |
// Loosely based on the Java version; see | |
// https://stackoverflow.com/questions/6122571/simple-non-secure-hash-function-for-javascript | |
const simpleHash = str => { | |
let hash = 0; |
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
/** | |
* Calculates the base bet from the current wager, multiplier, and streak. | |
* | |
* @param {number} wager - The current wager. | |
* @param {number} multi - The multiplier. | |
* @param {number} streak - The streak. | |
* @returns {number} - The calculated base bet. | |
*/ | |
const getBaseBetFromCurrent = (wager, multi, streak) => (wager / (multi ** streak)); |
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
function asyncParForEach(array, fn, callback) { | |
var completed = 0; | |
if (array.length === 0) { | |
callback(); // done immediately | |
} | |
array.forEach(function(data) { | |
fn(data, function() { | |
completed++; | |
if (completed === array.length) { |
I was trying to understand JavaScript Promises by using various libraries (bluebird, when, Q) and other async approaches.
I read the spec, some blog posts, and looked through some code. I learned how to
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 Thing = (function() { | |
this.public_property = "Public property"; | |
var private_property = "Private property"; | |
function Thing(data) { | |
this.datum1 = data.datum1; | |
this.datum3 = data.datum2; | |
} |
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
function promiseWhile(condition, body) { | |
var dfd = $.Deferred(); | |
function loop() { | |
if (!condition()) return dfd.resolve(); | |
body.apply(this, arguments) | |
.done(loop) | |
.fail(dfd.reject); | |
} | |
//call loop async |
NewerOlder