44 comments

[ 3.1 ms ] story [ 100 ms ] thread
It's definitely fun to mess around with. Nicely, done! Quick question: why do repo and gist counts cap at 100? I haven't looked at Github's API myself yet, so there might be a technical limitation here that I'm unaware of.
Yeah, there are a lot of technical limitations that we had to work around. Mainly, everything is paginated with a max per_page of 100. We decided to only analyze the 100 most recent gists and repos to not have to worry about that.

For commits, however, we couldn't not analyze them, so we do a ton of processing. Basically, we loop over every one of your repos and loop over all of the pages of commits for that repo. For big repos (i.e. Facebook), that means we end up doing 100s of async API requests...it gets pretty intense.

It makes sense that you're analyzing only the first 100, but it would probably be cool to add the raw quantities of these things as a metric. Perhaps they shouldn't count towards the score, but it would be cool to display them, and the info's readily available from https://api.github.com/users/:uname
What is it doing while "processing"? A progress bar would be a good idea.
I said it below, but the big chunk of "processing" is looking at all of the commits for all of your repos. There's no good way to access this data, so we essentially loop over all of your repos and than for each repo loop over all the pages of commits--a lot of API requests.
Unlocking the secret of life, apparently. At least, that's what it says it's doing now, after complaining that nobody else had got this far. It's been about 5 minutes...

...maybe it would have been wise to start with a table of existing entries that could be resolved quickly. I don't use Git and couldn't think of any accounts off the top of my head, so I just set 'abc' against 'xyz' on the theory that those usernames were likely to exist. UPDATE: I'm getting the behavior with Obama v Romney and indeed Jesse P v Remy G. Maybe the server's just overloaded...

Hmmm...it shouldn't be taking that long? Would you mind checking your console?
Sure:

  Failed to load resource https://platform.twitter.com/widgets.js
  Port error: Could not establish connection. Receiving end does not exist. miscellaneous_bindings:236
  chromeHidden.Port.dispatchOnDisconnect miscellaneous_bindings:236
  Uncaught ReferenceError: twttr is not defined app.js:190
¯\(°_o)/¯
:/ twitter's javascript api seems to have broken...weird. refresh and try again?
Maybe it's me...I have adblock, Ghstery, and Disconnect running.
Looks like everyone else has discovered this too. I'm getting back messages that I've discovered the secret of life and still no results...
are there still repos left under the processing box? if so, would you mind checking your console?
Uncaught ReferenceError: twttr is not defined

EDIT: My cookie-blocking plugin apparently was blocking something critical.

Also got the same error due to the Twitter button not loading. It might be a good idea to handle that case in the code.
should be handled now, sorry about that!
Sorry, failed to follow up on this. It does work well now.
Maybe it would be "exactly what it sounds like" if it was instead called "GitHubBattle". Git != GitHub
It seems like it overvalues Gists a bit. :)
It actually only values them as 5% of your score...despite their prominence :P
Not sure if it can handle big repos very well, I just threw in Twitter vs Facebook for fun and I got stuck with the "secret of life" message. But it's pretty neat! :)
Yeah, we loop over every page of commits for every repo for each user, so it takes a little while...that being said, if you wait it's pretty cool to see. Twitter is ~90 and Facebook is ~80.

I reached out to Github to see if there was a better way to do this, but they said there wasn't, unfortunately.

regarding the twitter vs facebook issue, checking the network panel on chrome, the rest of the request are pending and checking one of the requested url (https://api.github.com/repos/twitter/twitter4j/commits)

the error message is:

{ "message": "API Rate Limit Exceeded for 112.199.99.5" }

In the code, if you look, I actually extend that rate limit to 5000 by using authenticated requests (on the client side, I know, this is "dangerous"). The problem is that it just takes a long long time, lots of request (~400 for Facebook alone), which gradually slow down as the browser gets overloaded.
If this is failing for you, make sure you haven't blocked twitter using Ghostery or the like, as this causes the script to error out.

    Uncaught ReferenceError: twttr is not defined app.js:196
    setupWinner app.js:196
Maybe the script can be made a bit more robust in this case?
Good idea! Added a check to see if twttr is defined, if it isn't I just don't add the share through twitter button. Thanks!
No worries :)

I should have opened a pull request for you!

Awesome to see the quick turn around on your repo, though I haven't seen it deployed yet. It looks like you are using Heroku to deploy, have you not deployed yet or do I need to refresh my client-side resources?

Made a little mistake, sorry, should be deployed in 10 seconds.
Ha, no need to apologise! The fix works great.
I think you should weight the number of stars per repo higher. I think I am winning on number of repos and number of gists, but I think the user I'm battling beat me. Quality > Quantity.
Thanks for this. I ran into a lucky coincidence: my GitHub account is exactly 1000 days old. It's surprising that I've been using GitHub for almost 10% of my life. (I'm 10,095 days old, so it'll be exactly 10% the week after next.)
Well, this makes my devops decisions no easier as it's pretty much a dead heat:

http://www.gitbattle.com/?u1=puppetlabs&u2=opscode

(incidentally, there appears to be a UI bug where it lists some repos multiple times - at the end the list looked like puppet/chef/puppet/chef/puppet/chef )

I've been thinking about a similar hack for awhile, but my idea was to measure/compare code cleanliness (in the agile sense of the word) and expressiveness between two chunks of code written by two different developers, in the same programming language and with the same number of SLOC.

I believe something like this to be a much more reliable metric of code quality than commits per day and what have you.

If someone else has already done this, I'd be fascinated to take a look at how you measure those things. The problem would require a non-trivial amount of AI.

Neat! It'd be really cool to see the top-scorer in an organization. Trying to compute the score of tobytripp (a coworker) leaves me at the secret of life with both "Error in event handler for 'undefined': Cannot read property 'qrstr' of undefined TypeError: Cannot read property 'qrstr' of undefined " and "Uncaught SyntaxError: Unexpected token ILLEGAL" in my console.
Any idea what line numbers those came on? I'll try and fix it!
The event_handler is in event_bindings:369, and the unexpected token is in line 711 of the api response, apparently? bit.ly/Tt9exN