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
<?xml version="1.0" encoding="UTF-8"?> | |
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> | |
<CORSRule> | |
<AllowedOrigin>https://www.desktoppr.co</AllowedOrigin> | |
<AllowedMethod>GET</AllowedMethod> | |
<MaxAgeSeconds>315576000</MaxAgeSeconds> | |
<AllowedHeader>*</AllowedHeader> | |
</CORSRule> | |
</CORSConfiguration> |
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
#!/bin/sh | |
# | |
# This shell script passes all its arguments to the binary inside the | |
# MacVim.app application bundle. If you make links to this script as view, | |
# gvim, etc., then it will peek at the name used to call it and set options | |
# appropriately. | |
# | |
# Based on a script by Wout Mertens and suggestions from Laurent Bihanic. This | |
# version is the fault of Benji Fisher, 16 May 2005 (with modifications by Nico | |
# Weber and Bjorn Winckler, Aug 13 2007). |
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
#!/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
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
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
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"; |
NewerOlder