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 require_folder(folder_name_in_app) | |
| Dir[File.expand_path(File.dirname(__FILE__) + "/../app/" + folder_name_in_app + "/*.rb"].each { |file| require file } | |
| 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
| source 'http://rubygems.org' | |
| gem 'rails', '3.0.0' | |
| gem 'sqlite3-ruby', :require => 'sqlite3' | |
| group :development do | |
| gem 'rspec-rails', '2.0.1' | |
| end | |
| group :test do |
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 SessionsHelper | |
| include SignInOut | |
| def create_cookie(user_id, user_salt); end | |
| def remember_token; end | |
| def delete_cookie; 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
| #you can use this easily like the following in your spec files: | |
| reuqire_relative "../spec_helper_lite" | |
| reuqire_relative_to_root "lib/some_domain_logic" | |
| describe "some domain logic" do | |
| #specs will be here then | |
| 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
| require 'socket' | |
| HTTP_HEADER = "HTTP/1.1 200/OK\r\nContent-type:text/html\r\n\r\n" | |
| CURRENT_DIR = "." | |
| SPACE_IN_PARAM = "%20" | |
| def file_explorer | |
| webserver = TCPServer.new("localhost", 2000) | |
| loop do | |
| Thread.start(webserver.accept) do |session| |
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 Closest | |
| MAX = 2000000000000 | |
| def to_zero(input) | |
| raise IllegalArgumentException if input.nil? || input.empty? | |
| closest_to_zero = MAX | |
| @least_distance = MAX | |
| input.each do |num| | |
| if closer_to_zero(num) |
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
| (define make-pair (a, b) | |
| (lambda (pick) | |
| (cond (= pick 1) a) | |
| (cond (= pick 2) b))) | |
| (define car (x) (x 1)) | |
| (define cdr (x) (x 2)) |
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 Mutator | |
| def initialize(ruby_file) | |
| @ruby_file = ruby_file | |
| end | |
| def run_test | |
| spec_file_name = @ruby_file.split(/\./)[0] | |
| system("rspec #{spec_file_name}_spec.rb") | |
| 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
| (defn swap-pairs [items] | |
| (into (empty items) | |
| (interleave (take-nth 2 (drop 1 items)) | |
| (take-nth 2 items)))) | |
| (swap-pairs [1 2 3 4 5 6]) ;=> [2 1 4 3 6 3] |
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 'net/http' | |
| require 'json' | |
| module Bing | |
| class Search | |
| BASE_URL = "https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Composite?" | |
| SINGLE_QUOTE_ENCODED = "%27" | |
| def initialize(api_key) | |
| @api_key = api_key |
OlderNewer