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
if (!isWordEmpty(word)) { | |
word = removeHelloFromWord(word); | |
} | |
private boolean isWordEmpty(word) { | |
return "".equals(word); | |
} | |
private String removeHelloFromWord(word) { | |
return word.replaceAll("hello",""); |
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
if ( !"".equals(words) ) { | |
words = words.replaceAll("hello", ""); | |
} |
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 Money | |
def initialize(dollars, cents=0) | |
@dollars = dollars | |
@cents = cents | |
end | |
def +(other) | |
case other | |
when Money | |
Money.new(@dollars+other.dollars, @cents + other.cents) |
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
package org.codekata; | |
import java.util.ArrayList; | |
import org.apache.commons.lang.StringUtils; | |
public class StringCalculator { | |
private static final String DEFAULT_DELIMITER = ","; |
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 'machinist/active_record' | |
require 'sham' | |
require 'faker' | |
# This file should contain all the record creation needed to seed the database with its default values. | |
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). | |
# | |
# Examples: | |
# | |
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) | |
# Major.create(:name => 'Daley', :city => cities.first) |
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
ActionController::Routing::Routes.draw do |map| | |
map.check_email "users/check_email", :controller => "users", :action => "check_email" | |
map.resources :categories | |
map.resources :events | |
map.resources :users | |
# The priority is based upon order of creation: first created -> highest priority. | |
# Sample of regular route: | |
# map.connect 'products/:id', :controller => 'catalog', :action => 'view' |
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
events GET /events(.:format) {:controller=>"events", :action=>"index"} | |
POST /events(.:format) {:controller=>"events", :action=>"create"} | |
new_event GET /events/new(.:format) {:controller=>"events", :action=>"new"} | |
edit_event GET /events/:id/edit(.:format) {:controller=>"events", :action=>"edit"} | |
event GET /events/:id(.:format) {:controller=>"events", :action=>"show"} | |
PUT /events/:id(.:format) {:controller=>"events", :action=>"update"} | |
DELETE /events/:id(.:format) {:controller=>"events", :action=>"destroy"} | |
/ {:controller=>"events", :action=>"index"} | |
root / {:controller=>"events", :action=>"index"} |
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
NameError: uninitialized constant Event::Attendant | |
from /usr/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:105:in `rescue in const_missing' | |
from /usr/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:94:in `const_missing' | |
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/base.rb:2199:in `rescue in block in compute_type' | |
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/base.rb:2199:in `class_eval' | |
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/base.rb:2199:in `rescue in block in compute_type' | |
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/base.rb:2196:in `block in compute_type' | |
from /usr/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings' | |
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/base.rb:2195:in ` |
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
>> Event.first.attendants | |
NameError: uninitialized constant Event::Attendant | |
from /usr/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:105:in `rescue in const_missing' | |
from /usr/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:94:in `const_missing' | |
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/base.rb:2199:in `rescue in block in compute_type' | |
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/base.rb:2199:in `class_eval' | |
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/base.rb:2199:in `rescue in block in compute_type' | |
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/base.rb:2196:in `block in compute_type' | |
from /usr/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings' | |
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/activ |
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 'digest/sha2' | |
class User < ActiveRecord::Base | |
NAME_SIZE = 1..64 | |
EMAIL_SIZE = 1..230 | |
PASSWORD_SIZE = 4..20 |