Skip to content

Instantly share code, notes, and snippets.

View mariorez's full-sized avatar

Mario Rezende mariorez

View GitHub Profile
#To watch the contents of a directory change
watch -d ls -l
# Paste this function in your ".bashrc" to enable the "pomo" command in your terminal
# POMODORO Terminal:
function pomo {
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo -e "POMODORO Terminal\n"
echo "usage: pomo 25 minutes timeout"
echo -e " or: pomo [options] see options below\n"
echo "Options:"
echo " short: 05 minutes timeout"
echo " long: 15 minutes timeout"
# Execute command as user
function uexec {
if [ $# -eq 1 ]; then
eval "(su - '$1')"
fi
if [ $# -eq 2 ]; then
eval "(su - '$1' -c '${2}')"
fi
}
@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) {
### GIT DIRTY
source /usr/share/git/completion/git-prompt.sh
function _git_prompt() {
local git_status="`git status -unormal 2>&1`"
if ! [[ "$git_status" =~ Not\ a\ git\ repo ]]; then
if [[ "$git_status" =~ nothing\ to\ commit ]]; then
local signal='\[\e[0;1;32m\] ✔\[\e[0m\]'
elif [[ "$git_status" =~ nothing\ added\ to\ commit\ but\ untracked\ files\ present ]]; then
local signal='\[\e[0;1;31m\] ✘\[\e[0m\]'
@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
@Test
void validateUserRegistration() {
// setup
String name = "Fulano"
int age = 20
String email = "fulano@mail.test"
// execute
User user = UserService().register(name, age, email)
def 'Validate user registration'() {
given: 'user data'
def name = "Fulano"
def age = 20
def email = "fulano@mail.test"
when: 'register the user'
def user = UserService().register(name, age, email)
then:
name == 'Fulano'
name != 'Beltrano'
age >= 20
age < 100