Skip to content

Instantly share code, notes, and snippets.

Avatar
🙃
g7tri77k4pp4

James keppy

🙃
g7tri77k4pp4
  • USA
View GitHub Profile
@keppy
keppy / kpoker
Created May 29, 2012
poker game initialization
View kpoker
def initialize(numhands, n = 5, deck = [r+s for r in '23456789TJQKA' for s in 'SHDC'])
deck.shuffle
i = 0
numhands.times do (n*i).upto(n*(i+1)) {|x|... }
end
end
View gist:2831329
def initialize(hands, cards)
ranks = %w{ 2 3 4 5 6 7 8 9 T J Q K A }
suits = %w{ S H D C }
card_stack = Array.new
h = Array.new
suits.each {|suit|
ranks.size.times {|i|
card_stack << (ranks[i]+suit)
}
}
View gist:2831339
class PokerGame
include Enumerable
include Comparable
attr_reader :hand
def initialize(hands, cards)
ranks = %w{ 2 3 4 5 6 7 8 9 T J Q K A }
suits = %w{ S H D C }
card_stack = Array.new
h = Array.new
View gist:2835207
class PokerGame
include Enumerable
include Comparable
attr_reader :hand
def initialize(hands, cards)
ranks = %w{ 2 3 4 5 6 7 8 9 T J Q K A }
suits = %w{ S H D C }
card_stack = Array.new
num_hands = Array.new
@keppy
keppy / gist:3012287
Created Jun 28, 2012
Modeling a debate app
View gist:3012287
def User
has_many :propositions, :as => :debateable
has_many :oppositions, :as => :debateable
end
def Proposition
belongs_to :debateable, :polymorphic => :true
has_one :opposition, :as => :debateable
end
View gist:3042484
require 'spec_helper'
describe Debate do
#let(:prop_user) { FactoryGirl.create(:user) }
#let(:opp_user) { FactoryGirl.create(:user) }
before do
@prop_user = User.new(name: "Prop User", email: "prop@email.com")
@opp_user = User.new(name: "Opp User", email: "opp@email.com")
@debate = Debate.new(title: "Test Debate")
@keppy
keppy / gist:3133180
Created Jul 18, 2012
Problem with routes
View gist:3133180
routes.rb
----------
Debateable::Application.routes.draw do
resources :users do
resources :posts
end
resources :topics do
resources :posts
View employee_test.rb
require "minitest_helper"
class EmployeeTest < MiniTest::Unit::TestCase
def setup
super
@employee = Employee.new(first_name: "Jannis", last_name: "Steele")
@user = User.new(login: "Geoblaster", password: "foobar", password_confirmation: "foobar", email: "hero@mcpooch.com")
@employee.user = @user
end
@keppy
keppy / application trace
Created Sep 1, 2012
TypeError in InvoicesController#show_client_invoices
View application trace
app/controllers/invoices_controller.rb:3:in `[]'
app/controllers/invoices_controller.rb:3:in `show_client_invoices'
@keppy
keppy / _client_reservations.html.erb
Created Sep 3, 2012
Ajax call not displaying dynamic content--@invoice_reservations--the partial is rendered though.
View _client_reservations.html.erb
<table class="table table-bordered table-striped">
<%= @invoice_reservations.each do |r| %>
<tr>
<td><%= r.name %></td>
</tr>
</table>