Skip to content

Instantly share code, notes, and snippets.

View markelliot's full-sized avatar

Mark Elliot markelliot

View GitHub Profile
/* This script will synchronize two Google-hosted calendars as a Google Apps Script.
*
* Personal events will show on your work calendar by default with the label "Blocked (Personal)".
* Work events will show on your personal calendar by default with the label "Blocked (Work)".
*
* The description of the "Blocked" events contains an identifier that allows the script to update
* event times if they change.
*
* Note that this script will not copy or update events where:
* - you have not accepted the invite
@markelliot
markelliot / appendRowsToSheet.js
Created June 8, 2021 02:15
Appends rows to a Google Sheet using the specified OAuth2 token and spreadsheet id.
/**
* Appends the row matrix to the specified range in the identified sheet.
*
* @param {string} token an OAuth2 token scoped for write to the Google sheets APIs
* (scope must include "https://www.googleapis.com/auth/spreadsheets") and with access
* to the underlying Google Sheet. The Sheet should be shared with the service user's
* email address.
* @param {string} spreadsheetId the spreadsheet's identifier, which you can glean
* from the Google Sheets URL, extracted from the pattern:
* https://docs.google.com/spreadsheets/d/([A-Za-z0-9_-]+)/edit#gid=0
@markelliot
markelliot / getGoogleAuthToken.js
Last active June 19, 2024 16:40
Converts Google service user OAuth2 credentials into an access token in Cloudflare-compatible JS
/**
* Get a Google auth token given service user credentials. This function
* is a very slightly modified version of the one found at
* https://community.cloudflare.com/t/example-google-oauth-2-0-for-service-accounts-using-cf-worker/258220
*
* @param {string} user the service user identity, typically of the
* form [user]@[project].iam.gserviceaccount.com
* @param {string} key the private key corresponding to user
* @param {string} scope the scopes to request for this token, a
* listing of available scopes is provided at

Keybase proof

I hereby claim:

  • I am markelliot on github.
  • I am markelliot (https://keybase.io/markelliot) on keybase.
  • I have a public key whose fingerprint is 5FD1 F002 5836 8F86 3DF0 1BD2 EE57 1B77 7CE7 3A72

To claim this, I am signing this object:

var foo = {
field_1: { code: "1" },
field_2: { code: "2" },
field_3: { code: "3" },
field_4: { code: "4" },
field_5: { code: "5" },
field_6: { code: "6" },
field_7: { code: "7" },
field_8: { code: "8" },
field_9: { code: "9" },
var foo = {
field_1: { code: "1" },
field_2: { code: "2" },
field_3: { code: "3" },
field_4: { code: "4" },
field_5: { code: "5" },
field_6: { code: "6" },
field_7: { code: "7" },
field_8: { code: "8" },
field_9: { code: "9" },