This file contains 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 'ruby2d' | |
GRID_SIZE = 40 | |
# Set the window size | |
set width: GRID_SIZE * 12 | |
set height: GRID_SIZE * 9 | |
# Create a new shape | |
frogger = Square.new( |
This file contains 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 'ruby2d' | |
GRID_SIZE = 80 | |
set width: GRID_SIZE * 12 | |
set height: GRID_SIZE * 9 | |
frogger = Square.new(size: GRID_SIZE, color: 'olive', y: Window.height - GRID_SIZE, x: GRID_SIZE * 4) | |
trucks = []; boats = []; motorbikes = []; bicycles = [] | |
game_state = :in_progress |
This file contains 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 Game | |
attr_reader :player_one, :player_two, :board_one | |
def initialize(name_one, name_two) | |
@player_one = Player.new(name_one) | |
@player_two = Player.new(name_two) | |
@board_one = Board.new | |
end | |
end |
This file contains 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 Ruby23OpenStructPatched | |
# :nodoc: | |
class << self | |
alias allocate new | |
end | |
# | |
# Creates a new OpenStruct object. By default, the resulting OpenStruct | |
# object will have no attributes. | |
# |
This file contains 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
#!/usr/bin/env sh | |
website="http://studio.envato.com" | |
while [ 1 ] | |
do | |
time=$(curl -s -I $website | Grep Runtime | awk '{ print $2}') | |
printf "\rApp response: %.0fms " $(echo "$time * 1000" | tr -d $'\r' | bc) | |
sleep 0.25 | |
done |
This file contains 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
model = User # For the test we just need any active record model that has a created_at timestamp. | |
puts %{ | |
========================== | |
Bug present?: #{model.where('created_at > ?', model.last.created_at).any?} | |
Ruby: #{RUBY_DESCRIPTION} | |
Raw SQL: #{ActiveRecord::Base.connection.execute(model.where('created_at > ?', Time.at(model.last.created_at.to_i)).to_sql).to_a.first['created_at']} | |
AR Timestamp: #{model.last.created_at.to_f} | |
Rails: #{Rails.version} |
This file contains 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
-- Rails doesn't actually store timestamps in the database as UTC, it actually | |
-- stores them without any timezone information in the database (but in UTC | |
-- time). Which means that to convert a timestamp to another timezone we | |
-- first need to cast the timestamp to a timestamp that's in UTC and then | |
-- convert to the timezone we actually want. Melbourne in this case. | |
SELECT | |
TO_CHAR(((created_at AT TIME ZONE 'UTC') AT TIME ZONE 'Australia/Melbourne')::date, 'YYYY-MM-DD') AS "Day", | |
FROM jobs | |
GROUP BY "Day"; |
This file contains 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
Testing http://www.microlancer.com/ | |
At Mon May 20 17:52:07 2013 | |
10 loops | |
Fastest Median Slowest Std Dev | |
--------------------------------------------------------------------------- | |
Server performance: | |
Total application time 71ms 115ms 482ms 121ms | |
Host latency: |
This file contains 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
t = Thread.new do | |
pid = fork { raise 'nope' } | |
Process.waitpid(pid) | |
end | |
t.join |
This file contains 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
mario:~/Work/microlancer (master) $ heroku --version | |
heroku-toolbelt/2.36.1 (x86_64-darwin12.2.0) ruby/2.0.0 | |
mario:~/Work/microlancer (master) $ gem list | grep heroku | |
heroku-api (0.3.9) | |
# Login says it was successful but then I cannot run commands | |
mario:~/Work/microlancer (master) $ heroku login | |
Authentication successful. |
NewerOlder