Skip to content

Instantly share code, notes, and snippets.

class Deck
attr_reader :cards
RANKS = %w(2 3 4 5 6 7 8 9 T J Q K A)
SUITS = %w(s h c d)
def initialize
@cards = RANKS.product(SUITS).map {|r,s| {rank: RANKS.index(r)+2, suit: s, display: r+s}}
@cards.shuffle
end
def convert(card)
card.gsub('14','A').gsub('13','K').gsub('12','Q').gsub('11','J').gsub('10','T')
end
def flush?
hand = %w(Ts Qc 4c 3c Td Jc Ac)
suits = hand.map{|i| i[-1]}
counts = suits.each_with_object(Hash.new(0)) {|suit, counts| counts[suit] += 1}
counts.select {|k,v| v >= 5}.length != 0
end
def after_sign_in_path_for(resource)
if resource.is_a? Admin
admin_path
elsif resource.is_a? Manager
manager_path
else
root_path
end
end
<?xml version="1.0" encoding="UTF-8"?>
<OTA_VehResRQ>
<POS>
<Source>
<RequestorID ID="1234567"/>
</Source>
</POS>
<VehResRQCore>
<UniqueID ID="60a85676-e833-421b-8414-d1f5c5710caa:ECAR"/>
<Customer>
iata = request["POS"]["Source"]["RequestorID"]["@ID"] rescue nil
rate_key = request["VehResRQCore"]["UniqueID"]["@ID"] rescue nil
customer = request["VehResRQCore"]["Customer"]["Primary"] rescue nil
first_name = customer["PersonName"]["GivenName"] rescue nil
last_name = customer["PersonName"]["Surname"] rescue nil
email = customer["Email"] rescue nil
phone = customer["Telephone"] rescue nil
class RequestsController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :parse_xml
def ping
@response_tag = "OTA_PingRS"
rescue => e
log_error(e)
@error = e
render template: 'requests/error'
require 'direct_connect'
require 'builder'
task :ping do
xml = Builder::XmlMarkup.new(indent: 2)
xml.instruct!
xml.OTA_PingRQ {
xml.EchoData 'Hello World'
}
task :request do
puts "foo"
end
# Server
redis_version:2.8.7
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:56c319ad5166ef0b
redis_mode:standalone
os:Linux 3.2.0-23-generic x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.6.3