Skip to content

Instantly share code, notes, and snippets.

Avatar

Aidan rudkovskyi

View GitHub Profile
View complimentator.rb
require 'twitter'
# Bot implementation
class Complimentator
# Module that holds all commands
module Command
def compliment(tweet)
update(tweet, @compliments.sample)
end
View largest_series_product.py
def largest_product(num_string, series):
if series == 0:
return 1
end = series
products = []
for n in range(len(num_string)):
selection = num_string[n:end]
View request.rb
require 'net/http'
require 'uri'
module Requests
class Request
def initialize(url)
@uri = URI.parse(url)
@request = Net::HTTP::Get.new(@uri)
end
View wordpress.rb
require_relative 'request'
require 'json'
module Requests
class Wordpress
WEBSITE_URL = 'https://public-api.wordpress.com/rest/v1.1/sites/xxx/stats?http_envelope=1'.freeze
def initialize
super(WEBSITE_URL)
chrome!
View statistics.rb
SCHEDULER.every '30s' do
stats = Requests::Wordpress.new.stats
send_event(
'page_views',
current: stats['visitors_today'],
last: stats['visitors_yesterday']
)
end
View index.erb
<% content_for :title do %>My dashboard<% end %>
<div class="gridster">
<ul>
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="page_views" data-view="Number" data-title="Page views" style="background-color: #ec663c" data-moreinfo="Today's page views"></div>
</li>
</ul>
</div>
View github.rb
require_relative 'request'
require 'nokogiri'
module Requests
class Github < Request
def initialize(url)
super(url)
chrome!
end
View statistics_final.rb
SCHEDULER.every '5s' do
stats = Requests::Wordpress.new.stats
send_event(
'page_views',
current: stats['visitors_today'],
last: stats['visitors_yesterday']
)
stars = Requests::Github.new('https://github.com/sparklemotion/nokogiri').stars_count
send_event('stars_count', current: stars)
View client_create_tweet.rb
client.search("to:justinbieber marry me", result_type: "recent").take(3).each do |tweet|
puts tweet.text
end
View twitter_client_get_recent_tweets.rb
def popularity(string)
tweets = @client.search(string, result_type: 'recent').take(1_000)
tweets.length / (tweets.first.created_at - tweets.last.created_at) * 60
end
You can’t perform that action at this time.