Skip to content

Instantly share code, notes, and snippets.


Danilo Batista de Queiroz danilobatistaqueiroz

  • São Paulo, SP, Brasil
View GitHub Profile
View kibana_log.json
"type": "response",
"@timestamp": "2021-09-12T22:53:33+00:00",
"tags": [],
"pid": 1216,
"method": "get",
"statusCode": 400,
"req": {
"url": "/api/monitoring/v1/elasticsearch_settings/check/nodes",
"method": "get",


To me, legacy code is simply code without tests. I’ve gotten some grief for this definition. What do tests have to do with whether code is bad? To me, the answer is straightforward, and it is a point that I elaborate throughout the book: Code without tests is bad code. It doesn’t matter how well written it is; it doesn’t matter how pretty or object-oriented or well-encapsulated it is. With tests, we can change the behavior of our code quickly and verifiably. Without them, we really don’t know if our code is getting better or worse.

Chapter 1 Changing Software

Four Reasons to Change Software: For simplicity’s sake, let’s look at four primary reasons to change software.

danilobatistaqueiroz / cluster-kind.bash
Last active Aug 13, 2020
cluster kind using local registry and an ingress configured
View cluster-kind.bash
set -o errexit
# create registry container unless it already exists
running="$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)"
if [ "${running}" != 'true' ]; then
docker run \
-d --restart=always -p "${reg_port}:5000" --name "${reg_name}" \
danilobatistaqueiroz /
Created Jul 16, 2020 — forked from wojteklu/
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.

General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules


Configuring a Maven project to run test coverage with SonarQube, Jacoco

Install the SonarQube server, go the download page, choose the community edition:


Add Jacoco plugin in POM.xml:

danilobatistaqueiroz /
Last active May 4, 2021
Redis vs AMQP vs JMS vs Kafka


JMS: only java, it is a specification
AMPQ: universal, it is a protocol, it is open standard for messaging

JMS doesn't define a protocol.

JMS is an API and AMQP is a protocol.

AMQP supports 4 message models: Direct, Fanout, Topic, Headers

danilobatistaqueiroz /
Created Feb 11, 2020 — forked from deanhunt/
Notes from Martin Fowler's "Refactoring"

Refactoring, Fowler

Five or six years ago I was working on an essay about refactoring CSS. I didn't do that, but I did find these notes while working on something new. Hope they're useful! —Dean

p7 "When you find you have to add a feature to a program, and the program's code is not structured in a convenient way to add the feature, first refactor the program to make it easy to add the feature, then add the feature."


danilobatistaqueiroz /
Created Jan 28, 2020 — forked from bzerangue/
Disable Sleep/Suspend and WiFi in Ubuntu 16.04 LTS

On Ubuntu 16.04 LTS, I successfully used the following to disable suspend:

sudo systemctl mask

And this to re-enable it:

sudo systemctl unmask

danilobatistaqueiroz /
Last active Jan 25, 2021
Startup scripts for bash shell

Startup scripts for bash shell


Interactive shell: When reads commands from user input on a tty (prompt).
--interactive sources --> /etc/bash.bashrc and ~/.bashrc
Login shell: When a login prompt is required.
--login sources --> /etc/profile and ~/.profile

Interactive non-login shell: Open a new terminal.
--it sources ~/.bashrc

View Refactoring | Mente

Refatorar é bom para aprender OO

Uncle Bob blogou no Clean Coder sobre uns code reviews que ele fez do código (e das refatorações) de um cara chamado John MacIntyre.

Uncle Bob criticou a conclusão do cara de que refatoração não vale a pena para projetos reais: refatoração é uma maneira efetiva de evitar que o código apodreça e fique difícil de manter.

O que achei de mais interessante sobre o post do Uncle Bob é que ele pegou o código inicial do cara e foi fazendo pequenas refatorações, no estilo Baby Steps. No final, acabou melhorando drasticamente a estrutura do código e tornando-o muito mais extensível. O exemplo é bem pequeno mas, mesmo assim, houve uma melhora significativa.
O código inicial: