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
RSpec.configure do |config| | |
config.before do | |
Category.subclasses.each do |c| | |
c.instance_variable_set(:@instance, nil) | |
end | |
Category.instance_variable_set(:@instances, nil) | |
end | |
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
x = '123' | |
x[0, x.length] = 'aa' # x.replace('aa') |
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
STEP_DECORATORS_MAPPING = { | |
step1: Decorator1, | |
step2: Decorator2 | |
} | |
step = :step1 | |
STEP_DECORATORS_MAPPING[step].new(...) |
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
/usr/local/opt/rbenv/versions/2.1.0/lib/ruby/2.1.0/bigdecimal/util.rb:18: [BUG] Segmentation fault at 0x00000000000000 | ETA: 00:04:13 | |
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0] | |
-- Crash Report log information -------------------------------------------- | |
See Crash Report log file under the one of following: | |
* ~/Library/Logs/CrashReporter | |
* /Library/Logs/CrashReporter | |
* ~/Library/Logs/DiagnosticReports | |
* /Library/Logs/DiagnosticReports | |
for more details. |
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
require 'minitest/autorun' | |
BOOLEAN_MAPPINGS = { | |
'true' => true, | |
'false' => false | |
} | |
def typecast_hash_values(hash) | |
hash.each do |k, old_value| | |
if (new_value = BOOLEAN_MAPPINGS.fetch(old_value, old_value)) != old_value |
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
class DeviseCreateUsers < ActiveRecord::Migration | |
def migrate(direction) | |
super | |
# Create a default user | |
User.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if direction == :up | |
end | |
def change | |
create_table(:users) do |t| | |
## Database authenticatable |
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
module LiquidPresenters | |
class Plan < SimpleDelegator | |
def to_liquid | |
@to_liquid ||= HashWithIndifferentAccess.new({ | |
id: self.id, | |
name: self.name, | |
description: self.description, | |
status: self.status, | |
class_id: self.plan_class_id | |
}) |
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
require 'active_record' | |
require 'minitest/autorun' | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db.sqlite3') | |
ActiveRecord::Schema.define do | |
create_table :users, force: true do |t| | |
t.references :company, index: true | |
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
require 'active_record' | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db.sqlite3') | |
ActiveRecord::Schema.define do | |
create_table :users, force: true do |t| | |
end | |
end | |
class ActiveRecord::Base |
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
$ python -m smtpd -n -c DebuggingServer localhost:1025 | |
This is how receiving email looks like: | |
---------- MESSAGE FOLLOWS ---------- | |
MIME-Version: 1.0 | |
Content-Type: text/plain; charset="utf-8" | |
Content-Transfer-Encoding: 7bit | |
Subject: User activation - localhost:8000 | |
From: info@google.ru |