Skip to content

Instantly share code, notes, and snippets.

@dtturcotte
dtturcotte / addOrUpdateRecord.gs
Created December 4, 2023 21:24
addOrUpdateRecord Google Sheets App Script: randomly add / update a record (based on Trigger, or manual function execution)
/*
Randomly add or update (change value column for a row) a record
*/
function randomlyAddOrUpdateRecord() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('president_primary_polls_test')
// Force the spreadsheet changes to be applied
SpreadsheetApp.flush()
const lastRow = sheet.getLastRow()
@dtturcotte
dtturcotte / onEditWebhook.gs
Last active December 4, 2023 21:26
onEditWebhook Google Sheets App Script: send Google Sheet's updated row data to Node.js endpoint
const ngrokURL = 'NGROK_URL_HERE'
// 'kinesis': sends data to be stored in kinesis, which emits a message
// 'db': sends data to be stored in PostgreSQL, whose trigger emits a message
const endpoint = 'kinesis'
const url = `${ngrokURL}/api/polls/${endpoint}`
/*
On row edit (either by human entry or by timed trigger), get data and send to endpoint

Player Entity:

	pointerdown : function (e) {
		if (e.button === 0) {
			this.angle = this.angleToPoint(new me.Vector2d(e.gameX - 30, e.gameY + 30));

			// Projectile