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
| class State | |
| attr_accessor :value, :parent, :cost, :distance | |
| def initialize(value, distance, parent) | |
| @value, @distance, @parent, @cost = value, distance, parent, 0 | |
| end | |
| def to_s; value; end | |
| end | |
| def search(strategy, current, final) | |
| return false if current.nil? |
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
| class Node | |
| attr_accessor :value, :left, :right, :cost | |
| def to_s; value; end | |
| def cost; @cost == nil ? 0 : @cost; end | |
| end | |
| def ts(strategy, current, final, total_cost=0.0) | |
| return false if current.nil? | |
| return true if current.value == final | |
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
| # Usage | |
| # @browser ||= Rack::Test::Session.new(Rack::RemoteSession.new(Sinatra::Application, "twitter.com")) | |
| require 'httparty' | |
| module Rack | |
| class RemoteSession < MockSession # :nodoc: | |
| def request(uri, env) | |
| env["HTTP_COOKIE"] ||= cookie_jar.for(uri) |
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
| class NeuroticException < Exception; end | |
| module NeuroticBuilder | |
| @@_required_on_create = [] | |
| def build(*args) | |
| instance = self.send(:new, *args) | |
| yield(instance) if block_given? | |
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(chop). | |
| -export([chop/2]). | |
| chop(_Value, []) -> | |
| -1; | |
| chop(Value, List) -> | |
| case (length(List) + 1) div 2 of | |
| 0 -> | |
| -1; |
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
| Instalacao do ambiente Ruby/Rails no RedHat 5.5 | |
| =============================================== | |
| Observacao: Na instalacao em outro S.O. (Linux) o processo eh muito parecido | |
| Toda a instalacao foi feita como root. Se feita com algum usuario o RVM sera | |
| instalado na pasta do usuario, e nao para todo o sistema. Atente-se a isso e | |
| na duvida veja na documentacao do RVM. | |
| 0. Requisitos |
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
| #!/bin/sh | |
| USER=ruby | |
| case "$1" in | |
| start) | |
| echo "Starting CruiseControl.rb..." | |
| su - $USER -c 'rvm use 1.8.7@ci && /home/ruby/ci/cruisecontrol/cruise start -d' | |
| ;; | |
| stop) |
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
| class ClassWithAttr | |
| def self.my_attr_accessor(attr_name) | |
| define_method("#{attr_name}=") do |arg| | |
| instance_variable_set("@#{attr_name}", arg) | |
| end | |
| define_method(attr_name) do | |
| instance_variable_get("@#{attr_name}") | |
| end | |
| end | |
NewerOlder