Skip to content

Instantly share code, notes, and snippets.

@mhawksey
mhawksey / gist:1388321
Created November 23, 2011 10:03
TAGS 2.4.4 Google Apps Script to pull searches from the Twitter API into a Google Spreadsheet (see http://bit.ly/TAGSsetup )
View gist:1388321
// Part of this code up to END OF (c) is:
/*
Copyright 2011 Martin Hawksey
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
@mhawksey
mhawksey / gist:1170597
Created August 25, 2011 13:02
Google Apps Script to fill in a Document template with Spreadsheet data
View gist:1170597
function onOpen() {
var menuEntries = [ {name: "Create Diary Doc from Sheet", functionName: "createDocFromSheet"}];
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.addMenu("Fitness Diaries", menuEntries);
}
function createDocFromSheet(){
var templateid = "1O4afl8SZmMxMFpAiN16VZIddJDaFdeRBbFyBtJvepwM"; // get template file id
var FOLDER_NAME = "Fitness Diaries"; // folder name of where to put completed diaries
// get the data from an individual user
@mhawksey
mhawksey / gist:1276293
Last active February 17, 2023 11:14
Google App Script to insert data to a google spreadsheet via POST or GET - updated version as per https://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
View gist:1276293
/*
Copyright 2011 Martin Hawksey
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
@mhawksey
mhawksey / Method1.gs
Created February 17, 2023 09:07
Google Apps Script methods for generating Google My Drive report.
View Method1.gs
// @OnlyCurrentDoc
const FOLDER_ID = 'YOUR_FOLDER_ID'; // OR 'root' if you want your entire My Drive
/**
* Method One: Using built-in DriveApp / file iterator
*/
function generateFolderFilesDriveApp() {
try {
const folderId = FOLDER_ID;
const parentFolder = (folderId === 'root') ? DriveApp.getRootFolder() : DriveApp.getFolderById(folderId);
@mhawksey
mhawksey / gist:1442370
Last active January 1, 2023 07:51
Google Apps Script to read JSON and write to sheet
View gist:1442370
function getJSON(aUrl,sheetname) {
//var sheetname = "test";
//var aUrl = "http://pipes.yahoo.com/pipes/pipe.run?_id=286bbb1d8d30f65b54173b3b752fa4d9&_render=json";
var response = UrlFetchApp.fetch(aUrl); // get feed
var dataAll = JSON.parse(response.getContentText()); //
var data = dataAll.value.items;
for (i in data){
data[i].pubDate = new Date(data[i].pubDate);
data[i].start = data[i].pubDate;
}
@mhawksey
mhawksey / appsscriptzoneids.csv
Last active December 27, 2022 17:00
ZoneIds used in Google Apps Script
View appsscriptzoneids.csv
value text
Pacific/Midway (GMT-11:00) Midway
Pacific/Niue (GMT-11:00) Niue
Pacific/Pago_Pago (GMT-11:00) Pago Pago
Pacific/Honolulu (GMT-10:00) Hawaii Time
Pacific/Johnston (GMT-10:00) Johnston
Pacific/Rarotonga (GMT-10:00) Rarotonga
Pacific/Tahiti (GMT-10:00) Tahiti
Pacific/Marquesas (GMT-09:30) Marquesas
America/Anchorage (GMT-09:00) Alaska Time
@mhawksey
mhawksey / gist:3007293
Created June 27, 2012 22:26
Turn Google Site pages into RSS feed
View gist:3007293
/*
Copyright 2011 Martin Hawksey
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
@mhawksey
mhawksey / gist:193bca4037d9a48d7f58
Last active December 12, 2022 07:26
Automatically updating a Google Sheet with data from Google Analytics for regular reporting
View gist:193bca4037d9a48d7f58
function fetchMyQuery() {
// our query object
var query = {
"optionalArgs": {
"dimensions": "ga:source",
"filters": "ga:medium==referral",
"sort": "-ga:pageviews",
"max-results": "50"
},
"ids": "ga:82426939",
View feed-property-feed.php
<?php
/**
* RSS2 Feed Template for displaying RSS2 Posts feed.
*
* @package WordPress
*/
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
$more = 1;
echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
@mhawksey
mhawksey / gEVS.html
Created December 13, 2010 21:06
Example of using Google Spreadsheet and Visualization API as a multi question voting (clicker) system
View gEVS.html
<!--
You are free to copy and use this sample in accordance with the terms of the
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>gEVS Using Google Spreadsheet and Visualization API as a voting system wrapper</title>