Skip to content

Instantly share code, notes, and snippets.

require 'uri'
require 'net/http'
require 'openssl'
require 'json'
require 'byebug'
class WyreApi
ACCOUNT_ID = '**-*************'
API_KEY = '****-****-****-****'
SEC_KEY = '****-****-****-****'
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'
)
def game_intro
puts "The Dark Knight Returns"
end
def bats
puts " 🦇 " * 20
end
def new_line
puts ""
@aguayma
aguayma / ticker_on_localhost
Created January 28, 2015 20:06
ticker_on_localhost
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
voter_arr = []
politician_arr = []
class Hummus
def initialize(name,party)
@name = name
@party = party
end
end
@aguayma
aguayma / quadV2
Created January 21, 2015 23:20
Help me Jesus
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
@aguayma
aguayma / fizzbuzz
Created January 19, 2015 16:08
Syntax
(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
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
@aguayma
aguayma / mad_max
Created January 16, 2015 14:54
Mad_max
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
@aguayma
aguayma / 2_2
Created January 15, 2015 22:57
Hey you can't do that here
# 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