Skip to content

Instantly share code, notes, and snippets.

View Spencer-Easton's full-sized avatar

Spencer Easton Spencer-Easton

View GitHub Profile
#include "vertex.h"
#include "graph.h"
#include "set.h"
using namespace std;
class base
{
public:
@Spencer-Easton
Spencer-Easton / InteratorService.gs
Created December 16, 2016 21:28
A stupid simple Iterator Service
var IteratorService_ = function(array){
var newArray = array.slice(0);
Object.defineProperty(newArray, 'nextIndex', { value: 0, enumerable: false, writable:true });
Object.defineProperty(newArray, 'next', { value: function(){if(this.nextIndex >= this.length){throw new Error("NoSuchElementException")}else{return this[this.nextIndex++]}}, enumerable: false });
Object.defineProperty(newArray, 'hasNext', { value: function(){return (this.nextIndex < this.length)}, enumerable: false });
return newArray;
}
function emailReminder() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var leases = ss.getSheetByName("Leases").getDataRange().getValues();
var emails = ss.getSheetByName("Emails").getDataRange().getValues();
var notificationWindows = {}
notificationWindows[addMonths(new Date(),6)] = makeNotifications(emails, "Six Months");
notificationWindows[addMonths(new Date(),3)] = makeNotifications(emails, "Three Months");
notificationWindows[addMonths(new Date(),1)] = makeNotifications(emails, "One Month");
application: YOURPROJECTID
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /(.+)
static_files: public/\1
upload: public/(.*)
@Spencer-Easton
Spencer-Easton / gist:0d203b757783e0d35087
Last active August 13, 2016 05:12
firebase.json hosting example
{
"hosting": {
"public": “.”,
"headers":[{
"source":"**",
"headers":[{
"key":"Access-Control-Allow-Origin",
"value":"*"
}]
}]
@Spencer-Easton
Spencer-Easton / exportSpreadsheet.gs
Last active November 19, 2024 09:35
Example on how to export a Google sheet to various formats, includes most PDF options
function exportSpreadsheet() {
//All requests must include id in the path and a format parameter
//https://docs.google.com/spreadsheets/d/{SpreadsheetId}/export
//FORMATS WITH NO ADDITIONAL OPTIONS
//format=xlsx //excel
//format=ods //Open Document Spreadsheet
//format=zip //html zipped
@Spencer-Easton
Spencer-Easton / Duel Auth Example
Last active August 29, 2015 14:20
Duel Auth for a script
var localAuth = false;
var sProps = PropertiesService.getScriptProperties();
function doGet() {
var driveService = getDriveService();
if (!driveService.hasAccess()) {
return showAuth();
}
@Spencer-Easton
Spencer-Easton / XMLtoJSON
Created April 8, 2015 17:30
Script to convert XML to JSON using XmlService - Originaly published in a +Google Apps Script community thread by Eric Koleda
/**
* Converts an XML string to a JSON object, using logic similar to the
* sunset method Xml.parse().
* @param {string} xml The XML to parse.
* @returns {Object} The parsed XML.
*/
function xmlToJson(xml) {
var doc = XmlService.parse(xml);
var result = {};
var root = doc.getRootElement();