Skip to content

Instantly share code, notes, and snippets.

View netstart's full-sized avatar

Clayton K. N. Passos netstart

View GitHub Profile
@netstart
netstart / AmazonSQSAsyncTest.java
Last active March 21, 2019 21:05
Porque todo programador deve ter conhecimento em diversas linguagens? Levando o conceito de Promisse para o Java ao utilizar CompletableFuture.
import cloud.localstack.utils.PromiseAsyncHandler;
import com.amazon.sqs.javamessaging.SQSConnection;
import com.amazon.sqs.javamessaging.SQSConnectionFactory;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.services.sqs.AmazonSQS;
import com.amazonaws.services.sqs.AmazonSQSAsync;
import com.amazonaws.services.sqs.model.*;
import com.amazonaws.services.sqs.model.Message;
import org.junit.Assert;
import org.junit.BeforeClass;
@netstart
netstart / Braces - EBANX
Last active June 10, 2019 19:42
Braces balanced solution
You are designing a compiler for a C++ program and need to check that braces in any given file are balanced.
Braces in a string are considered to be balanced if the following criteria are met:
All braces must be closed. Braces come in pairs of the form (), {} and []. The left brace opens the pair, and the right one closes it.
In any set of nested braces, the braces between any pair must be closed.
For example, [{}] is a valid grouping of braces but [{]} is not.
Function Description
Complete the function braces in the editor below. The function must return an array of strings where the string at each index i denotes whether or not the braces were balanced in values[i]. The array should consist of strings YES or NO aligned with their indices in values.
@netstart
netstart / start-postgres-database.sh
Created July 31, 2019 13:27
start postgres database using docker
docker run --ulimit memlock=-1:-1 -it --rm=true --memory-swappiness=0 \
--name postgres-quarkus-rest-http-crud -e POSTGRES_USER=restcrud \
-e POSTGRES_PASSWORD=restcrud -e POSTGRES_DB=rest-crud \
-p 5432:5432 postgres:10.5
public class CollectionUtil {
/**
* Distinct by multiple fields – distinctByKeys() function
*
* <PRE>
* List<Record> list = recordsList.stream()
* .filter(distinctByKeys(Record::getId, Record::getName))
* .collect(Collectors.toList());
* </PRE>
@netstart
netstart / date.extensions.ts
Last active October 15, 2019 17:33
prototype extention objects
/**
* Import on top of app.module.ts to use across the application
*
* import './shared/utils/date.prototype.extendions';
*/
declare global {
interface Date {
addDays(days: number, useThis?: boolean): Date;
addSeconds(seconds: number): Date;
@netstart
netstart / .vimrc
Created October 27, 2019 18:07
.vimrc
# tab with 2 spaces
autocmd FileType yaml setlocal ai ts=2 sw=2 et
@netstart
netstart / Password.java
Created March 9, 2020 13:00
Password.java
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
public class Password {
public User changePassword(String newClearPassword) {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
if (!passwordEncoder.matches(newClearPassword, this.getPassword())) {
throw new InvalidPasswordException();
}
@netstart
netstart / keycloak.sh
Created April 29, 2020 18:50 — forked from paoloantinori/keycloak.sh
Keycloak Admin API Rest Example
#!/bin/bash
export TKN=$(curl -X POST 'http://localhost:8080/auth/realms/master/protocol/openid-connect/token' \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=admin" \
-d 'password=admin' \
-d 'grant_type=password' \
-d 'client_id=admin-cli' | jq -r '.access_token')
curl -X GET 'http://localhost:8080/auth/admin/realms' \
@netstart
netstart / gist:427c71bf6ef62532f01ca073b66f7d83
Created May 11, 2020 18:51 — forked from lfryc/gist:aae879ceb5534292e150
Switch WildFly to debug mode in Runtime using jboss-cli
# switch the log level to DEBUG on console
{wildfly}/bin/jboss-cli.sh --connect
[standalone@localhost:9990 /] /subsystem=logging/console-handler=CONSOLE:write-attribute(name=level,value=DEBUG)
[standalone@localhost:9990 /] /subsystem=logging/root-logger=ROOT:write-attribute(name=level,value=DEBUG)
# switch it back to whatever it was initial configuration (here it is INFO)
[standalone@localhost:9990 /] /subsystem=logging/console-handler=CONSOLE:write-attribute(name=level,value=INFO)
[standalone@localhost:9990 /] /subsystem=logging/root-logger=ROOT:write-attribute(name=level,value=INFO)
package matera.spi.messaging;
import org.mockito.Mockito;
import java.lang.reflect.Field;
/**
Example to use:
<PRE>