These utilities are grouped into related files, for simpler copy & paste to your scripts.
A couple of helper functions to convert to & from A1 notation.
/** | |
* Creates a menu entry in the Google Docs UI when the document is opened. | |
* | |
* @param {object} e The event parameter for a simple onOpen trigger. To | |
* determine which authorization mode (ScriptApp.AuthMode) the trigger is | |
* running in, inspect e.authMode. | |
*/ | |
function onOpen(e) { | |
DocumentApp.getUi().createAddonMenu() | |
.addItem('Clean Table of Contents', 'cleanToC') |
This is a sample script for sorting the cells on Google Spreadsheet with the background colors using Google Apps Script.
Unfortunately, in the current stage, it seems that sort(sortSpecObj)
of Class Range cannot directly sort by the background colors of cells. But when Sheets API is used, this goal can be achieved. Here, "SortRangeRequest" of the method of "spreadsheets.batchUpdate" in Sheets API is used.
/* A bare-bones GithubClient, just used for commits */ | |
function GithubClient(owner, repo, username, passwordOrToken) { | |
this.owner = owner; | |
this.repo = repo; | |
this.username = username; | |
this.passwordOrToken = passwordOrToken; | |
} | |
/* |
function sync() { | |
var id="XXXXXXXXXX"; // CHANGE - id of the secondary calendar to pull events from | |
var today=new Date(); | |
var enddate=new Date(); | |
enddate.setDate(today.getDate()+7); // how many days in advance to monitor and block off time | |
var secondaryCal=CalendarApp.getCalendarById(id); | |
var secondaryEvents=secondaryCal.getEvents(today,enddate); |
1. Copy/Paste the information below to the clipboard | |
2. Open the spreadsheet whose sheets need to be alphabetised | |
3. Choose Tools > Script editor > Blank (this opens a new tab in the browser) | |
4. Press Control+A followed by Control+V copy and paste the script in | |
5. Press Control+S to save the script | |
6. Choose Run > sortSheets | |
7. Go back to the spreadsheet tab to view the new sorted tab order | |
--Copy everything below this line-- | |
function sortSheets () { |
# walk_gdrive.py - os.walk variation with Google Drive API | |
import os | |
from apiclient.discovery import build # pip install google-api-python-client | |
FOLDER = 'application/vnd.google-apps.folder' | |
def get_credentials(scopes, secrets='~/client_secrets.json', storage='~/storage.json'): | |
from oauth2client import file, client, tools |
#!/usr/bin/env python3 | |
""" | |
Very simple HTTP server in python for logging requests | |
Usage:: | |
./server.py [<port>] | |
""" | |
from http.server import BaseHTTPRequestHandler, HTTPServer | |
import logging | |
class S(BaseHTTPRequestHandler): |