Skip to content

Instantly share code, notes, and snippets.

@joren
Last active December 17, 2015 01:09
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 joren/5525808 to your computer and use it in GitHub Desktop.
Save joren/5525808 to your computer and use it in GitHub Desktop.

Description

Simple Dashing widget that show the amount of participants for a Fikket event.

The widget was made by @joren for use @openminds. If you end up using this widget, please send me a tweet! I'd love to hear about it.

Dependencies

This widget requires the curb gem for easy curl request in Ruby and your Fikket API key.

Usage

This widgets uses the number-widget, so no need to create a new one. You can add as much events as you want in the config file. Add the name, slug of id and api key of your event in config/fikket.yml file. Name your number widget with 'fikket_eventname' to match it with this job.

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
  <div data-id="fikket_eventname" data-view="Number" data-title="Total participants"></div>
</li>

And that is all.

Contributing

Have tips on making this better? Please leave a comment and/or fork the gist. Sending me a tweet on Twitter is probably a good idea as well!

require 'json'
require 'curb'
begin
fikket_config = YAML.load_file("config/fikket.yml")
events = fikket_config['events']
events.each do |name, event|
SCHEDULER.every '1m', :first_in => 0 do |job|
participants = JSON.parse(Curl.get("http://fikket.com/api/events/#{event['id']}/participants.json?api_key=#{event['api_key']}").body_str)
send_event("fikket_#{name}", { current: participants.size })
end
end
rescue Errno::ENOENT
puts "No config file found for fikket - not starting the Fikket job"
end
events:
name_of_event:
id: id_or_event_slug
api_key: very_secret_api_key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment