Skip to content

Instantly share code, notes, and snippets.

@assimovt
Last active June 19, 2016 19:16
Show Gist options
  • Save assimovt/5177583 to your computer and use it in GitHub Desktop.
Save assimovt/5177583 to your computer and use it in GitHub Desktop.
Adds "Daily wisdom about startups" images from http://startupquote.com to your dashboard.

Setup

Add the simple-rss Gem to your Gemfile:

gem 'simple-rss'

Update your bundle:

bundle

You need to update the image/image.html to support remote images. So, I have just updated it to the following, since I do not use the assets:

<img data-bind-src="image" data-bind-width="width"/>

Put the startup_quote.rb to jobs/startup_quote.rb.

Finally add the startup_quote.erb contents to your dashboard.

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="startup_quote"
data-view="Image"
data-title="Startup quote"
style="padding:0;vertical-align:bottom;background:transparent;">
</div>
</li>
require 'simple-rss'
require 'open-uri'
url = 'http://feeds.feedburner.com/StartupQuote?format=xml'
feed = SimpleRSS.parse open(url)
entries = feed.entries
SCHEDULER.every '1m', :first_in => 0 do
random_quote = entries.sample
if (src = random_quote.description.match(/img.*?src="(.*?)"/i)[1] rescue false)
send_event('startup_quote', {image: src})
end
end
@loveybot
Copy link

Yay Ruby!!

@pushmatrix
Copy link

Love it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment