Skip to content

Instantly share code, notes, and snippets.

View brainysmurf's full-sized avatar

Adam Morris brainysmurf

View GitHub Profile
@brainysmurf
brainysmurf / MeetsAuditActivityInsights.md
Last active April 28, 2020 12:40
A case study in writing reusable code on the Google AppsScripts (GAS) platform, with V8 features

Meets Audit Activity Insights

Interacts with the Activities.list endpoint available on GSuite domains that lists lots of Meets activity information. It's the same endpoint used in its own reporting console, such as the Meets Quality Tool.

It downloads row-by-row all of this raw information, going back days number of days, saves into the spreadsheet into meet data sheet.

Additional sheets contain pivot tables that provide insights into the data, such as IP location info, duration of calls, frequency of use. Leadership boards are derived from those pivot tables.

License

@brainysmurf
brainysmurf / README.md
Last active September 24, 2023 11:53
Learning V8 by re-solving old problems

Learning V8 by re-solving old problems

Here, I'll document some code I found to be much easier or better to do in an appscripts context with modern Javascript.

Breaking A1Notation into constituent parts

You have a string that represents a range speciation using a1Notation. You need to get the starting row number. Or you need to get the last column. Or you need to get all of those things. You'd like to do it in a way that can be reused. And you wonder if some of the new syntax features makes this interesting.

Let's go over the skeleton of the function first:

@brainysmurf
brainysmurf / README.md
Last active June 21, 2024 05:53
Things one can get used to for the V8 Google Apps Scripts engine

Things one can get used to for the V8 Google Apps Scripts engine

A bit of a monologue about various syntax changes and adjustments in learning and using the tool.

Logging is slooooooow

I know. Everyone knows.

That's why I wrote a library that writes to a spreadsheet instead. Ever since I started using it I'm far more productive. I don't know how people are still putting with that god-awful lagging logger.

@brainysmurf
brainysmurf / README.md
Last active December 25, 2023 03:00
Named parameters, required parameters, and interfaces

Interfaces in Javascript for Google Apps Scripts

I really like named parameters. I can live without them, but there is one place where I really need them. Cases in which I want to create a class and the paramters are guaranteed to be present, nothing extra. This is one way of implementing them. (It's kinda ugly, but kinda cool.)

Project Key

Either copy into your project, or use as a library: MWzXfEDYTWuJ_Xj0ap9H8-68b30WIDiE_

Wrong behaviour

@brainysmurf
brainysmurf / Code.js
Created February 22, 2020 03:40
'use strict' and Google AppsScript with V8 Runtime
function globalStrictMode_() {
'use strict';
return function () {
return this; // returns null in strict mode, global object if not
}.apply(null, []);
}
function globalDefaultMode_() {
return function () {
return this; // returns null in strict mode, global object if not
@brainysmurf
brainysmurf / README.md
Last active February 13, 2020 11:57
Loop Benchmarks: V8 vs RHINO

Loop Benchmarks: V8 vs RHINO

Looping code was written to be compatible with both engines. It simply does nested loops with multiplication in the body.

  • Conclusion: V8 is way faster.
  • Caveat: This does not paint a complete picture.

Results:

RHINO

@brainysmurf
brainysmurf / submit.md
Created February 13, 2020 00:36 — forked from tanaikech/submit.md
Benchmark: Reading and Writing Spreadsheet using Google Apps Script

Benchmark: Reading and Writing Spreadsheet using Google Apps Script

October 12, 2018 Published.

October 18, 2018 Updated. In order to compare with Advanced Google Service, a result of Sheets API by UrlFetchApp was added to Appendix.

@brainysmurf
brainysmurf / README.md
Last active November 5, 2020 07:38
Concurrency (lack thereof) in Google Apps Scripts V8

Concurrency in Google AppsScripts (V8)

Steps to reproduce

  • Run useForLoop independently, and observe it takes about 7 seconds to complete
  • Run entrypoint which calls useForLoop three times, asynchronously
  • Observe that the second run takes at least three times as long as the first run to complete
  • Repeat the process above but in a browser, and observe the expected behaviour

Conclusion: Even though the documentation indicates that you can define async functions, and that you can make Promises, it ain't actually async.

@brainysmurf
brainysmurf / import.py
Created December 24, 2019 11:46
Installing package into IDLE
import subprocess
import sys
subprocess.check_call([sys.executable, "-m", "pip", "install", "arcade"])
# If you wish to reverse the install, uncomment the following line:
# subprocess.check_call([sys.executable, "-m", "pip", "uninstall", "--yes", "arcade"])
try:
@brainysmurf
brainysmurf / README.md
Last active July 28, 2019 04:25
A post mortem of writing a kernel in Jupyter notebook with metakernel

Writing a custom kernel for Jupyter

Introduction / movitation

Already, Jupyter notebook system is great for sharing course content, and does it in a way that I can constantly write and improve it. However, there was one drawback in the course that I'm offering (IB Diploma Computer Science) and it's that it teaches Pseudocode, and not any official language. That means that I can't just ask them to open the terminal, or use a text editor and execute.

However, like all Open Source tools, Jupyter is very customizable. So I set to work. This is what I wanted:

  1. students can input pseudocode from scratch
  2. student can play with and improve code provided to them