There are many Google Apps Script projects and snippets scattered around this site. I’m going to try to organize them in this page, but it will take a while. If you find something on the site that you think should be linked here, please let me know. You are also welcome to contribute your own snips too. Please contact me via our forum
A series of short tutorials are available here Do something useful with GAS in 5 minutes
Many of these snippets are in the cUseful library.
All code here is unprotected and free to re-use. For more details see Reusing code from this site. If you find this site useful and wish to support it, you can do so by buying my book or video course .
General JavaScript techniques
- Namespaces in libraries and scripts
- Untangling with promises
- Advanced Array functions
- Flattening an object with dot syntax
- Flattening and unflattening objects to spreadsheets
- Chaining JavaScript
- JavaScript recursion primer
- More recursion – parents and children
- Traversing a tree
- Using timing functions to get insight into Sheets
- Using Object.create in Apps Script
- JavaScript closures – how, where and why
- Converting SVG to PNG with JavaScript
- Dynamically creating tables with clusterize.js
- Calculating the last day of a given weekday in the month
- Use promise instead of callback for settimeout
- Changing a class dynamically
- Cross Origin Resource sharing (CORS)
- Canvasser
- Generating and managing random lists with JavaScript and Apps Script
- Apps Script as a proxy
- Sorting Google Sheet DisplayValues
- Publishing ES6 code on NPM
- Exponential backoff for promises
- ES6 JavaScript features
- Abstracting services with closures
- JavaScript currying and functional programming
- JavaScript currying and functional programming – even more
- Composing functions and functional programming
- Shortcut for adding nested properties to a JavaScript object
- Formatting GraphQL queries
- Roughly matching text
- Calculating image dimensions in server side apps script
- Improved namespace pattern for Apps Script
- Squeezing more into (and getting more out of) Cache services
- Google Drive as cache
- Recursive async functions
Music maths and physics
Fiddler – a functional approach to fiddling with tabular data
- A functional approach to fiddling with sheet data
- Unique values with data fiddler
- More sheet data fiddling
- Fiddling with text fields that look like dates
- A functional approach to updating master sheet
- Populating sheets with API data using a Fiddler
- Header formatting with fiddler
- Formatting sheet column data with fiddler
- Styling Gmail html tables
- Sorting Google Sheet DisplayValues
- Fiddler and rangeLists
- Optimizing sheet formatting with Apps Script
Apps Script specific
- Apps Script as a proxy
- Reporting file, function and line number in Apps Script
- How to determine what kind of object something is in Apps Script
- Backing off on rate limiting
- A recursive extend function for Apps Script
- Custom checking for exponential backoff
- Checking the argument types in Apps Script
- Create sha1 signatures with apps script
- Why Base64
- Including the stack in custom errors
- Generating test data for sheets and tables
- Convert JSON to XML
- From Xml to JSON
- Using Apps Script for xml json conversion
- Counting script and library usage
- Exponential backoff
- Addressing namespace and library methods from google.script.run
- Creating a key digest to use for a cache key or to compare content
- Zipping to make stuff fit in cache or properties service.
- Identifying duplicates on Drive
- Logging differences in strings in Apps Script
- Dealing with objects that are too large for the property or cache store
- Anonymous user registration with the Apps Script PropertiesService
- Generating coupon codes with expiry dates
- Generating and managing random lists with JavaScript and Apps Script
- Transform dates for add-on transfer
- Simple server side polling
- How to get stats about youtube videos in your channel with apps script
- Using exponential backoff with github api – dealing with data “in preparation”
- Use Drive properties to find app files
- Using Es6 with Apps Script
- Apps Script const scoping problems
- What JavaScript engine is Apps Script running on?
HTML Service
- Parallel process orchestration with HtmlService
- Running things in parallel that need oAUTH2 – datastore
- Sharing code between client and server
- More client server code sharing
- Getting an htmlservice template from a library
- Passing data to html service
- How to pass non stringifyable objects to html service
- Pseudo binding in HTML service
- Add-on spinner
- Copying canvas and svg images from your Add-on
- Measuring library load speed
- Using promises with apps script
- Watching for server side changes from the client html service – sheets
- Watching docs for changes
- Implementing a client side progress bar reporting on server side work for htmlService
- Using promises to orchestrate Html service polling
- Organizing asynchronous calls to google.script.run
- Organizing parallel streams of server calls with google.script.run promises
- Reusing html stuff between Apps Script projects
D3
- Configurable circular timer with D3
- Example of clock using d3 configurable timer
- Quick doughnut and pie charts with a radial timer
- Using D3 in server side Gas
Docs specific
- Sorting bookmarks in a document
- Cleaning up a document format
- Cleaning up heading levels
- Normalizing the header level of blank paragraphs
- Large document performance
- Extracting images from a document
- Removing Duplicate Paragraphs
- Adding abstracts to documents
- Bulk search and replace images in Google Docs
- Converting Google Docs table to JSON and back
Sheets specific
- Data wrangling with named columns in Google Spreadsheet
- Summarizing emails to a sheet
- How to transpose spreadsheet data with apps script
- Column numbers to characters
- Importing Predictwise data
- Transposing sheet data – another way
- Using array formulas to improve performance
- Filling ranges
- Using the Itunes API with Apps Script
- Optimizing showing and hiding rows and columns
- Detecting Spreadsheet tables automatically with Google Apps Script
- Generating and managing random lists with JavaScript and Apps Script
- Converting timestamps to dates formula
- Highlight duplicate rows in a sheet – map, filter and every
- Highlight duplicate rows in a sheet – map and reduce
- Creating and working with transposed sheet data arrays
- Sheets API – Developer Metadata
- Sheets Developer Meta Data – Apps Script advanced service
- Sheets Meta Data Advanced service library utilities
API specific
- Finding a Drive App folder by path
- Migrating user and script properties
- Multiple inserts in Fusion Tables
- Universal analytics measurement protocol for your GAS libraries
- Universal analytics for checking co-operating processes
- Minimizing maps directionfinder api calls
- Direction minimizer – other usages
- Extract the plus one counts from a page
- Get GAS library info
- Inviting members to Google Plus from Groups
- Patching site HTML
- Using Advanced Drive service to convert files
- Creating a pile of files list from Google Drive
- Loading large JSON data to BigQuery with Apps Script
- Resumable uploads – writing large files to Drive with Apps Script
- Using sheets via Bigquery from Apps Script
- Using the Slideshare API from Apps Script
- A webapp to share copies of the contents of folders
- Sheets API – Developer Metadata
- Tracking github pageviews
Reorganizing your sites hosted files
- Finding where Drive hosting is being used in Sites
- Identifying hosted files
- Copying to new host location
Libraries
Here are some libraries you might find useful and are welcome to use.
- SunCalc
- moment.js
- Using crossfilter with Google Apps Script
- EzyOauth2 – taking some pain out of Apps Script API authentication
- Using named locks with Google Apps Scripts
- Parallel processing in Apps Script
- EasyCron Library
- CryptoJS libraries for Google Apps Script
- Database abstraction with google apps script
- OAuth2 for Apps Script in a few lines of code
Web apps
The web apps will use the GAS content service and return JSON or JSONP (if you include &callback=) when you call them