Skip to content

Instantly share code, notes, and snippets.

View danilobatistaqueiroz's full-sized avatar

Danilo Batista de Queiroz danilobatistaqueiroz

View GitHub Profile

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 November 8, 2023 09:53
Redis vs AMQP vs JMS vs Kafka

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 February 11, 2020 17:22 — forked from deanhunt/fowler.md
Notes from Martin Fowler's "Refactoring"

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 January 28, 2020 19:23 — forked from bzerangue/disable-suspend.md
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 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 January 25, 2021 00:07
Startup scripts for bash shell

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

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:

@danilobatistaqueiroz
danilobatistaqueiroz / fib.py
Created September 26, 2019 00:46 — forked from soeirosantos/fib.py
a bit of Fibonacci with Python
def recursive_fib(n):
if n <= 1:
return n
return recursive_fib(n - 2) + recursive_fib(n - 1)
def memoized_fib(n):
f = [0] * (n + 1)
f[0] = 0
f[1] = 1
@danilobatistaqueiroz
danilobatistaqueiroz / npm_without_root
Created July 16, 2019 14:09
running npm without root
https://www.competa.com/blog/how-to-run-npm-without-sudo/
npm config set prefix ~/.npm
# open your .bashrc (Linux) or .bash_profile (Mac) file for editing:
nano ~/.bashrc # for Linux
# or...
nano ~/.bash_profile # for Mac if you haven't created a .bashrc file
# add these lines:
function cnpj(s) {
let cnpj = s.replace(/[^\d]+/g, '')
// Valida a quantidade de caracteres
if (cnpj.length !== 14)
return false
// Elimina inválidos com todos os caracteres iguais
if (/^(\d)\1+$/.test(cnpj))
return false
@danilobatistaqueiroz
danilobatistaqueiroz / mongoDB.py
Created May 26, 2019 19:00 — forked from cjgiridhar/mongoDB.py
CRUD for MongoDB with Pymongo
import pymongo
from pymongo import Connection
conn = Connection()
db = conn['myDB']
collection = db['language']
#Creating a collection
db.language.insert({"id": "1", "name": "C", "grade":"Boring"})
db.language.insert({"id": "2", "name":"Python", "grade":"Interesting"})