Skip to content

Instantly share code, notes, and snippets.

View cored's full-sized avatar
🐽
Hacking Everything

Rafael George cored

🐽
Hacking Everything
View GitHub Profile
if (!isWordEmpty(word)) {
word = removeHelloFromWord(word);
}
private boolean isWordEmpty(word) {
return "".equals(word);
}
private String removeHelloFromWord(word) {
return word.replaceAll("hello","");
if ( !"".equals(words) ) {
words = words.replaceAll("hello", "");
}
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)
package org.codekata;
import java.util.ArrayList;
import org.apache.commons.lang.StringUtils;
public class StringCalculator {
private static final String DEFAULT_DELIMITER = ",";
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)
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'
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"}
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 `
>> 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
require 'digest/sha2'
class User < ActiveRecord::Base
NAME_SIZE = 1..64
EMAIL_SIZE = 1..230
PASSWORD_SIZE = 4..20