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
# Представим, что у нас есть некоторый внешний источник, который возвращает нам данные в виде массива хэшей. | |
# Причём все значения в хэшах передаются как строки. Создайте такой универсальный класс Storage, который позволит | |
# создавать классы преобразователи: | |
require 'time' | |
class Storage | |
def self.attrb(attribute_name, attribute_accessor = nil, &process_proc) | |
raise ArgumentError if attribute_name.nil? |
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
# wrap_method оборачивает вызовы методов вызовами before- и after-методов | |
# Возможно множественная обертка, в ходе которой образуется method-chain | |
module Wrappable | |
class WrapperOptions | |
attr_reader :before_callback, :after_callback | |
def initialize(&block) | |
instance_eval(&block) | |
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 'mysql2' | |
client = Mysql2::Client.new(:host => "localhost", :username => "root", :password => "password", :database => "ar_sample") | |
results = client.query('DROP TABLE if exists pet') | |
results = client.query('CREATE TABLE pet (id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, name CHAR(30), owner_name CHAR(20), age SMALLINT(6));') | |
class String | |
def to_sql; "\"#{self.to_s}\""; 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
require 'ftpd' | |
class Driver | |
def initialize(temp_dir) | |
@temp_dir = temp_dir | |
end | |
def authenticate(user, password) | |
true | |
end | |
def file_system(user) |
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
-- sample pgq working example with internal ticker call | |
select pgq.create_queue('LogEvent'); | |
select pgq.insert_event('LogEvent', 'data', 'DataFor123'); | |
select pgq.register_consumer('LogEvent', 'TestConsumer'); | |
select pgq.ticker(); | |
select pgq.next_batch('LogEvent', 'TestConsumer'); |
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
SELECT a.pid, a.usename, mode, locktype, query, state, granted, | |
tuple, transactionid, classid, objid, objsubid | |
FROM pg_catalog.pg_locks bl | |
JOIN pg_catalog.pg_stat_activity a ON a.pid = bl.pid | |
where granted and a.pid <> pg_backend_pid() | |
order by locktype; |
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
Общий алгоримт работы над задачей: | |
Практически любая задача вам будет дана в виде ссылки на задачу в системе JIRA. | |
Перейдя по ссылке вы увидите подробное описание задачи. Внимательно ознакомтесь с ним. | |
Если у Вас возникнут вопросы, вы можете обратиться к своему ПМ, или автору задачи, с просьбой разъяснить некоторые вопросы. | |
Если Вам все ясно, вы приступаете к решению задачи. | |
Прежде чем писать код, рекомендуется сделать в гите отдельную ветку для решения текущей задачи. Подбробней см. статью Гит-воркфлоу. | |
После того, как вы приступили к работе над задачей, необходимо проставить статус "В процессе", чтобы избежать вероятности решения задачи несколькими людьми одновременно. |
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
Ошибки в шаблонах. | |
Практически все шаблоны в наших проектах написаны с использованием HAML. Так что в первую очередь вам необходимо понять, что это такое. | |
Полезные ссылки для изучения вопроса: | |
http://haml.info/ | |
https://github.com/haml/haml | |
https://ru.wikipedia.org/wiki/Haml | |
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 'open-uri' | |
require 'csv' | |
require 'nokogiri' | |
require 'digest' | |
require 'curl' | |
class Parser | |
@@headers = %w{type, group, pic, name} | |
@@catalog ||= CSV.read("catalog.txt", "a+", col_sep: "\t", headers: true, converters: :numeric, header_converters: :symbol).map { |row| row.to_h } |
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
[ | |
{ | |
color: "red", | |
value: "#f00" | |
}, | |
{ | |
color: "green", | |
value: "#0f0" | |
}, | |
{ |
OlderNewer