Skip to content

Instantly share code, notes, and snippets.

View mariorez's full-sized avatar

Mario Rezende mariorez

View GitHub Profile
@mariorez
mariorez / gist:060ad802b554babb80b5
Created October 21, 2015 14:30 — forked from ngocdaothanh/gist:3764694
Scala Assignment: Recursion
package recfun
import scala.collection.mutable.ListBuffer
import common._
/** https://class.coursera.org/progfun-2012-001/assignment/view?assignment_id=4 */
object Main {
def main(args: Array[String]) {
println("Pascal's Triangle")
for (row <- 0 to 10) {
@mariorez
mariorez / configure_docker0.sh
Created January 31, 2017 12:42
Change the IP subnet of Docker's docker0 interface
#!/bin/sh -e
#
# You can run this script directly from github as root like this:
# curl -sS https://gist.githubusercontent.com/fabiorphp/a94e0ea2558b3d10185d6d69d053c2b2/raw/configure_docker0.sh | sudo bash -s - 172.31.0.21/16
#
# * Make sure you replace "192.168.254.0/24" with the network that you want to use
#
# NOTE: This script is intended for Debian / Ubuntu only!
if [ $# -lt 1 ]; then
@mariorez
mariorez / gist:cc166ac47e9a3ab5b89d08c6be1c57f3
Created August 23, 2017 17:03 — forked from SzymonPobiega/gist:5220595
DDD/CQRS/ES/Architecture videos

If you have two days to learn the very basics of modelling, Domain-Driven Design, CQRS and Event Sourcing, here's what you should do:

In the evenings read the [Domain-Driven Design Quickly Minibook]{http://www.infoq.com/minibooks/domain-driven-design-quickly}. During the day watch following great videos (in this order):

  1. Eric Evans' [What I've learned about DDD since the book]{http://www.infoq.com/presentations/ddd-eric-evans}
  2. Eric Evans' [Strategic Design - Responsibility Traps]{http://www.infoq.com/presentations/design-strategic-eric-evans}
  3. Udi Dahan's [Avoid a Failed SOA: Business & Autonomous Components to the Rescue]{http://www.infoq.com/presentations/SOA-Business-Autonomous-Components}
  4. Udi Dahan's [Command-Query Responsibility Segregation]{http://www.infoq.com/presentations/Command-Query-Responsibility-Segregation}
  5. Greg Young's [Unshackle Your Domain]{http://www.infoq.com/presentations/greg-young-unshackle-qcon08}
  6. Eric Evans' [Acknowledging CAP at the Root -- in the Domain Model]{ht
def subscriber1 = Mock(Subscriber)
def subscriber2 = Mock(Subscriber)
Subscriber subscriber1 = Mock()
Subscriber subscriber2 = Mock()
class Publisher {
List<Subscriber> subscribers = []
void send(String message){
subscribers*.receive(message)
}
}
interface Subscriber {
void receive(String message)
}
1 * subscriber1.receive("hello")
| | | |
| | | restrição de argumento
| | restrição de método
| restrição de alvo
restrição por cardinalidade
class Publisher {
private Subscriber subscriber
Publisher(Subscriber subscriber) {
this.subscriber = subscriber
}
String sendAndGetStatus(String message) {
return subscriber.receive(message)
}
subscriber.receive(_) >> "ok"
| | | |
| | | gerador de resposta
| | argumento de restrição
| método de restrição
objeto de restrição
given:
def stack = new Stack()
when:
stack.pop()
then:
thrown(EmptyStackException)
stack.empty