Skip to content

Instantly share code, notes, and snippets.

@mathias
Last active December 27, 2015 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mathias/7293278 to your computer and use it in GitHub Desktop.
Save mathias/7293278 to your computer and use it in GitHub Desktop.

Description

This is a simple job for a Number widget to display your team's Coderwall rank. (As seen on https://coderwall.com/leaderboard )

Be sure to set the CODERWALL_TEAM variable with the name of your team as it appears in the URL for your team.

Since the Coderwall rank only seems to change daily, I recommend bumping up the scheduler to only request the JSON as infrequently as you can stand. The Coderwall API is free and doesn't require authentication, and I'd like it if it stayed that way versus them requiring OAuth or some other mechanism to ensure people aren't killing their API.

Insert something like this into your Dashboard:

    <li data-row="2" data-col="1" data-sizex="1" data-sizey="1">
      <div data-id="coderwall" data-view="Number" style="background-color:#2A76C6;"></div>
    </li>
require 'net/http'
require 'json'
SCHEDULER.every '30m', :first_in => '5s' do |job|
uri = URI.parse("https://coderwall.com/team/#{ENV['CODERWALL_TEAM']}.json")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
status = JSON.parse(response.body)
name = status['name']
rank = status['rank']
team_size = status['size']
moreinfo = name + ", currently at " + team_size.to_s + " members. (Lower is better.)"
send_event("coderwall", {title: "Coderwall Rank", current: rank, moreinfo: moreinfo})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment