Skip to content

Instantly share code, notes, and snippets.

@matthewfinnell
matthewfinnell / MergeAllSheets
Created August 9, 2014 19:22
Google Apps Script to merge all data from multiple sheets into a single sheet for reporting on Google Drive Sheets.
/* MergeAllSheets
*
* Takes a list of sheet names and add their data to a single sheet
* Uses leftmost col. for names of the orginiating sheet of ea. row
* If no args specified, takes all sheets except current - reports count
*
* Always assumes header row (doesn't take row 1 of anything)
*
* Usage:
* =MergeAllSheets("D.C.","Illinois","Los Angeles","Massachusetts","Ohio","Seattle")
@kythin
kythin / share.js
Created April 15, 2014 23:29
JS Social share functions
function fbShare(url, title, descr, image, winWidth, winHeight) {
var winTop = (screen.height / 2) - (winHeight / 2);
var winLeft = (screen.width / 2) - (winWidth / 2);
title = encodeURIComponent(title);
url = encodeURIComponent(url);
descr = encodeURIComponent(descr);
image = encodeURIComponent(image);
window.open('http://www.facebook.com/sharer.php?s=100&p[title]=' + title + '&p[summary]=' + descr + '&p[url]=' + url + '&p[images][0]=' + image, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight);
@mhawksey
mhawksey / TAGS v5.1.1.js
Last active August 17, 2016 08:27
Version 5.1.1 of TAGS script. Open Tools > Script editor and replace the TAGS.gs code with the one below
// This code excluding Google(c) Code tab:
/*
Copyright 2013 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
@chrislkeller
chrislkeller / import_json_appsscript.js
Last active March 25, 2024 19:45
Adds what amounts to an =ImportJSON() function to a Google spreadsheet... To use go to Tools --> Script Editor and add the script and save.
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@mhawksey
mhawksey / gist:1106744
Last active April 23, 2024 22:02
Bunch of Google Apps Script snippets for getting social bookmark/share counts. Used in http://mashe.hawksey.info/2011/07/shared-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
@tomcritchlow
tomcritchlow / Google Docs Script
Created April 5, 2011 18:36
The Google Spreadsheets Script Used To Call Social Media APIs
function FBshares(url) {
var jsondata = UrlFetchApp.fetch("http://graph.facebook.com/"+url);
var object = Utilities.jsonParse(jsondata.getContentText());
return object.shares;
}
function Tweets(url) {
var jsondata = UrlFetchApp.fetch("http://urls.api.twitter.com/1/urls/count.json?url="+url);
var object = Utilities.jsonParse(jsondata.getContentText());
return object.count;