Skip to content

Instantly share code, notes, and snippets.

@tariqhamid
tariqhamid / Google_OAuth2.js
Created August 30, 2016 15:34 — forked from entaq/Google_OAuth2.js
Simple Google+ OAuth 2.0 calls in Apps Script
/**
reference -
https://developers.google.com/accounts/docs/OAuth2WebServer
https://code.google.com/apis/console/
https://developers.google.com/+/api/latest/
**/
////handle all requests here
function doGet(e) {
@tariqhamid
tariqhamid / gist:936567218757acc123e887e27db472a2
Created August 21, 2016 17:14 — forked from kyo-ago/gist:9873380
休日だけhueの操作を変えるGAS(作りかけ)
var account = {
'email': '',
'password': ''
};
var bridgeid = '';
var initializeParameter = {
'devicetype' : 'GAS',
'username' : 'newdeveloper'
};
@tariqhamid
tariqhamid / Apps Script pdfToText utility.md
Created August 17, 2016 15:15 — forked from mogsdad/Apps Script pdfToText utility.md
For http://stackoverflow.com/questions/26613809, a question about getting pdf attachments in gmail as text. I got a little carried away - this does much more than asked.

Google Apps Script pdfToText Utility#

This is a helper function that will convert a given PDF file blob into text, as well as offering options to save the original PDF, intermediate Google Doc, and/or final plain text files. Additionally, the language used for Optical Character Recognition (OCR) may be specified, defaulting to 'en' (English).

Note: Updated 12 May 2015 due to deprecation of DocsList. Thanks to Bruce McPherson for the getDriveFolderFromPath() utility.

    // Start with a Blob object
    var blob = gmailAttchment.getAs(MimeType.PDF);
    
@tariqhamid
tariqhamid / httpGetTemplate.gs
Created August 12, 2016 10:57 — forked from mogsdad/httpGetTemplate.gs
Google Apps Script template functions for external host communication with UrlFetchApp. See https://mogsdad.wordpress.com.
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* httpGetTemplate.gs
*
* A pair of template functions for external host communication with
* UrlFetchApp, including parameter encoding and error handling.
*
* From: gist.github.com/mogsdad/a76c32231a2b91ff8b59
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@tariqhamid
tariqhamid / download.js
Created August 10, 2016 19:46 — forked from mkaminsky11/download.js
How to manipulate Google Drive files
/*
Download a file
*/
function downloadFile(fileId) {
var request = gapi.client.drive.files.get({
'fileId': fileId
});
request.execute(function(resp) {
window.location.assign(resp.webContentLink);
});
@tariqhamid
tariqhamid / README.md
Created August 10, 2016 19:40 — forked from nicerobot/README.md
Create Google Drive webViewLink folders via JavaScript.

Create Google Drive webViewLink folders via JavaScript (You must change CLIENT_ID before this will work.)

These folders are suitable for publishing websites. Once the folder is created, simply upload index.html and other resources to the folder.

@tariqhamid
tariqhamid / cbl.js
Created August 9, 2016 22:44 — forked from patt0/cbl.js
ContinuousBatchLibrary is a Google Apps Script library that manages large batches and works around the 5 minute limitation of GAS execution. It does this by setting time based triggers in the future as well as memorising the last processed key in the batch in order to restart from the correct position. At the end of the batch a cleanup function …
/**
* --- Continous Execution Library ---
*
* Copyright (c) 2013 Patrick Martinent
*
* 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
@tariqhamid
tariqhamid / 3G-camera.gs
Created August 9, 2016 19:00 — forked from polvi/3G-camera.gs
app-script for taking a twilio MMS post from a 3G game camera to google drive
/* Connect your 3g game camera to google drive
* 1) buy camera: http://www.amazon.com/Covert-Special-Ops-Cellular-Camera/dp/B00806KGY6
* 2) Configure it to point to your twilio number
* 3) Deploy google app script below as a public webapp
* 4) Configure twilio to point to your app script
*/
function doGet() {
return ContentService.createTextOutput("");
@tariqhamid
tariqhamid / sign_s3.gs
Created August 9, 2016 18:21 — forked from andsens/sign_s3.gs
Google spreadsheet function for signing S3 URLs (very handy for CSV cost allocation reports when combined with the ImportData() function)
function sign_s3(access_key, private_key, bucket, object_name, validity, base_url) {
if(!base_url) {
base_url = "http://s3.amazonaws.com";
}
if(!validity) {
validity = 60;
}
expires = Math.floor((new Date()).getTime() / 1000) + validity;
object_name = encodeURIComponent(object_name);
stringToSign = "GET\n\n\n"+expires+"\n/"+bucket+"/"+object_name;
function main() {
MccApp.accounts().withCondition("Cost > 1.00").forDateRange("YESTERDAY").withLimit(50).executeInParallel('runOnEachAccount', 'finished');
}
function runOnEachAccount() {
Logger.log('Starting on: '+AdWordsApp.currentAccount().getCustomerId());
var results = getAccountReport();
Logger.log(results);
return JSON.stringify(results);
}