Skip to content

Instantly share code, notes, and snippets.

View Haumer's full-sized avatar
🎯
Focusing

Alex Haumer Haumer

🎯
Focusing
  • London
View GitHub Profile
require 'open-uri'
require 'nokogiri'
puts "what would you like to look for?"
keyword = gets.chomp
url = "https://www.etsy.com/uk/search?q=#{keyword}"
html_file = URI.open(url).read
html_doc = Nokogiri::HTML(html_file)
require 'date'
require 'yaml'
# 1) define a method #french_ssn_info
def french_ssn_info(ssn_number)
# 2) write regex to match
# gender (first digit) => 1 male 2 female
# year (next 2 digits)
# month (next 2 digits)
# department (next 2 digits)
puts "----------------------------------------"
puts "-----Welcome to The Price is Right!-----"
puts "----------------------------------------"
# 1) make a method
# 2) computer has to pick a random number (save it to a variable)
# 3) prompt the user to also pick/guess a number (save it to a variable)
def price_is_right
require "date"
# STRING => needs quotes
"london"
""
age = 29
name = "Alex"
# puts "#{name} is #{age}" # string interpolation
# puts '#{name} is #{age}'
require "open-uri"
require "json"
ENDPOINT = "https://api.tfl.gov.uk/line/mode/tube,overground,dlr,tflrail/status"
json_data = open(ENDPOINT).read
JSON.parse(json_data).each do |line|
name = line["name"]
status = line["lineStatuses"].first["statusSeverityDescription"]
puts "#{status} on the #{name}"

simple_form_array_input.rb

class ArrayInput < SimpleForm::Inputs::StringInput
  def input
    input_html_options[:type] ||= input_type

    existing_values = Array(object.public_send(attribute_name)).map do |element|
      @builder.text_field(nil, input_html_options.merge(value: element, name: "#{object_name}[#{attribute_name}][]"))
    end
require 'csv'
# 1. Greet/Welcome the user to the Christmas List program!
puts "(¯`·._(¯`·._(¯`·._(¯`·._(¯`·.__.·¯) _.·¯)_.·¯)_.·¯)_.·¯)"
puts "(¯`·._(¯`·._ Welcome to the Christmas List! _.·¯)_.·¯)"
puts "(¯`·._(¯`·._(¯`·._(¯`·._(¯`·.__.·¯) _.·¯)_.·¯)_.·¯)_.·¯)"
options = [
"list",
"add",
"delete",
puts "----------------------------------------"
puts "-----Welcome to The Price is Right!-----"
puts "----------------------------------------"
puts "Guess the price of this wonderful imaginary product"
# computer picks a random number (generate random number)
computer_number = rand(1..100)
# ask the user to enter a number => gets.chomp
require "date"
def greetings(name)
"Welcome to London #{name}! I hope you enjoy it!"
end
# puts greetings("James")
# puts greetings("Nathan")
# def one_plus_one
require "date"
def greetings(name)
"Welcome to London #{name}! I hope you enjoy it!"
end
# puts greetings("James")
# puts greetings("Nathan")
# def one_plus_one