Skip to content

Instantly share code, notes, and snippets.

View wesleyegberto's full-sized avatar
🎯
Exploring

Wesley Egberto wesleyegberto

🎯
Exploring
View GitHub Profile
@wesleyegberto
wesleyegberto / TestThreadStackSize.java
Created May 15, 2022 18:22 — forked from rednaxelafx/TestThreadStackSize.java
Inconsistency of -Xss and -XX:ThreadStackSize in the java launcher
import java.lang.reflect.Field;
import sun.misc.Unsafe;
public class TestThreadStackSize {
private static void crashVM() {
try {
makeSegfault(getUnsafe());
} catch (Exception e) {
// swallow
}

I've been working with Apache Kafka for over 7 years. I inevitably find myself doing the same set of activities while I'm developing or working with someone else's system. Here's a set of Kafka productivity hacks for doing a few things way faster than you're probably doing them now. 🔥

Get the tools

@wesleyegberto
wesleyegberto / jwt-expiration.md
Created May 29, 2019 21:00 — forked from soulmachine/jwt-expiration.md
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
wesleyegberto / git.md
Created December 28, 2018 18:43 — forked from leocomelli/git.md
Lista de comandos úteis do GIT

#GIT

Estados

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

Ajuda

import {
AfterContentInit, Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, Output, PLATFORM_ID,
Renderer2
} from "@angular/core";
import {isPlatformBrowser} from "@angular/common";
@Directive({
selector: '[image-loader]'
})
export class ProgressiveImageLoaderDirective implements AfterContentInit, OnDestroy {
@wesleyegberto
wesleyegberto / Controller.java
Created September 18, 2018 23:56 — forked from bmchild/Controller.java
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 = br.read(contents)) != -1) {
@wesleyegberto
wesleyegberto / static_server.js
Created August 5, 2016 02:02 — forked from ryanflorence/static_server.js
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);