This file contains hidden or 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 generate_cards | |
@cards = [] | |
FACES.each do |face| | |
SUITS.each do |suit| | |
@cards << Card.new(face,suit) | |
end | |
end | |
end |
This file contains hidden or 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 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", |
This file contains hidden or 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
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! |
This file contains hidden or 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
$(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?" |
This file contains hidden or 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 Course < ActiveRecord::Base | |
has_many :registrations, class_name: "CourseRegistration" | |
def seats_available | |
class_size - registrations.length | |
end | |
end |
This file contains hidden or 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
- if object.errors.any? | |
.alert.alert-danger.fade.in | |
%a.close{"data-dismiss" => 'alert'} × | |
%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 |
This file contains hidden or 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
validates :last_name, | |
uniqueness: { | |
scope: [:first_name, :course_id, :user_id], | |
case_sensitive: false, | |
message: "This student has already been registered." | |
} |
This file contains hidden or 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
<VirtualHost *:80> | |
ServerAdmin [email protected] | |
ServerName luckyruby.com | |
ServerAlias www.luckyruby.com | |
DocumentRoot /var/www/luckyruby | |
<Directory /> | |
Options FollowSymLinks | |
AllowOverride None | |
</Directory> |
This file contains hidden or 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
./configure --enable-libfdk-aac --enable-libaacplus --enable-libvo-aacenc --enable-libschroedinger --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-stripping --enable-nonfree --enable-version3 --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin" --enable-gpl --enable-libx264 |
This file contains hidden or 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 Roulette | |
def initialize(bankroll, min_bet, max_bet) | |
@wheel = "0-28-9-26-30-11-7-20-32-17-5-22-34-15-3-24-36-13-1-00-27-10-25-29-12-8-19-31-18-6-21-33-16-4-23-35-14-2".split("-").map(&:to_i) | |
@max_index = @wheel.length - 1 | |
@bankroll, @min_bet, @max_bet = bankroll, min_bet, max_bet | |
@bet_size = @min_bet | |
@results = [] | |
end | |
def spin_the_wheel |
NewerOlder