Skip to content

Instantly share code, notes, and snippets.

@wildekek
Last active December 8, 2017 15:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wildekek/f38f6184c9f82fefb200 to your computer and use it in GitHub Desktop.
Save wildekek/f38f6184c9f82fefb200 to your computer and use it in GitHub Desktop.
Memegenerator dashing job
require 'net/http'
require 'json'
#Id of the widget
id = "businesscat"
#What meme to show
meme = "Business-Cat"
#The Memegenerator API
server = "http://version1.api.memegenerator.net"
SCHEDULER.every '5m', :first_in => 0 do |job|
#The uri getting the instances of the meme that have been popular the last 7 days
uri = URI("#{server}/Instances_Select_ByPopular?languageCode=en&pageIndex=0&pageSize=12&urlName=#{meme}&days=30")
res = Net::HTTP.get(uri)
#Marshal the json into an object
j = JSON.parse(res)
#We want a random result
instances = j["result"].shuffle
imageUrl = instances[0]["instanceImageUrl"]
#Send the meme to the image widget
send_event(id, { image: "#{imageUrl}" })
end
@hdev-moliver
Copy link

Looks like Memegenerator.net is down..not sure if it will come back up. But quick question on integrating this with BigImage...

Can you confirm the correct code to place in the dashboard.erb file is:

  <div data-id="businesscat" data-view="BigImage" </div>

@Skeyelab
Copy link

Skeyelab commented Dec 8, 2017

This does still work, but you will need an API key: https://memegenerator.net/api

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