Skip to content

Instantly share code, notes, and snippets.

@patcon
Last active August 29, 2015 13:59
Show Gist options
  • Save patcon/10791600 to your computer and use it in GitHub Desktop.
Save patcon/10791600 to your computer and use it in GitHub Desktop.
Google App Scripts for gittip budgeting (for use in Google Spreadsheet "Tools > Script editor...")

Usage

  • Create new spreadsheet.
  • Click Tools > Script editor...
  • Copy in code.js.
  • Save with an arbitrary name, and then click the "Run" arrow.
  • Go back to spreadsheet.
  • Use custom functions like this in a cell: =getGittipReceivingIndividual("patcon")
function getGittipReceivingIndividual(username) {
if (typeof username != "string") {
throw "input must be a string";
}
var url = 'https://www.gittip.com/' + username + '/public.json';
var response = UrlFetchApp.fetch(url);
var json = response.getContentText();
var data = JSON.parse(json);
return parseFloat(data.receiving);
}
function getGittipReceivingTeam(team, username) {
var url = 'https://www.gittip.com/' + team + '/members/index.json';
var response = UrlFetchApp.fetch(url);
var json = response.getContentText();
var data = JSON.parse(json);
var user_data = data.filter(function(u){
return u.username === username
});
return parseFloat(user_data[0].take);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment