Skip to content

Instantly share code, notes, and snippets.

View labnol's full-sized avatar
🇮🇳
Building stuff for the Internet!

Amit Agarwal labnol

🇮🇳
Building stuff for the Internet!
View GitHub Profile
@labnol
labnol / gist:1907309
Created February 25, 2012 08:15 — forked from mhawksey/gist:1029258
Google Apps Script to display email notification
function doGet(e) {
try{
var app = UiApp.createApplication();
var mainPanel = app.createVerticalPanel();
var emailTable = app.createFlexTable().setId("emailTable");
app.add(mainPanel);
mainPanel.add(emailTable);
var mail = GmailApp.getInboxThreads(0, 10);
for (var i = mail.length; i > 0; i--) {
var msg = mail[i-1];
@labnol
labnol / mail-merge-gmail.js
Last active August 14, 2019 00:50 — forked from gnunicorn/mass_emailer.js
Source Code for Mail Merge
/*
* Added Remaining Quota Notifications
* Renamed a few menu options
* Forked from gist: 1838132 by ligthyear
*/
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [ {name: "Start Mail Merge", functionName: "fnMailMerge"}];
ss.addMenu("Mail Merge", menuEntries);
@labnol
labnol / youtubeOAuthGoogApps.js
Created February 25, 2012 08:16 — forked from psychemedia/youtubeOAuthGoogApps.js
Youtube OAuth in Google Apps Script
function youtube(){
// Setup OAuthServiceConfig
var oAuthConfig = UrlFetchApp.addOAuthService("youtube");
oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope=http%3A%2F%2Fgdata.youtube.com%2F");
oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
oAuthConfig.setConsumerKey("anonymous");
oAuthConfig.setConsumerSecret("anonymous");
// Setup optional parameters to point request at OAuthConfigService. The "twitter"
@labnol
labnol / twitterlinks.js
Created February 25, 2012 08:17 — forked from kurtraschke/twitterlinks.js
Google Apps Script to turn Twitter usernames into links
@labnol
labnol / updatetweets.js
Created February 25, 2012 08:17 — forked from kurtraschke/updatetweets.js
Google Apps Script to set cell comment to latest Tweet
function setComments() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var twitterDataRange = ss.getRangeByName("Twitter3");
vals = twitterDataRange.getValues();
for (i in vals) {
var row = vals[i];
for (j in row) {
var col = vals[i][j];
if (col.length > 0) {
@labnol
labnol / gist:1907314
Created February 25, 2012 08:18 — forked from mhawksey/gist:1442370
Google Apps Script to read JSON and write to sheet
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 = Utilities.jsonParse(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;
}
@labnol
labnol / gist:1907315
Created February 25, 2012 08:18 — forked from mhawksey/gist:1658408
Google Apps Script mashup to send free SMS notifications using Google Calendar guest invite feature
/*
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
@labnol
labnol / gist:1907316
Created February 25, 2012 08:19 — forked from mhawksey/gist:1170597
Google Apps Script to fill in a Document template with Spreadsheet data
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
@labnol
labnol / gist:1907319
Created February 25, 2012 08:19 — forked from mhawksey/gist:1383136
Google Apps Script to turn line breaked text and wiki markup links for UI Services
// http://goodoldhacking.blogspot.com/2011/01/workaround-for-html-in-apps-script.html
/**
* Returns a widget formatted with the text.
* Modified my mhawksey for inline links
*/
function formatTextPanel(a, text) {
var app = a ;
var panel = app.createFlowPanel();
var lines = text.split("\n");
@labnol
labnol / gist:1907321
Created February 25, 2012 08:19 — forked from mhawksey/gist:1723943
Core Google Apps Script Functions
// The rest of this code is currently (c) Google Inc.
// setRowsData fills in one row of data per object defined in the objects Array.
// For every Column, it checks if data objects define a value for it.
// Arguments:
// - sheet: the Sheet Object where the data will be written
// - objects: an Array of Objects, each of which contains data for a row
// - optHeadersRange: a Range of cells where the column headers are defined. This
// defaults to the entire first row in sheet.
// - optFirstDataRowIndex: index of the first row where data should be written. This