Skip to content

Instantly share code, notes, and snippets.


Wesley Egberto wesleyegberto

Block or report user

Report or block wesleyegberto

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View api-blueprint-cheat-sheet
## Apiary
# API Blueprint Cheat Sheet
[API Blueprint]( - API description format, plain text, Markdown-like.
## API Blueprint Document Structure
wesleyegberto /
Created May 29, 2019 — forked from soulmachine/
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

wesleyegberto /
Created May 29, 2019
Spring Boot - RabbitMQ - Request-Reply Pattern
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import java.util.Arrays;
import java.util.Random;
* @author Deus Jeraldy
* @Email:
public class np {
private ObjectMapper jsonMapper = new ObjectMapper();
private ExecutorService executorService = Executors.newFixedThreadPool(5);
public ListenableFuture<Boolean> export(UUID customerId) {
try (PipedInputStream in = new PipedInputStream();
PipedOutputStream pipedOut = new PipedOutputStream(in);
GZIPOutputStream out = new GZIPOutputStream(pipedOut)) {
Stopwatch stopwatch = Stopwatch.createStarted();
wesleyegberto /
Created Dec 28, 2018 — forked from leocomelli/
Lista de comandos úteis do GIT



  • Modificado (modified);
  • Preparado (staged/index)
  • Consolidado (comitted);


View progressiveImageLoader.directive.ts
import {
AfterContentInit, Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, Output, PLATFORM_ID,
} from "@angular/core";
import {isPlatformBrowser} from "@angular/common";
selector: '[image-loader]'
export class ProgressiveImageLoaderDirective implements AfterContentInit, OnDestroy {
wesleyegberto /
Created Sep 18, 2018 — forked from bmchild/
Example of how to wire up a chunked response and how to consume it via angular.
@RequestMapping(value = "/runJobAndGetLogs", method = RequestMethod.GET)
public ResponseEntity<StreamingResponseBody> runJobAndGetLogs() throws IOException {
final InputStream inputStream = someService.runJobAndGetReportProgress();
StreamingResponseBody body = StreamingResponseBody body = (outputStream) -> {
try (BufferedInputStream br = new BufferedInputStream(inputStream)) {
// just copying to the outputstream
byte[] contents = new byte[1024];
int bytesRead = 0;
while ((bytesRead = != -1) {
View jpa-h2-persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns=""
<persistence-unit name="h2" transaction-type="JTA">
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
<property name="hibernate.connection.driver_class" value="org.h2.Driver" />
<property name="" value="update" />
wesleyegberto /
Created Aug 23, 2018
Examples of API response to webapp


  success: boolean,
  data: T,
  error: string, // could be message or i18n code
  errorCode: string, // error code to allow the page to behave according to the error (like show a retry or undo button)
  tracking: string // simple code to allow the user to open a ticket
You can’t perform that action at this time.