Skip to content

Instantly share code, notes, and snippets.

View sbellware's full-sized avatar

Scott Bellware sbellware

View GitHub Profile
@sbellware
sbellware / filter_tweeps.rb
Created February 27, 2015 01:04
Example of command pattern with dependencies
tweep = #...
GrowViral::TweepProcessor::FilterTweeps.! tweep
module GrowViral
module TweepProcessor
class FilterTweeps
attr_reader :tweep
attr_reader :rejections
null_object_accessor :logger, Logger
@sbellware
sbellware / build-gem-conversation-samuel-williams-scott-bellware.txt
Created February 25, 2015 03:55
Samuel Williams request for ownership of the "build" gem name
Samuel Williams
3/4/14
Hey
I’m releasing a build tool for ruby/c++ package manager.
Wondering if I could use the name “build” for my gem.
Apparently if you yank all versions (0.0.0 :D), I can reuse the name.
@sbellware
sbellware / template_method.rb
Last active August 29, 2015 14:15
An idea for making template method pattern more explicit in Ruby
class Thing
include Virtual
def dimensions
{width: subclass.width, height: subclass.height}
end
end
class Example < Thing
def width
11 Fallacies of Distributed Computing
1. The network is reliable (Bill Joy, Tom Lyon)
2. Latency isn't a problem (Bill Joy, Tom Lyon)
3. Bandwidth isn't a problem (Bill Joy, Tom Lyon)
4. The network is secure (Bill Joy, Tom Lyon)
5. The topology won't change (Peter Deutsch)
6. The administrator will know what to do (Peter Deutsch)
7. Transport cost isn't a problem (Peter Deutsch)
8. The network is homogeneous (James Gosling)
@sbellware
sbellware / prox_gem.rb
Last active August 29, 2015 14:09
References gems from path, git, or remote gem server based on configuration in environment variables
def prox_gem(gem_name, options={})
opts = _options(gem_name, options)
gem gem_name, opts
end
def _options(gem_name, options={})
mode = _prox_gem_mode
if mode == "path"
return { :path => _file_system_path(gem_name) }
elsif mode == "git"
@sbellware
sbellware / command_with_configuration.rb
Last active August 29, 2015 14:07
Configuring a Ruby Command Object
module Freendship
class Create
attr_reader :user_id
attr_reader: friend_id
# NOTE: null_attr creates an attr with a null object default value
null_attr :logger
null_attr :data_access
def initialize(user_id, :friend_id)
class SomeCommand
attr_accessor ...some attributes used by the command...
def initialize(...some initializer parameters...)
# Set the instance's attributes to the corresponding initializer parameters
end
def !
# This is the executor method (ie: the command's "raison d'etre")
# Do something here, making use of the parameters passed
class Other
attr :x
end
# Pull (Ask, Instead of Tell)
self.x = other.x
# NOTE: The `other.x` retrieves a value from `other`. Therefore, it's a "query", or an "ask".
# Creates more coupling as `other` must expose a larger interface to cover all of the values
# to be pulled from it to be copied to other objects.
@sbellware
sbellware / perfection.md
Created July 22, 2014 15:19
The Purpose of Perfection - Much Ado About Agile 2014

The Purpose of Perfection


They say that "perfect is the enemy of the good". It's possible that their translation from French lacks some of the nuance of the original quote, and takes some license to rationalize a work management ideology where people who make decisions are insulated from suffering the consequences of those decisions. The typical diminishing returns of a software effort are not seen as a consequence of a poor understanding of perfection. There's a science to perfection, and western industry was taken by surprise by its competitive advantage

Hatchet.configure do |config|
config.level :warn
config.level :debug, 'Application::BankTransfer'
config.appender(Hatchet::LoggerAppender.new) do |appender|
appender.logger = Logger.new('log/application.log')
end
config.appender(CustomEmailAppender.new) do |appender|
appender.level :fatal