Skip to content

Instantly share code, notes, and snippets.

View Haumer's full-sized avatar
🎯
Focusing

Alex Haumer Haumer

🎯
Focusing
  • London
View GitHub Profile
Hello World!
I am a Gist!
You can find me on GitHub or
share and showcase me right here on HubGist
@Haumer
Haumer / B390_imdb.rb
Last active August 20, 2020 20:12
imdb api for Nextbinge
require 'uri'
require 'net/http'
require 'openssl'
require 'json'
class IMDB
attr_reader :data
BASE_URL = URI('https://imdb-internet-movie-database-unofficial.p.rapidapi.com/search/').freeze
def initialize(movie:)

OmniAuth in Rails

Rails Template:

rails new \
  --database postgresql \
  --webpack \
 -m https://raw.githubusercontent.com/lewagon/rails-templates/master/devise.rb \
require 'nokogiri'
require 'watir'
require_relative '../recipe'
class ScrapeBBCGoodFood
def self.call(keyword)
# Set up watir, wait until page contents that are needed are fully loaded
# Leave the below line as is if you don't want a browser window to open
browser = Watir::Browser.new :chrome, headless: true
# Comment in the below line, and comment out the above line if you want to see a browser window pop up
# browser = Watir::Browser.new
require 'set'
teamOne = "Billy, Frankie, Stevie, John"
teamTwo = "Billy, Frankie, Stevie, Zach"
teamOneSet = teamOne.split(', ').to_set
teamTwoSet = teamTwo.split(', ').to_set
teamOneSet ^ teamTwoSet # => #<Set: {"John", "Zach"}>
@Haumer
Haumer / gsub.rb
Created September 14, 2020 16:03
something.gsub(/src=(?<url>[^\s]+)/, 'src="" data-src=\k<url> class="lozad"')
# here \k<something> where something is the name of the group in your regex.
require_relative "task"
require_relative "view"
class Controller
def initialize(repository)
@repository = repository
@view = View.new
end
def add_task
class Patient
attr_accessor :room, :id
def initialize(attributes = {})
@id = attributes[:id]
@name = attributes[:name]
@cured = attributes[:cured] || false
end
end
class BaseRepo
def initialize(csv_file)
@csv_file = csv_file
@elements = []
@next_id = 1
load_csv if File.exist?(@csv_file)
end
def create(element)
element.id = @next_id