Skip to content

Instantly share code, notes, and snippets.

View thealchen's full-sized avatar

Al Chen thealchen

View GitHub Profile
@thealchen
thealchen / peloton_coda_sync.js
Last active December 11, 2021 18:52
Google Apps Script to sync Peloton workout data to a table in a Coda doc
// One-way data sync from Peloton API to Coda in Google Apps Script
// Author: Al Chen ([email protected])
// Last Updated: December 11th, 2021
// Notes: Assumes you are using the V8 runtime (https://developers.google.com/apps-script/guides/v8-runtime)
// Coda's library for Google Apps Script: 15IQuWOk8MqT50FDWomh57UqWGH23gjsWVWYFms3ton6L-UHmefYHS9Vl
// Writeup and copyable template here: https://coda.io/@atc/analyze-your-peloton-workout-stats-with-real-time-updates
//////////////// Setup and global variables ////////////////////////////////
CodaAPI.authenticate('YOUR_CODA_API_KEY')
@thealchen
thealchen / loading_bar.js
Created April 13, 2021 18:19
Create a loading bar while you're retrieving results from an API with Google Apps Script
// Create a loading bar in your Google Sheet using Google Apps Script
// Author: Al Chen ([email protected])
// Last Updated: April 13th, 2021
// Notes: Assumes you are using the V8 runtime (https://developers.google.com/apps-script/guides/v8-runtime)
// Example Google Sheet: https://docs.google.com/spreadsheets/d/1ngvYKEMunqCVufR10rlK42iENAERp-uyiPN_aiq-MKo/edit?usp=sharing
SOURCE_SHEET_ID = 'YOUR_GOOGLE_SHEETS_ID'
SOURCE_WORKSHEET_NAME = 'YOUR_WORKSHEET_NAME'
function loop() {
@thealchen
thealchen / count_colored_cells_google_apps_script.js
Created February 27, 2023 03:09
Count the number of cells with a background color in Google Sheets (Google Apps Script)
function CountFormattedCells() {
// Output the number of formatted cells somewhere in your spreadsheet
var outputNumberOfFormattedCells = 'C52'
// Cell that contains the color you want to count. Default is blank.
var cellWithFormatToCount = ''
var spreadsheet = SpreadsheetApp.getActive();
var currentRangeColors = spreadsheet.getActiveRange().getBackgrounds();