Skip to content

Instantly share code, notes, and snippets.

View manoelcampos's full-sized avatar
🙃
Always trying to automate something

Manoel Campos manoelcampos

🙃
Always trying to automate something
View GitHub Profile
@manoelcampos
manoelcampos / SingletonDoubleLock.java
Created August 25, 2025 10:47
Shows the need for a double-checked lock when implementing a Singleton to ensure Thread-Safety
public class Singleton {
private static volatile Singleton instance;
// An id to make it clear multiple instances were created
private final long id = System.nanoTime();
private Singleton(){
// Commented out just to demonstrate the problem with no double-checked locking
//if(instance != null) throw new IllegalStateException("Singleton has already been created");
System.out.println("Creating Singleton with id " + id);
@manoelcampos
manoelcampos / quarkus-vs-spring.adoc
Created July 11, 2025 17:25
Quarkus vs Spring/SpringBoot

Quarkus

Spring / SpringBoot

Geral

Não precisa de uma extensão adicional e nem configuração no IDE para fazer hot reload (já é padrão)

Precisa da dependência Spring DevTools (que pode precisar de configuração no IDE)

Não precisa de uma classe Application para iniciar a app, apesar de poder ser adicionada para configuar a mesma (como usando @ApplicationPath("/api") para definir o caminho raiz da API REST)

Precisa de uma classe Application com um método main e também permite configurar a aplicação.

REST Controllers

Usa anotações da API Jakarta RESTful Web Services

Usa anotações próprias

Sugere o sufixo Resource por convenção para classes contendo endpoints (mais aderente ao estilo REST)

Sugere o sufixo Controller por convenção para classes contendo endpoints (mais aderente ao padrão MVC)

Caminho base dos endpoints de um resource/controller são definidos como por exemplo, @Path("/product")

Caminho base dos endpoints de um

@manoelcampos
manoelcampos / Movimentacao.java
Created April 12, 2024 18:50
Mostra como implementar o método clone (type-unsafe) em uma classe Java simplesmente incluindo um implements Cloneable
public class Movimentacao implements Cloneable {
private int id;
private String descricao;
public Movimentacao(int id, String descricao) {
this.descricao = descricao;
this.id = id;
}
@Override
@manoelcampos
manoelcampos / fly.log
Created December 12, 2023 19:37
fly.logs
# Logs after deploy with min_machines_running = 0
2023-12-12 15:55:44.753 [competeaqui_fly_io_logs] [INFO] gru 8522 6e82d2e7c020e8 competeaqui-staging 2023-12-12T18:55:44.753Z INFO 314 --- [ main] b.c.competeaqui.CompeteAquiApplication : Started CompeteAquiApplication in 15.256 seconds (process running for 16.305)
2023-12-12 16:03:21.036 [competeaqui_fly_io_logs] [INFO] gru 8522 6e82d2e7c020e8 competeaqui-staging Downscaling app competeaqui-staging from 1 machines to 0 machines, stopping machine 6e82d2e7c020e8 (region=gru, process group=app)
2023-12-12 16:03:21.036 [competeaqui_fly_io_logs] [INFO] gru 8522 6e82d2e7c020e8 competeaqui-staging Downscaling app competeaqui-staging from 1 machines to 0 machines, stopping machine 6e82d2e7c020e8 (region=gru, process group=app)
2023-12-12 16:03:21.039 [competeaqui_fly_io_logs] [INFO] gru 8522 6e82d2e7c020e8 competeaqui-staging INFO Sending signal SIGINT to main child process w/ PID 314
2023-12-12 16:03:21.039 [competeaqui_fly_io_logs] [INFO] gru 8522 6
@manoelcampos
manoelcampos / valid.lua
Created January 4, 2023 20:56
Módulo para validação de dados em Lua
local _G, table, string, math, tonumber, tostring, type, print = _G, table, string, math, tonumber, tostring, type, print
---Módulo para validação de dados
--@author Manoel Campos da Silva Filho - http://manoelcampos.com
--@version 0.2
module "valid"
---Divide uma string utilizando um determinado separador existente nela.
--Fonte: http://lua-users.org/wiki/SplitJoin
--@param self String a ser dividida
@manoelcampos
manoelcampos / CloudSimExampleToCompareWithCloudSimPlus.java
Last active May 18, 2023 22:04
Examples comparing CloudSim and CloudSim Plus simulation frameworks
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerTimeShared;
import org.cloudbus.cloudsim.Datacenter;
import org.cloudbus.cloudsim.DatacenterBroker;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
@manoelcampos
manoelcampos / DataFrameRowColRemoval.java
Created October 17, 2020 13:51
d3x-morpheus DataFrame row/column removal issue
import com.d3x.morpheus.array.Array;
import com.d3x.morpheus.frame.DataFrame;
import com.d3x.morpheus.frame.DataFrameValue;
import java.util.List;
public class DataFrameRowColRemoval {
public static void main(String[] args) {
new DataFrameRowColRemoval();
}
@manoelcampos
manoelcampos / apt-get
Last active March 27, 2020 12:33
A shell script to run macOS homebrew as if it was the Debian/Ubuntu's apt-get command, just because "why not?" 😂
#!/bin/bash
# Runs macOS homebrew as if it was the Debian/Ubuntu's apt-get command,
# just because "why not?"
# Usage:
# sudo apt-get parameters
# or apt-get parameters
# Example: sudo apt-get install git
#
# Move the script to /usr/local/bin
@manoelcampos
manoelcampos / netbeans-macos-app-packager.sh
Last active June 4, 2019 00:08
A shell script to create a NetBeans.app package for macOS from the NetBeans binaries
#!/bin/bash
clear
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then
echo "
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a dir.
Usage: `basename "$0"` netbeans_dir
- netbeans_dir: The directory containing all the files for a specific NetBeans release.
@manoelcampos
manoelcampos / bot.sh
Last active January 25, 2019 16:58
Sends a key and mouse click repeatedly, at a defined time interval
#!/bin/bash
# Sends a key and mouse click repeatedly, at a defined time interval.
# Author - Manoel Campos
clear
#Checks if xdotool command is installed. If not, installs it
xdotool -v 2>/dev/null || echo 'Installing required tools...' && sudo apt-get install xdotool -y > /dev/null
echo ''