Skip to content

Instantly share code, notes, and snippets.

View sbellware's full-sized avatar

Scott Bellware sbellware

View GitHub Profile
@sbellware
sbellware / events_table.sql
Created May 15, 2016 02:42
Event Sourcing Basics for Postgres
CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public;
-- ----------------------------
-- Table structure for events
-- ----------------------------
DROP TABLE IF EXISTS "public"."events";
CREATE TABLE "public"."events" (
"id" uuid DEFAULT gen_random_uuid() NOT NULL,
"type" varchar NOT NULL COLLATE "default",
"stream" varchar NOT NULL COLLATE "default",
@sbellware
sbellware / gist:795297
Created January 25, 2011 17:51
An Alternative to All-or-Nothing Custom Form Builder Replacement

An Alternative to All-or-Nothing Custom Form Builder Replacement

Background

Replacing Rails' default form builder with a custom form builder is a typical way of adding custom form helpers to a Rails application.

The typical way of doing this is:

ActionView::Base.default_form_builder = MyCustomFormBuilder
@sbellware
sbellware / gist:892438
Created March 29, 2011 14:19
Example Haml Helper for Creating a Submit Button with Nested Span for its Label
def submit_button(options={})
text = options.delete(:text) || "Submit"
options.merge! :type => :submit
capture_haml do
haml_concat(content_tag(:button, options) do
haml_concat content_tag(:span, text)
end)
end
end
module Events
class Opened
include Messaging::Message
attribute :account_id, String
attribute :customer_id, String
attribute :time, String
end
class Deposited

RubyGems and Namespacing

Here's what my Gemfile should be:

source 'https://rubygems.org'

source 'https://gem.fury.io/eventide' do
  gem 'eventide'
end
@sbellware
sbellware / category-slice.json
Last active April 13, 2016 19:07
EventStore Slice Examples
{
"title": "Event stream '$ce-sendFunds'",
"id": "http://127.0.0.1:2113/streams/%24ce-sendFunds",
"updated": "2016-04-13T23:27:54.854508Z",
"streamId": "$ce-sendFunds",
"author": {
"name": "EventStore"
},
"headOfStream": true,
"selfUrl": "http://127.0.0.1:2113/streams/%24ce-sendFunds",
module Events
class Recorded
include EventStore::Messaging::Message
include Lapse
attribute :error_id
attribute :time
attribute :source
attribute :hostname
attribute :error
require 'benchmark'
class Thing
end
module SomeMod
end
Benchmark.bm do |x|
x.report do
module Calculate
attr_accessor :num1
attr_accessor :num2
def calculate
self.!
end
end
class Arithmetic < Module