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
x0 = (0..500).map{ |xx| xx/1000.0 } | |
y0 = x0.map{ |xx| Math.exp(-xx) } | |
x1 = (500..1000).map{ |xx| xx/1000.0 } | |
y1 = x1.map{ |xx| Math.exp(-xx) } | |
# create new datablock | |
datablock = Datablock.new([x0, y0]) | |
# now data will be sent to gnuplot and new datablock in terminal created | |
# everything is good, we still may have stateless objects |
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
def generic_restriction(method_name, attributes) | |
[:define_method, :define_singleton_method].each do |definition_method| | |
send definition_method, method_name do | |
attributes | |
end | |
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
Запрос через IN: | |
SELECT "documents".* FROM "documents" | |
WHERE "documents"."archived_at" IS NULL | |
AND ( | |
contractor_id IN (SELECT id FROM companies WHERE lower(COALESCE(companies.title, '')) ~* 'основ') | |
OR stock_to_id IN (SELECT id FROM stocks WHERE lower(COALESCE(stocks.title, '')) ~* 'основ') | |
OR stock_from_id IN (SELECT id FROM stocks WHERE lower(COALESCE(stocks.title, '')) ~* 'основ') | |
); | |
EXPLAIN ANALYZE: | |
>> Append (cost=135.96..2696.11 rows=3680 width=291) (actual time=4.539..52.993 rows=1940 loops=1) |
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
# A monkey-patch that allows you to use comma as decimal separator in ActiveRecord | |
# Notice for rails 5.0: in Rails 5.0 module Type with all nested classes is moved into ActiveModel, | |
# so don't forget to substitute 'module ActiveRecord' with 'module ActiveModel' after update | |
module ActiveRecord | |
module Type | |
class Decimal | |
private | |
alias_method :cast_value_without_comma_separator, :cast_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 Formula | |
attr_accessor :value | |
def initialize(v) | |
@value = v | |
end | |
def to_s | |
value | |
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
module A | |
def a | |
puts 'A' | |
end | |
end | |
module B | |
def a | |
puts 'B' | |
end |