Skip to content

Instantly share code, notes, and snippets.

@mwean
mwean / gist:3805758
Created September 30, 2012 03:36
Class-level observers
require 'observer'
class BudgetsConsumer
def self.update(val)
puts "new value from enrollment consumer: #{val}"
end
end
class EnrollmentsConsumer
extend Observable
@mwean
mwean / gist:3808618
Created September 30, 2012 22:27
Examples of ConsumerPublisher
class ConsumerChangesObserver < ActiveRecord::Observer
observe :consumer, :address_record, :consumer_enrollment
def after_update(record)
ConsumerPublisher.publish_change(record)
end
end
class SomeController < FmsController
def some_action
@mwean
mwean / gist:3822941
Created October 2, 2012 20:01
Message-Based Callbacks
module FmsEngine
module Core
class Callbacks
class << self
# Redis or something:
CALLBACK_REGISTRY = Hash.new { |h, k| h[k] = [] }
def bind(event, klass, callback_method, facade_method)
CALLBACK_REGISTRY[event] << { klass: klass, callback_method: callback_method, facade_method: facade_method }
end
@mwean
mwean / ssh debug
Last active December 16, 2015 02:59
OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /home/runner/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to annkissam.beanstalkapp.com [50.31.156.72] port 22.
debug1: Connection established.
debug1: identity file /home/runner/.ssh/id_rsa type -1
debug1: identity file /home/runner/.ssh/id_rsa-cert type -1
debug1: identity file /home/runner/.ssh/id_dsa type -1
@mwean
mwean / accounts.md
Last active December 21, 2015 13:49

Accounts

Create an account

POST /accounts

Input

  • account_id
@mwean
mwean / bitmap_heap_explain.sql
Last active August 29, 2015 14:07
Code Snippets for Adventures in Searching with Postgres - Part 1
Bitmap Heap Scan on icd_codes (cost=7.63..900.68 rows=10 width=143)
Filter: ((code)::text ~~ 'A1%'::text)
-> Bitmap Index Scan on index_code_on_icd_codes (cost=0.00..7.62 rows=333 width=0)
Index Cond: (((code)::text ~>=~ 'A1'::text) AND ((code)::text ~<~ 'A2'::text))
@mwean
mwean / create_index1.sql
Last active October 5, 2017 09:28
Code Snippets for Adventures in Searching with Postgres - Part 2
CREATE INDEX index_description_on_icd_codes ON icd_codes USING gin(to_tsvector(description))
total commits: 192
58 Merge
12 Update
12 Add
9 adds
8 Added
6 bump
6 Fix
4 Still
4 Fixed
@mwean
mwean / SassMeister-input.scss
Created June 3, 2015 19:39
Generated by SassMeister.com.
// ----
// Sass (v3.4.13)
// Compass (v1.0.3)
// ----
map-merge((foo: 1, bar: 2), (baz: 3));
map-merge(("foo": 1), ("bar": 2));
@mwean
mwean / SassMeister-input.scss
Last active August 29, 2015 14:22
Generated by SassMeister.com.
// ----
// Sass (v3.4.14)
// Compass (v1.0.3)
// ----
$positions: (
backend: "\e83a",
dev: "\e84a",
data: "\e82e",
front: "\e807",