This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# unless there's a really good reason to do so, a view should not be passed a reference to a preexisting DOM element | |
view = new BadPhoneInputView(el: $('#phone')) | |
# instead, write your markup as a string-property of the view prototype to be evaluated at render-time | |
class GoodPhoneInputView extends Backbone.Marionette.ItemView | |
template: "<input type='text' name='phone'><a class='submit' href='#'>submit</a>" | |
# this allows us to unit-test the view in-memory, independently of the document |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'barrister-redis' | |
require './service.rb' | |
container = Barrister::RedisContainer.new('./user_service.idl', | |
[HandlerA.new, HandlerB.new], | |
database_url: ENV['OPENREDIS_URL'], | |
list_name: 'user_service') | |
container.start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# x = Loan.new | |
# x.attributes = process_parameters(params[:apply]) | |
# x.to_json | |
{ | |
"loan":{ | |
"address_city":"Dallas", | |
"address_state":"TX", | |
"address_street":"101 Main Street", | |
"address_suite_number":"#101", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
insert :: LogMessage -> MessageTree -> MessageTree | |
insert (Unknown _) t = t | |
insert m@(LogMessage _ ts1 _) t = case t of | |
(Leaf) -> Node Leaf m Leaf | |
(Node _ (Unknown _) _) -> t | |
(Node t1 m2@(LogMessage _ ts2 _) t2) -> case ts1 < ts2 of | |
True -> Node (insert m t1) m2 t2 | |
False -> Node t1 m2 (insert m t2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addSomethingToEach :: [Integer] -> [Integer] | |
addSomethingToEach list = map something list | |
where something n = case (n > 0) of | |
True -> 2 | |
False -> 9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
after_create :notify_added | |
validates :email, uniqueness: true | |
def notify_added | |
UserMailer.email(self).deliver | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
after_create :notify_added | |
validates :email, uniqueness: true | |
def notify_added | |
UserMailer.email(self).deliver | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsersController < ApplicationController | |
def index | |
@users = User.all | |
end | |
def new; end | |
def create | |
User.new(user_params).save! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// services/mail_service/interface.idl | |
interface MailService { | |
send_email(from string, to string, subject string, body string) bool | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// services/user_service/interface.idl | |
struct UserProperties { | |
email string | |
full_name string | |
phone_number string [optional] | |
} | |
struct User extends UserProperties { | |
id int |