Skip to content

Instantly share code, notes, and snippets.

View sclinede's full-sized avatar

Sara Dolganov sclinede

View GitHub Profile
@sclinede
sclinede / pipelines.rb
Last active September 24, 2023 11:10
Sagas implementation in pure Ruby (pre-DirtyPipelines gem)
class DirtyPipeline::Action
module WrappedCall
def call
Events.publish! Event.generate(self)
super
end
end
class << self
attr_accessor :attempted_event_klass, :pipeline, :timeout
Реализуется как отдельное независимое приложение-сервис.
Формат для обмена данными пока не согласован
Платформа: Rails 4, Ruby 2.1
Сервис строится вокруг UN (Universal Number) с хранением связанного id компании (как числа, без контроля целостности последнего).
Получение данных происходит с помощью прямого доступа к таблицам сервиса в режиме чтения.
Для изменения данных об UNах, используется API.
API:
@sclinede
sclinede / saga.rb
Last active March 6, 2022 06:09
Example of Full Saga implementation in Ruby (with Usage example, also)
class Saga
class << self
def with_redis; raise NotImplementedError; end
attr_accessor :cleanup_delay, :queue, :last_txid
def queue
Thread.current[:saga_queue] ||= []
end
def last_txid
module SimpleRailway
class Result
attr_accessor :success, :data
def initialize(success, data)
@success = success
@data = data
end
def success?; !!success; end
def failure?; !success?; end
# Usage:
#
# class Mail
# include SimpleStateMachine
#
# self.initial_state = 'unread'
# self.transitions_map = {
# read: {from: 'unread', to: 'read'},
# unread: {from: 'any', to: 'unread'},
# delete: {from: 'any', to: 'deleted'},

Keybase proof

I hereby claim:

  • I am sclinede on github.
  • I am sclinede (https://keybase.io/sclinede) on keybase.
  • I have a public key ASDUo5iyfIIqj7mP4hqtK0zJCXexqsJsNf_fdOSLBRWUwQo

To claim this, I am signing this object:

@sclinede
sclinede / yardoc_cheatsheet.md
Created December 24, 2016 12:00 — forked from chetan/yardoc_cheatsheet.md
YARD cheatsheet

YARD CHEATSHEET http://yardoc.org

cribbed from http://pastebin.com/xgzeAmBn

Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.

Modules

Namespace for classes and modules that handle serving documentation over HTTP

# Public: Виджет 'Акции компании на главной ск'
#
# Возвращает публикуемые, не истекшие, одобренные или на модерации, отмеченные for_home_page,
# наиболее свежие по дате создания акции
#
# Examples
#
# presenter 'apress/deals/front/offer', :latest_company_offers, company, {limit: 3}
#
# company - Company - компания, акции которой необходимо получить
Долганов С.С., текущие задачи:
- Задача 1 (срок к дд.мм.гггг):
Небольшое описание, коментарии и проч.
- Задача 2 (срок к дд.мм.гггг):
Другое описание и бла-бла-бла.
private void newMessageHandler(object _sender, NewMessageEventArgs e)
{
// Здесь вы можете обработать данное событие, e.Text - содержит текст сообщения
}
//... где-то в коде ...
//... там где вы инициализируете общение между желающими ...
Communicator MyCom = new Communicator(localPort, destIp, destPort); // Параметры, соответственно: порт для входящих соединений (1), IP того с кем связываемся (2),
// порт входящих соединений того с кем связываемся (3)