🏄♂️
- GitHub Staff
- rickwinfrey.com
- @rewinfrey.bsky.social
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
ActionMailer::Base.deliveries.first.html_part.decoded |
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
Changing order of inclusions breaks development mode, so did not changed it. | |
Development mode without assets precompiled works fine. | |
Development mode with assets precompiled broken. | |
Production mode (assets precompiled of course) works fine. | |
Commenting-out config.assets.debug = true in config/environments/development.rb fixes development mode when assets precompiled. | |
The last thing looks very strange. Some black magic definitely involved. |
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
Basic commands: | |
rvm gemset create <name> | |
rvm gemset list | |
rvm gemset use <name> | |
rvm gemset delete <name> | |
Global gemsets: | |
RVM provides @global gemset for each version of Ruby | |
Installing a gem to this gemset makes it available to all gemsets for that version of Ruby |
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
brew --version | |
should report 0.9.3 or greater | |
if you have a older version then update it: | |
brew update | |
now you can install gcc-4.2 and create a symbolink link to the correct dir | |
brew tap homebrew/dupes |
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 new myapp --skip-test-unit --database=postgresql | |
$> rvm gemset create myapp | |
$> rvm gemset use myapp | |
$> include 'rspec-rails' in Gemfile | |
$> bundle install |
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
def meth(a, b, c) | |
[c, b, a] | |
end | |
ary = [1, 2, 3] | |
meth(*ary) # => [3, 2, 1] | |
class Symbol | |
def to_proc2 | |
Proc.new { |element| element.send self } | |
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
Index: | |
1. should() #basic expectation | |
2. should_not() #basic negation of an expectation (RSpec does not support using !=) | |
3. include(item) #called on an enumerable object, this returns true or false if the object is found in the enumerable collection | |
4. respond_to(:message) #determines if a particular message (as a symbol) is defined for an object | |
5. raise_error(type, message) #checks if a particular error was raised, accepts zero, one or two parameters |
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
def minimax(max_player = true, ply = 0, alpha = -9999, beta = 9999) | |
# Return from recursive calls for the following escape conditions: | |
# 1. winning move found | |
# 2. resulting game tree ended in a draw | |
if board.winner? | |
# to differentiate between a win later in the game tree versus near the root, we + or - the ply from alpha or beta, | |
# depending on if the current move represents a win for the max player, or the min player, respectively. | |
return(max_player ? (-9999 + ply) : (9999 - ply)) |
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
def minimax(max_player = true, ply = 0, min_score = 1000, max_score = -1000) | |
if board.winner? | |
return(max_player ? (-1000 + ply) : (1000 - ply)) | |
elsif board.draw_game? | |
return 0 | |
end | |
best_move = 0 | |
available_moves.each do |index| |
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
def minimax_with_alpha(max_player = true, ply = 0, alpha = -9999, beta = 9999) | |
if board.winner? | |
return winning_score(max_player, ply) | |
elsif board.draw_game? | |
return 0 | |
end | |
current_round = gen_score_game_tree(max_player: max_player, | |
alpha: alpha, | |
beta: beta, |
OlderNewer