Skip to content

Instantly share code, notes, and snippets.

def generate_cards
@cards = []
FACES.each do |face|
SUITS.each do |suit|
@cards << Card.new(face,suit)
end
end
end
class RankedHand
attr_reader :category, :cards, :score, :description
RANKINGS = { royal_flush: "19", straight_flush: "18", four_of_a_kind: "17",
full_house: "16", flush: "15", straight: "14", three_of_a_kind: "13",
two_pair: "12", pair: "11", high_card: "10"
} #for scoring purposes, it's necessary that these ranking values be 2 chars long
DESCRIPTIONS = { royal_flush: "Royal Flush", straight_flush: "Straight Flush",
four_of_a_kind: "Four of a Kind", full_house: "Full House",
before_save :adjust_parts_qty
before_destroy :adjust_parts_qty
private
def adjust_parts_qty
old_quantity = quantity_was || 0
new_quantity = marked_for_destruction? ? 0 : quantity
part.quantity += new_quantity - old_quantity
part.save!
$(document).on "change", ".paid_checkbox", ->
url = $(this).data('paid-url')
if $(this).is(":checked")
box = confirm "Are you sure you want to mark as paid?"
if box is true
$.get url, { paid: "1"}
else
$(this).prop "checked", false
else
box = confirm "Are you sure you want to mark as unpaid?"
class Course < ActiveRecord::Base
has_many :registrations, class_name: "CourseRegistration"
def seats_available
class_size - registrations.length
end
end
- if object.errors.any?
.alert.alert-danger.fade.in
%a.close{"data-dismiss" => 'alert'} &#215;
%ul
- object.errors.each do |attr, msg|
- if msg.first == "^"
= content_tag :li, msg[1..-1] if msg.is_a? String
- else
= content_tag :li, "#{object.class.human_attribute_name(attr)} #{msg}" if msg.is_a? String
validates :last_name,
uniqueness: {
scope: [:first_name, :course_id, :user_id],
case_sensitive: false,
message: "This student has already been registered."
}
<VirtualHost *:80>
ServerAdmin info@luckyruby.com
ServerName luckyruby.com
ServerAlias www.luckyruby.com
DocumentRoot /var/www/luckyruby
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
def overlap?(range1_start, range1_end, range2_start, range2_end)
if (range1_start > range2_end || range1_end < range2_start)
false
else
true
end
end
def account_id_32(getRequest)
players_list(getRequest).map do |x|
{ id: x["account_id"],
hero_id: x["hero_id"],
player_slot: x["player_slot"]
}
end
end