Skip to content

Instantly share code, notes, and snippets.

View kenmazaika's full-sized avatar

ken mazaika kenmazaika

View GitHub Profile
def count
n = 1
while(n < 10)
n = n + 1
end
end
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.0.1)
actionpack (= 4.0.1)
mail (~> 2.5.4)
actionpack (4.0.1)
activesupport (= 4.0.1)
builder (~> 3.1.0)
erubis (~> 2.7.0)
development:
adapter: postgresql
encoding: unicode
database: splurty-dev
pool: 5
host: localhost
username: action
password:
test:
g = Game.last
g.expects(:check?).returns(true)
# make sure you can't move into check
g = Game.last
g.expects(:check?).returns(false)
# make sure it's allowed
module ObjectTracker
module ClassMethods
def track_method(method_name)
alias_method :"#{method_name}_without_tracking", method_name
define_method :"#{method_name}_with_tracking" do |*splat|
params = self.class.instance_method(:"#{method_name}_without_tracking").parameters.collect(&:last)
self.send(:"#{method_name}_without_tracking", *splat) # do method first
self.track_event!(method_name, Hash[*(params.zip(splat).flatten)]) # then track
end
alias_method method_name, :"#{method_name}_with_tracking"
require 'rubygems'
require 'httparty'
resp = HTTParty.get("http://www.catfact.info/api/v1/facts.json", :query => {:page=>2, :per_page=>3})
puts resp.inspect
puts resp.code
puts "-----"
resp['facts'].each do |f|
x = loc[1]
y = loc[0]
@image[y][x+1]=1 if x<(@image[y].length-1)
@image[y][x-1]=1 if x>0
@image[y+1][x]=1 if y<(@image.length-1)
@image[y-1][x]=1 if y>0
@image[loc[0]][loc[1]+1]=1 if loc[1]<(@image[loc[0]].length-1)
@image[loc[0]][loc[1]-1]=1 if loc[1]>0
@image[loc[0]+1][loc[1]]=1 if loc[0]<(@image.length-1)
@image[loc[0]-1][loc[1]]=1 if loc[0]>0
test 'White set for starting move' do
game = create(:game)
start = game.player_turn
assert_equal 'white', start
end
Places
------
id
Comments