- 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")
Last active
August 29, 2015 13:59
-
-
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...")
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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