Skip to content

Instantly share code, notes, and snippets.

Benjamin Gaertig ben-ole

Block or report user

Report or block ben-ole

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ben-ole
ben-ole / event_handler.ex
Created Jul 3, 2018
KaufmannEx EventHandler 1
View event_handler.ex
defmodule Sample.EventHandler do
alias KaufmannEx.Schemas.Event
def given_event(%Event{name: :"command.user.create", payload: payload} = event) do
{:ok, user_info} = Sample.User.create(payload)
Publisher.publish(:"event.user.create", user_info, event.meta)
end
@ben-ole
ben-ole / event_handler.ex
Created Jul 3, 2018
KaufmannEx EventHandler 2
View event_handler.ex
defmodule Sample.EventHandler do
alias KaufmannEx.Schemas.Event
def given_event(%Event{name: :"command.user.create", payload: payload} = event) do
{:ok, user_info} = Sample.User.create(payload)
Publisher.publish(:"event.user.create", user_info, event.meta)
end
@ben-ole
ben-ole / publisher.ex
Last active Jul 3, 2018
Kafka publisher
View publisher.ex
defmodule Sample.Publisher do
def publish(event_name, payload, context \\ %{}, topic \\ :default) do
message_body = %{
payload: payload,
meta: event_metadata(event_name, context)
}
KaufmannEx.Publisher.publish(event_name, message_body, context)
@ben-ole
ben-ole / event_handler_test.ex
Created Jul 3, 2018
KaufmannEx TestSupport
View event_handler_test.ex
defmodule Sample.EventHandlerTest do
use KaufmannEx.TestSupport.MockBus
test "Events Can Be published & observed" do
given_event(:"command.user.create", %{user_name: "Test User", user_email: "test@example.com"})
assert %{
payload: %{user_id: uknown_id}
} = then_event(:"event.test")
end
@ben-ole
ben-ole / form_helper.rb
Created Feb 23, 2017
Foundation Switch Rails Form Helper
View form_helper.rb
module FormHelper
class ActionView::Helpers::FormBuilder
include ActionView::Helpers::FormTagHelper
include ActionView::Helpers::FormOptionsHelper
def switch(name, options = {})
@switch_id = "#{@object_name}_#{name}"
lbl(name,options) + container(name,options)
end
@ben-ole
ben-ole / Paging.coffee
Last active Aug 26, 2016
Simple Navigation Component for FramerJS
View Paging.coffee
# simple navigation componenent like on iOS
# put at the top of your file
class Paging
pages = Array()
constructor: (@bg_layer) ->
# push a new page on top
You can’t perform that action at this time.