This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'uri' | |
require 'net/http' | |
require 'openssl' | |
require 'json' | |
require 'byebug' | |
class WyreApi | |
ACCOUNT_ID = '**-*************' | |
API_KEY = '****-****-****-****' | |
SEC_KEY = '****-****-****-****' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gateway = ActiveMerchant::Billing::PsigateGateway.new(login: ENV['STORE_ID'],password: ENV['STORE_PWD']) | |
credit_card = ActiveMerchant::Billing::CreditCard.new( | |
first_name: 'John', | |
last_name: 'Doe', | |
number: '4111111111111111', | |
month: '12', year: '2019', | |
verification_value: '123' | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def game_intro | |
puts "The Dark Knight Returns" | |
end | |
def bats | |
puts " 🦇 " * 20 | |
end | |
def new_line | |
puts "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'httparty' | |
require 'json' | |
require 'nokogiri' | |
get '/' do | |
response = HTTParty.get('http://finance.yahoo.com/q?s=AAPL') | |
dom = Nokogiri::HTML(response.body) | |
span = dom.xpath("//span[@id='yfs_l84_aapl']").first | |
price = span.content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
voter_arr = [] | |
politician_arr = [] | |
class Hummus | |
def initialize(name,party) | |
@name = name | |
@party = party | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Quadrilateral | |
attr_accessor :top, :bottom, :left, :right | |
def initialize(left, top, right, bottom) | |
@left = left | |
@top = top | |
@right = right | |
@bottom = bottom | |
end | |
#gets the perimeter of the quads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(1..100).each do |n| | |
case | |
when (n % 3 == 0) && (n % 5 == 0) | |
puts "FIZZBUZZ" | |
when n % 3 == 0 | |
puts "Fizz" | |
when n % 5 == 0 | |
puts "Buzz" | |
else | |
puts n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mad_max(a,b, *rest) | |
if (a.is_a? Numeric) && (b.is_a? Numeric) | |
puts [a,b].max | |
else | |
puts "Please put a valid number" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mad_max(a,b) | |
if (a.is_a? Fixnum) && (b.is_a? Fixnum) | |
puts [a,b].max | |
else | |
if a||b == String | |
puts "Please put a valid number" | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add 2 to the number. | |
def add_two(number) | |
if number.respond_to? :+ | |
if number.respond_to? :push | |
number.push 2 | |
elsif number.respond_to? :squeeze | |
puts "Please enter a valid number!" | |
else | |
number + 2 | |
end |
NewerOlder