Skip to content

Instantly share code, notes, and snippets.

Avatar

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",
View working_effectively_with_legacy_code.md

WORKING EFFECTIVELY WITH LEGACY CODE

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
danilobatistaqueiroz / cluster-kind.bash
Last active Aug 13, 2020
cluster kind using local registry and an ingress configured
View cluster-kind.bash
#!/bin/sh
set -o errexit
# create registry container unless it already exists
reg_name='kind-registry'
reg_port='5000'
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
danilobatistaqueiroz / clean_code.md
Created Jul 16, 2020 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin
View clean_code.md

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

View sonar_jacoco.md

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

Install the SonarQube server, go the download page, choose the community edition:
https://www.sonarqube.org/downloads/

sonarqube_download_page

Add Jacoco plugin in POM.xml:

<build>
@danilobatistaqueiroz
danilobatistaqueiroz / amqp_vs_jms.md
Last active May 4, 2021
Redis vs AMQP vs JMS vs Kafka
View amqp_vs_jms.md

AMQP vs JMS

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
danilobatistaqueiroz / fowler.md
Created Feb 11, 2020 — forked from deanhunt/fowler.md
Notes from Martin Fowler's "Refactoring"
View fowler.md

Refactoring, Fowler

http://martinfowler.com/books/refactoring.html

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."

p7

@danilobatistaqueiroz
danilobatistaqueiroz / disable-suspend.md
Created Jan 28, 2020 — forked from bzerangue/disable-suspend.md
Disable Sleep/Suspend and WiFi in Ubuntu 16.04 LTS
View disable-suspend.md

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

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

And this to re-enable it:

sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target

@danilobatistaqueiroz
danilobatistaqueiroz / bash_shell_scripts.md
Last active Jan 25, 2021
Startup scripts for bash shell
View bash_shell_scripts.md

Startup scripts for bash shell

TL;DR

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 iniciante.md

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: