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 count | |
| n = 1 | |
| while(n < 10) | |
| n = n + 1 | |
| 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
| 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) |
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
| development: | |
| adapter: postgresql | |
| encoding: unicode | |
| database: splurty-dev | |
| pool: 5 | |
| host: localhost | |
| username: action | |
| password: | |
| test: |
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
| 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 |
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
| 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" |
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
| 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| |
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
| 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 |
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
| @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 |
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
| test 'White set for starting move' do | |
| game = create(:game) | |
| start = game.player_turn | |
| assert_equal 'white', start | |
| 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
| Places | |
| ------ | |
| id | |
| Comments |