Kanshi Tanaike
function ChunkyCache(cache, chunkSize){ | |
chunkSize = chunkSize || 100*1024; | |
return { | |
put: function (key, value, timeout) { | |
var json = JSON.stringify(value); | |
var cSize = Math.floor(chunkSize / 2); | |
var chunks = []; | |
var index = 0; | |
while (index < json.length){ | |
cKey = key + "_" + index; |
This is a sample script for easily retrieving the reformatted scripts without comments in a project using Google Apps Script (GAS).
When I create GAS script, if the format of script is not correct, the script editor lets me know about it. By this, I can find that the script editor and/or Google Drive checks the format of scripts. I had wished if I could use this function. Recently, I noticed an interesting function. A GAS project is created and when function myFunction() {Logger.log(this)}
is run in the script, I noticed that all scripts in the project are included in this
. Furthermore, when I saw the retrieved script, also I noticed that their scripts are reformatted and all comments are removed. In the case of Apps Script API, when the scripts are retrieved by the API, the retrieved script is the same to the original one. So I think that this will help users retrieve simply the reformat
<!DOCTYPE html> | |
<html> | |
<head> | |
<script> | |
var data | |
var formId = 'form' | |
function drawForm() { | |
if (!data) return | |
var outputEl = document.getElementById(formId); |
const gulp = require( 'gulp' ); | |
const spawn = require( 'child_process' ).spawn; | |
/** | |
* This solution to execute and watch a shell function from Gulp is | |
* adapted from https://stackoverflow.com/a/10232330/3232832 | |
* | |
* e.g. callSpawn( 'ping', [ '-c 5', 'google.com' ], cb ); | |
*/ | |
function callSpawn( command, arguments, cb ) { |
/* | |
Suppose there is some endpoint that returns a jsonp to you, as in Google Visualization API | |
It gives you a text response that looks like this: | |
"some.namespace.nameOfFunction({obj:'blah'})" | |
We want the object inside that function call. | |
In a google app scripting context, we have no choice but to evaluate it the old-fashioned way, using "evil" eval(). | |
This solution builds a variable that resolves the namespace some.namespace.blah.blah and which ultimately becomes | |
a function that returns the passed parameter. | |
We build the variable with raw text, then eval it, giving the local context the ability to resolve the namespace and |
There are event objects at Google Apps Script. Typically, users which use Spreadsheet often use onEdit(event)
. Here, I would like to introduce the process costs for the event objects using this onEdit(event)
.
When onEdit(event)
is used for the spreadsheet, event
of onEdit(event)
has the following structure.
{
"authMode": {},
function numberWithSpaces(nr) { | |
return nr.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " "); | |
} |