Skip to content

Instantly share code, notes, and snippets.

Avatar

Aidan Rudkovskyi rudkovskyi

View GitHub Profile
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 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 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 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 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 complimentator.rb
require 'twitter'
# Bot implementation
class Complimentator
# Module that holds all commands
module Command
def compliment(tweet)
update(tweet, @compliments.sample)
end
View bingy.rb
require 'open-uri'
class Bingy
LANDING_PAGE = 'http://www.bing.com/translator'.freeze
SPEAK_URL = LANDING_PAGE + '/api/language/Speak?locale=en-US&media=audio/mp3'
def initialize(text, gender = 'male')
@user_agent = 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36'
@params = { text: text, gender: gender }
end
View download_ny_photos_step_2.rb
# Adding RMagick to combine images
require 'open-uri'
require 'uri'
require 'rmagick'
class PhotoDownloader
RESOURCE = 'http://access.nypl.org/image.php/'
def initialize(id, zoom, dimension)
View downloads_ny_photos_step_1.rb
# First quick draft
require 'open-uri'
require 'uri'
class PhotoDownloader
RESOURCE = 'http://access.nypl.org/image.php/'
def initialize(id, dimension)
@id = id
View download_ny_photos_final.rb
# https://theoryofe.co/2016/10/17/reverse-engineering-by-using-chrome/
require 'open-uri'
require 'uri'
require 'rmagick'
class PhotoDownloader
RESOURCE = 'http://access.nypl.org/image.php/'.freeze
def initialize(id, zoom)
You can’t perform that action at this time.