start new:
tmux
start new with session name:
tmux new -s myname
--colour | |
-I app |
module AbstractClass | |
def self.included(klass) | |
klass.instance_exec do | |
@abstract_class = klass | |
def self.new(*args) | |
if self == @abstract_class | |
raise "Instantiating abstract class #{self} is not allowed." | |
else | |
super |
# include from an initializer | |
module HstoreAccessor | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def hstore_accessor(hstore_attribute, *keys) | |
Array(keys).flatten.each do |key| |
module DelayedJob | |
module Matchers | |
def enqueue_delayed_job(handler) | |
DelayedJobMatcher.new handler | |
end | |
class DelayedJobMatcher | |
def initialize(handler) | |
@handler = handler | |
@attributes = {} |
namespace :db do | |
namespace :enable do | |
desc "enable hstore extension" | |
task :hstore => [:environment, :load_config] do | |
ActiveRecord::Base.connection.execute('CREATE EXTENSION IF NOT EXISTS hstore;') | |
end | |
end | |
Rake::Task['db:schema:load'].enhance ['db:enable:hstore'] | |
end |
Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?
Add the project to your repo:
git submodule add [email protected]:AFNetworking/AFNetworking.git Vendor/AFNetworking
or something to that effect.
# Public: A module to be mixed in another class with common methods to index | |
# records in ElasticSearch. | |
# | |
# The host object needs to respond to 'indexed_attributes', which will return | |
# an array of the attributes names to be indexed. | |
# | |
# It's also recommended to override the 'save?' method to make sure only | |
# records that match some specifications are indexed. | |
# | |
# The type used for the ElasticSearch index will be extracted from the name of |
class SomeBusinessCase | |
include Wisper | |
def execute(attributes) | |
if true | |
publish(:some_business_case_successful, details) | |
else | |
publish(:some_business_case_failed, details) | |
end | |
end |
#somewhere in a controller | |
CreateOrder.new(OrderRepository).create current_user, params | |
# where | |
class CreateOrder < UseCaseService | |
def initialize order_repo | |
@order_repo = order_repo |