Rails Template:
rails new \
--database postgresql \
--webpack \
-m https://raw.githubusercontent.com/lewagon/rails-templates/master/devise.rb \| Hello World! | |
| I am a Gist! | |
| You can find me on GitHub or | |
| share and showcase me right here on HubGist |
| 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:) |
| 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"}> |
gem install gist
Please log in with gist --login. (GitHub now requires credentials to gist https://bit.ly/2GBBxKw)
gist --login
https://github.com/login/device
Success! https://github.com/settings/connections/applications/4f7ec0d4eab38e74384e
| 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 |