Skip to content

Instantly share code, notes, and snippets.

View madzhuga's full-sized avatar

Maxim Madzhuga madzhuga

View GitHub Profile
Map / Мапа / Словарь
---------------------
// Описание мапы (так ты ее описала, но еще не создала, память под нее не выделена, использовать еще нельзя)
var m map[string]int
// Делаешь мапу - теперь под нее выделяется память и в нее уже можно записывать занчения
m = make(map[string]int)
// Задаешь значение по ключу
@madzhuga
madzhuga / example.rb
Created March 25, 2021 11:36
example
class FinalResult
def results(filename)
@filename = filename
prepare
output
end
def prepare
CSV.foreach(file) do |row|
records << row_record(row) if row.length == 16
/ app/views/rails_workflow/operations/_some_event_partial.html.slim
ruby:
# I know it's bad code but doing it this way just to focus
# on post topic
user = User.find(context.data["user"][:id])
table.table.table-striped.table-hover
tbody
tr
td User
RailsWorkflow::EventManager.create_event(‘some_event’, { user_id: 14 })
class SomeEvent < RailsWorkflow::EventOperation
# We getting here event context - which we can use to match
# this operation to a given event
def match(event_context)
event_context[:user_id] == user.id
end
private
def user
RailsWorkflow::EventManager.create_event('some_event', { event_context: 'bla-bla-bla' })
class OperationsController < ApplicationController
...
skip_before_action :navigate_to_current_operation
...
end
class ApplicationController < ActionController::Base
...
before_action :navigate_to_current_operation
def navigate_to_current_operation
return unless current_operation
redirect_to current_operation_path
end
...
end
class ApplicationController < ActionController::Base
...
before_action :navigate_to_current_operation
def navigate_to_current_operation
return unless current_operation
redirect_to send(current_operation.data[:url_path], *current_operation.data[:url_params])
end
...
end
class OperationsController < ApplicationController
before_action do
@skip_current_operation_button = true
end
...
end