Skip to content

Instantly share code, notes, and snippets.

View ka8725's full-sized avatar
🚀
Ruby on Rails expert with business development mindset | WideFix Founder

Andrei Kaleshka ka8725

🚀
Ruby on Rails expert with business development mindset | WideFix Founder
View GitHub Profile
RSpec.configure do |config|
config.around(:all, callbacks: true) do |example|
ActiveRecord::Base.skip_callbacks = false
example.run
ActiveRecord::Base.skip_callbacks = true
end
end
ActiveRecord::Base.skip_callbacks = true
# app/models/base.rb
module Base
def some_method
ImpClass.test
end
end
# app/models/impl_class
class ImlClass
include Base
@ka8725
ka8725 / gist:e8727dc650a9079f8732
Created July 18, 2014 00:07
Fucking javascript
>>> c = [1,2,[1,2]]
1,2,1,2
>>> c.sort()
1,1,2,2
>>> c.join('--')
1--1,2--2
>>> c.length
3
>>> c[0]
1
@ka8725
ka8725 / invalid_factory_girl.rb
Created August 5, 2014 20:56
Invalid factory
class Company < AR
has_many :users
has_many :discounts
end
class User < AR
belongs_to :company
has_many :discounts
end
class Object
def raise_not_implemented
raise NotImplementedError.new("Define ##{caller_locations(1,1)[0].label} for #{self.class}")
end
end
class << true
def !@
true
end
end
class << false
def !@
false
end
module Publisher
extend self
# delegate to ActiveSupport::Notifications.instrument
def broadcast_event(event_name, payload={})
if block_given?
ActiveSupport::Notifications.instrument(event_name, payload) do
yield
end
else
class CreateUserForm
include ActiveModel::Model
attr_accessor :email
attr_accessor :name
def initialize
@user = User.new
end
require 'delegate'
require 'benchmark'
class User
attr_reader :name
def initialize(name)
@name = name
end
end
@ka8725
ka8725 / smart.txt
Last active August 29, 2015 14:17 — forked from avsej/smart.txt
smartctl 6.3 2014-07-26 r3976 [x86_64-linux-4.0.0-0.rc3.git2.1.fc23.x86_64] (local build)
Copyright (C) 2002-14, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Device Model: Samsung SSD 850 PRO 256GB
Serial Number: S1SUNSAFA06649M
LU WWN Device Id: 5 002538 8a0713409
Firmware Version: EXM01B6Q
User Capacity: 256,060,514,304 bytes [256 GB]
Sector Size: 512 bytes logical/physical