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 / whd_google_docs.js
Created February 25, 2012 08:26 — forked from kevee/whd_google_docs.js
Web Help Desk post to Google Docs
// INSTRUCTIONS:
// 1. Start a new form in Google docs
// 2. Go to Tools > Script editor from the spreadhseet
// 3. Paste in the below code
// 4. Go to Triggers > Current script's triggers
// 5. Add a new trigger
// 6. Select "onFormSubmit" then "On Form Submit" from the third select box. Click save.
// 7. Save the script and go back to your spreadsheet. You should see a "WHD Options" menu.
// 8. Click WHD Options > Ticket settings and enter the API key (from WHD's user setting screen) and the URL to your "Create Ticket" post. The script will automatically append "?apiKey=xxx" to the end of this URL.
// 9. Use the email settings in the WHD Options if you want to email users with their WHD ticket.
/**
* POST data from a Google Spreadsheet to a remote URL, via menu option Add-ons > Post values
* See: http://www.google.com/google-d-s/scripts/guide.html for more info
*/
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var r = sheet.getRange("B5");
function onOpen() {
@labnol
labnol / google_apps_script
Created February 25, 2012 08:22 — forked from kysnm/google_apps_script
Google Analytics API for Google Docs
var DateTime = function() {
var now = new Date();
this.year = now.getFullYear();
this.month = ('00' + now.getMonth()).slice(-2);
var monthEndDate = new Date(this.year, this.month, 0);
this.startDate = this.year + '-' + this.month + '-01';
this.endDate = this.year + '-' + this.month + '-' + monthEndDate.getDate();
}
var Profile = function(profileName, tableId) {
@labnol
labnol / gist:1907325
Created February 25, 2012 08:20 — forked from mhawksey/gist:1106744
Google Apps Script - Social Bookmarking Counts
/*
All code apart from getPlusones()
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
@labnol
labnol / gist:1907323
Created February 25, 2012 08:20 — forked from mhawksey/gist:1388321
Google Apps Script - Twitter Search
// 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
@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
@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: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: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: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;
}