Skip to content

Instantly share code, notes, and snippets.

@visibilityspots
Last active August 29, 2015 14:01
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 visibilityspots/cb1a95fdb16ef662842a to your computer and use it in GitHub Desktop.
Save visibilityspots/cb1a95fdb16ef662842a to your computer and use it in GitHub Desktop.
Foursquare checked in people widget for dashing using the rubygem foursquare2

Foursquare widget

The sandwich bar I buy my lunch is in the center of Ghent. Where a lot of students 'study' and need some lunch too. Because I don't want to lose time waiting in a queue I had the wonderful idea of setting up a dashing widget which show me how many people checked in on foursquare in this popular venue.

I started writing a dashing job using the foursquare ruby wrapper of Matt Mueller (https://github.com/mattmueller/foursquare2).

screenshot

In your dashing root directory you have to add this gem into the Gemfile.

gem 'foursquare2'

And install this new gem using

$ bundle install

Once that's done you copy the foursquare.rb file into the dashingRootDir/jobs/ directory and complete the script using those parameters.

_api_client_id = ''
_api_client_secret = ''
_venue_id = '4c73902d57b6a1435a69c8cc'

The api credentials you can get from https://foursquare.com/developers/apps where you have to register a new app. The venue id on the other hand you can strip off from the url of the venue.

example: https://foursquare.com/v/97/4c73902d57b6a1435a69c8cc the venue_id would be '4c73902d57b6a1435a69c8cc'

In your dashboard file dashingRootDir/dashboards/####.erb you can use this html code to show the total of checked in people at your venue on your dashing dashboard:

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
  <div data-id="foursquare_checkins_people" data-view="Number" data-title="People checked in @YOURVENUENAME" style="background-color: #80c02d"></div>
</li>

No more waiting queues for you ;)

<li data-row="1" data-col="2" data-sizex="1" data-sizey="1">
<div data-id="foursquare_checkins_people" data-view="Number" data-title="Foursquare" style="background-color: #105010"></div>
<i class="icon-globe icon-background"></i>
</li>
#!/usr/bin/env ruby
require 'foursquare2'
_api_client_id = ''
_api_client_secret = ''
_api_version = 20140225
_venue_id = ''
SCHEDULER.every '10m', :first_in => 0 do |job|
venue = Foursquare2::Client.new(:client_id => _api_client_id, :client_secret => _api_client_secret, :api_version => _api_version)
venue_checkins = venue.herenow(_venue_id)
send_event('foursquare_checkins_people', current: venue_checkins['hereNow']['count'])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment