Skip to content

Instantly share code, notes, and snippets.

View roberto-filho's full-sized avatar

Roberto Welzel Filho roberto-filho

View GitHub Profile
@roberto-filho
roberto-filho / unit-testing-workshop.md
Last active June 28, 2019 14:30
Unit Testing Workshop

UNIT TESTING

O QUE SÃO TESTES UNITÁRIOS? (15 min)

  1. Testes de unidade
  2. Testes de integração
  3. FIRST - (Fast, Independent, Repeatable, Self-verifying, Timely) link

POR QUÊ SÃO IMPORTANTES? (10 min)

  1. Desenho testável - pensar sobre design
  2. Retorno antecipado (early feedback)
  3. São como documentação
@roberto-filho
roberto-filho / months_between.sql
Last active July 3, 2018 15:27
Postgresql function to calculate the months between two dates.
CREATE OR REPLACE FUNCTION months_between(
date,
date)
RETURNS integer AS
$BODY$
DECLARE
dt_final date;
BEGIN
dt_final := $2;
@roberto-filho
roberto-filho / subir-versao.sh
Last active May 21, 2016 03:54
Comando para subir a versão dos pom.xmls e dos XMLs
#!/bin/bash
# Pega as versões da linha de comando
old=$1
new=$2
# Executa o comando que faz a substituição do conteúdo dos arquivos
## <version>2.0.0</version>
## version="2.0.0"
sed -e "s/<version>$old<\/version>/<version>$new<\/version>/" \
-e "s/version=\"$old\"/version=\"$new\"/" \
@roberto-filho
roberto-filho / NFeBuildAllCacerts.java
Created May 19, 2016 13:13
Snippet para criar uma keystore com todos os certificados dos serviços Web NF-e
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.KeyStore;
import java.security.MessageDigest;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
@roberto-filho
roberto-filho / create-gitlab-runners.sh
Created April 26, 2016 22:31
Commands to use gitlab runner
# This one is to create a new runner with docker support
sudo sudo docker run -d --name runner --restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /srv/gitlab-runner/config:/etc/gitlab-runner \
gitlab/gitlab-runner:latest
# This one is to register a runner with services
sudo docker exec -it gitlab-runner gitlab-runner register \
--url "https://gitlab.com/" \
--registration-token "PROJECT_REGISTRATION_TOKEN" \
@roberto-filho
roberto-filho / ubuntu-multiarch.md
Created October 15, 2015 17:18
Installing multiarch

Command to use 32bit packages on linux

sudo apt-get install gcc-4.7-multilib
@roberto-filho
roberto-filho / Snippet.java
Created September 1, 2015 12:35
Percorrendo um multimap
// O multimap
Multimap<CFOP, BigDecimal> valores;
for(CFOP cfop : valores.keySet()) {
List<BigDecimal> total = valores.get(cfop);
BigDecimal soma = Helper.sum(total);
// Obtemos o valor do cfop
}
@roberto-filho
roberto-filho / fiscal.properties
Created August 3, 2015 11:22
Arquivo para inicialização do sistema.
#Fri Jul 31 11:06:38 BRT 2015
db.url=jdbc\:postgresql\://192.168.0.183/dev
db.output=false
db.usuario=postgres
db.senha=admin
login.usuario=f
@roberto-filho
roberto-filho / empty-tables.sql
Created August 1, 2015 14:03
Descobrir as tabelas sem registros
SELECT relname
FROM pg_catalog.pg_class
WHERE relpages = 0
AND NOT relisshared
AND NOT relhassubclass
AND relkind = 'r'
AND relnamespace <> (SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog');
@roberto-filho
roberto-filho / ServiceCreation.java
Created May 22, 2015 15:01
Service creation with eclipse plugins
/*
* Para cadastrar um serviço, chame esse método no "start" da classe plugin
*/
plugin.getBundle().getBundleContext().registerService(ExternalAPI.class, new ConcreteExternalAPI(), null);
/*
* Para obter o serviço registrado por outro plugin
*/