Skip to content

Instantly share code, notes, and snippets.

View erickoledadevrel's full-sized avatar

Eric Koleda erickoledadevrel

View GitHub Profile
@erickoledadevrel
erickoledadevrel / zendesk.ts
Created March 6, 2024 14:56
Using the password grant to connect to the Zendesk API in a Coda Pack
import * as coda from "@codahq/packs-sdk";
export const pack = coda.newPack();
const ClientId = "...";
const ClientSecret = "...";
pack.addNetworkDomain("zendesk.com");
pack.setUserAuthentication({
type: coda.AuthenticationType.Custom,
@erickoledadevrel
erickoledadevrel / pack.ts
Created February 17, 2023 15:33
Pack that authenticates with Supabase
import * as coda from "@codahq/packs-sdk";
export const pack = coda.newPack();
// TODO: Set domain and API key.
const ProjectDomain = "<subdomain>.supabase.co";
const ApiKey = <apikey>";
const ProjectUrl = `https://${ProjectDomain}`;
pack.addNetworkDomain(ProjectDomain);
@erickoledadevrel
erickoledadevrel / checkAndHide.gs
Last active April 9, 2022 16:53
Google Apps Script code to hide a row when a checkbox is checked.
/*
* Copyright 2019 Google LLC.
* SPDX-License-Identifier: Apache-2.0
*/
var CHECKBOX_COLUMN = 'B';
function onEdit() {
var range = SpreadsheetApp.getActiveRange();
if (range.getA1Notation().split(/\d/)[0] == CHECKBOX_COLUMN &&
@erickoledadevrel
erickoledadevrel / Code.gs
Last active April 12, 2021 20:48
Walkstation booking with Apps Script
/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
@erickoledadevrel
erickoledadevrel / moveToCalendar.gs
Last active November 16, 2023 07:02
Moving events from one calendar to another, using Google Apps Script
/**
* Move events with a given title from your primary calendar to another calendar.
* You must enable the Calendar Advanced Service:
* https://developers.google.com/apps-script/guides/services/advanced#enabling_advanced_services
*/
function moveEvents(eventTitle, fromCalendarName, toCalendarName) {
var fromCalendarId = CalendarApp.getCalendarsByName(fromCalendarName)[0].getId();
var toCalendarId = CalendarApp.getCalendarsByName(toCalendarName)[0].getId();
var now = new Date();
@erickoledadevrel
erickoledadevrel / downloadFileRange.gs
Created August 9, 2018 16:22
Downloading a portion of a Drive file in Apps Script.
function downloadFileRange(fileId, startByte, endByte) {
// Mention DriveApp in a comment to ensure the Drive scope is requested.
// DriveApp.getRootFolder();
var url = 'https://www.googleapis.com/drive/v3/files/' +
fileId + '?alt=media';
var response = UrlFetchApp.fetch(url, {
headers: {
Authorization: 'Bearer ' + ScriptApp.getOAuthToken(),
Range: 'bytes=' + startByte + '-' + endByte
}
function onOpen() {
DocumentApp.getUi().createMenu('Demo')
.addItem('Select Spreadsheet', 'selectSpreadsheet')
.addItem('Update Data', 'updateData')
.addToUi();
}
function selectSpreadsheet() {
var result = DocumentApp.getUi().prompt('Enter the ID of the spreadsheet:');
var spreadsheetId = result.getResponseText();
@erickoledadevrel
erickoledadevrel / UnmergedRanges.gs
Last active February 20, 2023 11:58
[Apps Script] Getting the unmerged ranges within a range
/**
* Gets all the unmerged ranges within a range.
* @param {SpreadsheetApp.Range} range The range to evaluate.
* @returns {SpreadsheetApp.Range[]} The unmerged ranges.
*/
function getUnmergedRanges(range) {
if (!range.isPartOfMerge()) {
return [range];
}
var mergedRanges = range.getMergedRanges();
@erickoledadevrel
erickoledadevrel / AppsMarketplaceSignIn.html
Created April 22, 2016 18:42
Showing how to use the Google Sign-in JavaScript library with Google Apps Marketplace.
<html>
<head>
<title>GAM Sample App</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/URI.js/1.17.1/URI.js"></script>
<script src="https://apis.google.com/js/platform.js?onload=init" async defer></script>
</head>
<body>
<h1>GAM Sample App</h1>
<p id="message">Loading...</p>
@erickoledadevrel
erickoledadevrel / Timezones.gs
Last active July 8, 2020 11:42
Some examples showing how to work with timezones in Apps Script.
// Setup: Spreadsheet in Pacific time, Script in Eastern time, Calendar in Mountain time.
// Sample spreadsheet: https://docs.google.com/spreadsheets/d/1neePK1YPKMKnVwI8dld0HSJjI1kSFPpcY8g7kG8xG4U/edit#gid=0
// A2 = 3/1/2016 9:00 AM, B2 = 3/1/2016 10:00 AM
/**
* The dates and times in the spreadsheet refer to exact moments in time, and the clock
* on the wall may show a different time.
*/
function copyMoment() {
var ss = SpreadsheetApp.getActive();