summaryrefslogtreecommitdiff
path: root/templates/project/jobs
diff options
context:
space:
mode:
Diffstat (limited to 'templates/project/jobs')
-rw-r--r--templates/project/jobs/buzzwords.rb9
-rw-r--r--templates/project/jobs/convergence.rb14
-rw-r--r--templates/project/jobs/sample.rb13
-rw-r--r--templates/project/jobs/twitter.rb28
4 files changed, 64 insertions, 0 deletions
diff --git a/templates/project/jobs/buzzwords.rb b/templates/project/jobs/buzzwords.rb
new file mode 100644
index 0000000..7974dd9
--- /dev/null
+++ b/templates/project/jobs/buzzwords.rb
@@ -0,0 +1,9 @@
+buzzwords = ['Paradigm shift', 'Leverage', 'Pivoting', 'Turn-key', 'Streamlininess', 'Exit strategy', 'Synergy', 'Enterprise', 'Web 2.0']
+buzzword_counts = Hash.new({ value: 0 })
+
+SCHEDULER.every '2s' do
+ random_buzzword = buzzwords.sample
+ buzzword_counts[random_buzzword] = { label: random_buzzword, value: (buzzword_counts[random_buzzword][:value] + 1) % 30 }
+
+ send_event('buzzwords', { items: buzzword_counts.values })
+end
diff --git a/templates/project/jobs/convergence.rb b/templates/project/jobs/convergence.rb
new file mode 100644
index 0000000..1da2a5b
--- /dev/null
+++ b/templates/project/jobs/convergence.rb
@@ -0,0 +1,14 @@
+# Populate the graph with some random points
+points = []
+(1..10).each do |i|
+ points << { x: i, y: rand(50) }
+end
+last_x = points.last[:x]
+
+SCHEDULER.every '2s' do
+ points.shift
+ last_x += 1
+ points << { x: last_x, y: rand(50) }
+
+ send_event('convergence', points: points)
+end \ No newline at end of file
diff --git a/templates/project/jobs/sample.rb b/templates/project/jobs/sample.rb
new file mode 100644
index 0000000..1fe008d
--- /dev/null
+++ b/templates/project/jobs/sample.rb
@@ -0,0 +1,13 @@
+current_valuation = 0
+current_karma = 0
+
+SCHEDULER.every '2s' do
+ last_valuation = current_valuation
+ last_karma = current_karma
+ current_valuation = rand(100)
+ current_karma = rand(200000)
+
+ send_event('valuation', { current: current_valuation, last: last_valuation })
+ send_event('karma', { current: current_karma, last: last_karma })
+ send_event('synergy', { value: rand(100) })
+end \ No newline at end of file
diff --git a/templates/project/jobs/twitter.rb b/templates/project/jobs/twitter.rb
new file mode 100644
index 0000000..7b2bd6f
--- /dev/null
+++ b/templates/project/jobs/twitter.rb
@@ -0,0 +1,28 @@
+require 'twitter'
+
+
+#### Get your twitter keys & secrets:
+#### https://dev.twitter.com/docs/auth/tokens-devtwittercom
+twitter = Twitter::REST::Client.new do |config|
+ config.consumer_key = 'YOUR_CONSUMER_KEY'
+ config.consumer_secret = 'YOUR_CONSUMER_SECRET'
+ config.access_token = 'YOUR_OAUTH_TOKEN'
+ config.access_token_secret = 'YOUR_OAUTH_SECRET'
+end
+
+search_term = URI::encode('#todayilearned')
+
+SCHEDULER.every '10m', :first_in => 0 do |job|
+ begin
+ tweets = twitter.search("#{search_term}")
+
+ if tweets
+ tweets = tweets.map do |tweet|
+ { name: tweet.user.name, body: tweet.text, avatar: tweet.user.profile_image_url_https }
+ end
+ send_event('twitter_mentions', comments: tweets)
+ end
+ rescue Twitter::Error
+ puts "\e[33mFor the twitter widget to work, you need to put in your twitter API keys in the jobs/twitter.rb file.\e[0m"
+ end
+end \ No newline at end of file