Skip to content

Instantly share code, notes, and snippets.

View jacegu's full-sized avatar
🦖
Juggling shipping and parenting

Javier Acero jacegu

🦖
Juggling shipping and parenting
View GitHub Profile
@jacegu
jacegu / tddeo.md
Last active December 24, 2015 05:59
Sobre el estado de tddeo.com

Sobre el estado de tddeo

En las últimas dos semanas muchos me habéis estado preguntando cuando está previsto que salga tddeo. Lo cierto es que aún no puedo decir una fecha. Sin embargo si quiero compartir qué ha pasado en los últimos dos meses y qué va a ocurrir cuando, finalmente, tddeo vea la luz.

El nacimiento

En primer lugar me gustaría explicar cuál fue el origen del proyecto. Ya que, aunque fue anunciado durante el mes de Julio, tiene algunos meses más de vida.

En marzo de 2013 me encontraba en una "encrucijada laboral" (por llamarlo de alguna manera). El trabajo que había estado sustentando mi estatus de freelance había llegado a su fin. Necesitaba encontrar nuevos clientes o abrir nuevas vías de ingresos.

defmodule Teenager do
import String
@reply_to_silence "Fine. Be that way!"
@reply_to_question "Sure."
@reply_to_shout "Woah, chill out!"
@reply_to_other "Whatever."
def hey(message) do
cond do
@jacegu
jacegu / no_mocks_spec.rb
Last active December 20, 2015 14:29
First steps with a mock-less testing.
require 'factory'
describe 'A user' do
let(:user_service) { Tddeo::Factory.user_service }
let(:user_repository) { Tddeo::Factory.user_repository }
before(:all) do
ENV['RACK_ENV'] = 'test'
end
@jacegu
jacegu / gist:6091719
Last active August 3, 2021 03:20
Differences between Domain Services & Application Services

The differences between a domain service and an application services are subtle but critical:

  • Domain services are very granular where as application services are a facade purposed with providing an API.
  • Domain services contain domain logic that can’t naturally be placed in an entity or value object whereas application services orchestrate the execution of domain logic and don’t themselves implement any domain logic.
  • Domain service methods can have other domain elements as operands and return values whereas application services operate upon trivial operands such as identity values and primitive data structures.
  • Application services declare dependencies on infrastructural services required to execute domain logic.
  • Command handlers are a flavor of application services which focus on handling a single command typically in a CQRS architecture.

Source: http://gorodinski.com/blog/2012/04/14/services-in-domain-driven-design-ddd/

@jacegu
jacegu / dispatcher.rb
Last active December 19, 2015 10:19
Playing around with sidekiq workers and dependency injection. You cannot create a new instance of the worker with dependencies injected and call `perform_async` on the instance. (This doesn't make much sense now that I've grasped how sidekiq works, but would have been nice). But you can achieve something similar using a factory to build the depe…
require_relative 'worker'
class Dispatcher
def self.dispatch_instance
Worker.new(STDOUT).perform_async('This is working')
end
def self.dispatch_class
Worker.perform_async('This is working')
end
@jacegu
jacegu / string_calculator.erl
Created April 17, 2013 14:32
My erlang practice of the day.
-module(kata).
-import(lists, [map/2, foldl/3]).
-include_lib("eunit/include/eunit.hrl").
add("") -> 0;
add(Operators) ->
lists:foldl(fun(Number, Acumulator) -> Number + Acumulator end, 0, extractNumbers(Operators, ",\n")).
extractNumbers(String, Separator) ->
map(fun erlang:list_to_integer/1, string:tokens(String, Separator)).
@jacegu
jacegu / roman_numerals.erl
Created April 15, 2013 14:39
Roman numeral kata in erlang. Wondering if there is a better/more idiomatic way to approach the problem.
-module(kata).
-include_lib("eunit/include/eunit.hrl").
to_roman(Arabic) when Arabic >= 50 -> string:concat("L", to_roman(Arabic - 50));
to_roman(Arabic) when Arabic >= 10 -> string:concat("X", to_roman(Arabic - 10));
to_roman(Arabic) when Arabic >= 5 -> string:concat("V", to_roman(Arabic - 5));
to_roman(Arabic) when Arabic =:= 4 -> string:concat("IV", to_roman(Arabic - 4));
to_roman(Arabic) when Arabic >= 1 -> string:concat("I", to_roman(Arabic - 1));
to_roman(_) -> "".
@jacegu
jacegu / lambda_syntax.rb
Created March 14, 2013 14:18
Weird behavior between ruby versions with ->{ } proc syntax. Any explanation?
#ruby 1.9.2-p320
BasicObject.new.instance_eval { ->{} }
#NoMethodError: undefined method `lambda' for #<BasicObject:0x007f97eb198590>
# from (irb):6:in `block in irb_binding'
# from (irb):6:in `instance_eval'
# from (irb):6
# from /Users/jacegu/.rbenv/versions/1.9.2-p320/bin/irb:12:in `<main>'
#ruby 1.9.3-p392
BasicObject.new.instance_eval { ->{} }
@jacegu
jacegu / jacegu.zsh-theme
Created December 9, 2012 21:38
My theme for Oh My Zsh
PROMPT='%{$fg_bold[black]%}⌘ %{$reset_color%}%~ $(git_prompt_info)%{$fg[black]%}❯ %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}(➥ %{$reset_color%}%{$fg[cyan]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$reset_color%}%{$fg[red]%}✗%{$reset_color%})"
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$reset_color%}%{$fg[green]%}✓%{$reset_color%})"
@jacegu
jacegu / functional_gol.rb
Created December 9, 2012 19:38
Functional take on Conway's Game of Life
module Cell
def cell
{ state: :alive, neighbours: [] }
end
def dead_cell
{state: :dead, neighbours: []}
end
def neighbours_of(cell, neighbour_info)