Skip to content

Instantly share code, notes, and snippets.

// import_json_appsscript.js
// https://gist.github.com/allenyllee/c764c86ed722417948fc256b7a5077c4
//
// Changelog:
// (Oct. 16 2019) tag: allenyllee-20191016
// 1. Fixed google script error: urlfetchapp - service invoked too many times https://stackoverflow.com/questions/10598179/google-apps-script-urlfetchapp-service-invoked-too-many-times
// (Jul. 16 2018) tag: allenyllee-20180716
// 1. Fixed the issue "If you try to query /arrayA[k]/arrayB[n]/arrayC[m]/.../member, you will always get /arrayA[k]/arrayB[k]/arrayC[k]/.../member."
// (Nov. 30 2017) tag: allenyllee-20171130
// 1. Add the ability to query array elements by using xpath like "/array[n]/member" where "n" is array index
@mesgarpour
mesgarpour / appsScript_ListFilesFolders_ver.2.js
Last active May 31, 2024 22:55
[Google Apps Script] List all files & folders in a Google Drive folder, & write into a speadsheet
/*
* Copyright 2017 Mohsen Mesgarpour
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@azadisaryev
azadisaryev / convertExcel2Sheets
Last active March 9, 2024 18:23
Google Apps Script for converting Excel (.xls or .xlsx) file to Google Spreadsheet. Drive API must be enabled in your script's Advanced Google Services and in Developers Console for the script to work (see https://developers.google.com/apps-script/guides/services/advanced#enabling_advanced_services for details).
/**
* Convert Excel file to Sheets
* @param {Blob} excelFile The Excel file blob data; Required
* @param {String} filename File name on uploading drive; Required
* @param {Array} arrParents Array of folder ids to put converted file in; Optional, will default to Drive root folder
* @return {Spreadsheet} Converted Google Spreadsheet instance
**/
function convertExcel2Sheets(excelFile, filename, arrParents) {
var parents = arrParents || []; // check if optional arrParents argument was provided, default to empty array if not
@davidjgraph
davidjgraph / gist:9d997cdf81f438bbd725
Created July 29, 2014 13:27
explore.js draw.io plugin
/**
* Explore plugin.
*/
Draw.loadPlugin(function(ui)
{
// Adds resource for action
mxResources.parse('exploreFromHere=Explore from here...');
// Max number of edges per page
var pageSize = 20;
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@junaidk
junaidk / resources.md
Last active January 4, 2023 10:25
Google App Script Resources
@mogsdad
mogsdad / digest.js
Last active October 29, 2021 03:28
This Google Apps Script function returns a string representing the 16-byte MD5 digest of a given message. It was originally written as an answer to StackOverflow question http://stackoverflow.com/questions/16216868/get-back-a-string-representation-from-computedigestalgorithm-value-byte. It's been refactored to support adaptation to other digest …
/**
* Return string representation of MD5 digest of the given message.
*
* @param {String} message Message to be encoded.
*
* @return {String} 16-byte digest value
*/
function signMd5(message){
return digest(Utilities.DigestAlgorithm.MD5, message);
}
@tommcfarlin
tommcfarlin / add-custom-post-type-menu.php
Created April 25, 2013 12:38
[WordPress] Add a custom post type menu as a child of an existing custom post type menu.
<?php
// Define the 'Portfolio' post type. This is used to represent galleries
// of photos. This will be our top-level custom post type menu
$args = array(
'labels' => array(
'all_items' => 'Gallery',
'menu_name' => 'Portfolio',
'singular_name' => 'Gallery',
'edit_item' => 'Edit Gallery',
@crstamps2
crstamps2 / jsonPuller
Created July 14, 2012 15:22
A Google apps script to pull json from a spreadsheet
function doGet(){
var ss = SpreadsheetApp.openById("//key ommitted");
return exportJSON(ss);
}
// Exports current sheet as JSON and displays in message box.
function exportJSON(ss) {
var sheet = ss.getSheetByName("sessions");
var rowsData = getRowsData(sheet);
@JuanCanham
JuanCanham / gist:2917132
Created June 12, 2012 12:02
Simple Google Apps script to update signatures accross a domain
function getSignature() {
//pretty basic function for testing
if ( startupChecks()) { return; }
var email = SpreadsheetApp.getActiveSpreadsheet().getActiveCell().getValue().toString();
if ( email === "" ) {
Browser.msgBox("No email selected", "Please select a cell containing a user's email" , Browser.Buttons.OK);
return;
}
var result = authorisedUrlFetch(email, {});
Browser.msgBox(result.getContentText());