Skip to content

Instantly share code, notes, and snippets.

🎯
Exploring

Wesley Egberto wesleyegberto

🎯
Exploring
View GitHub Profile
@wesleyegberto
wesleyegberto / web.xml
Created Mar 7, 2017
web.xml for Servlet 3.1
View web.xml
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
</web-app>
@wesleyegberto
wesleyegberto / simple-control-value-acessor.ts
Created Sep 9, 2019
Base class to create Angular components
View simple-control-value-acessor.ts
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { forwardRef, Type } from '@angular/core';
/**
* Function to create the basic provider to components which use `ngModel` as required by Angular.
* @param type component type which extends `SimpleControlValueAcessor`
*/
export function createProviders(type: Type<SimpleControlValueAcessor>) {
return [
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => type), multi: true }
@wesleyegberto
wesleyegberto / Dockerfile.dev
Created Apr 26, 2020
Dockerfile to build docker image for development (supports live reload and debug by attaching to the remote JVM)
View Dockerfile.dev
# docker run -d --rm --name my-app --network dkrnet -p 8080:8080 my-app
FROM maven:3.6.3-jdk-13
COPY pom.xml /workspace/
COPY src /workspace/src/
WORKDIR /workspace/
CMD ["mvn", "compile", "quarkus:dev", "-Dquarkus.live-reload.password=123"]
@wesleyegberto
wesleyegberto / monitored_ab_stress.sh
Last active Feb 23, 2020
Script to start a server and run a monitored stress test using Apache Bench
View monitored_ab_stress.sh
# Script to run stress test agains a URL using Apache Bench
# Usage: sh monitored_ab_stress.sh "$CMD" <URL-stress> <output-results-filename>
# where CMD="java -jar my-app.jar"
# script origin at https://github.com/jkremser/micronaut-app-k8s/blob/master/plot-test.sh
#!/bin/bash
echo "=== Monitored Apache Bench Test - Started"
echo $@
URL_TEST=$2
@wesleyegberto
wesleyegberto / profiling.vim
Created Feb 15, 2020
Script to profiling Vim to see what plugin are slowing thing down
View profiling.vim
" Source: https://stackoverflow.com/questions/12213597/how-to-see-which-plugins-are-making-vim-slow
:profile start profile.log
:profile func *
:profile file *
" At this point do slow actions
:profile pause
:noautocmd qall!
@wesleyegberto
wesleyegberto / jupyter_pandas_download_dataframe.py
Created Feb 11, 2020
Function to download a Pandas dataframe from a Jupyter notebook
View jupyter_pandas_download_dataframe.py
def csv_download_link(df, csv_file_name, delete_prompt=True):
"""Display a download link to load a data frame as csv from within a Jupyter notebook"""
df.to_csv(csv_file_name, index=False)
from IPython.display import FileLink
display(FileLink(csv_file_name))
if delete_prompt:
a = input('Press enter to delete the file after you have downloaded it.')
import os
os.remove(csv_file_name)
View rxjs_operators_by_example.md
View api-blueprint-cheat-sheet
## Apiary
# API Blueprint Cheat Sheet
[API Blueprint](http://apiblueprint.org)(.apib) - API description format, plain text, Markdown-like.
## API Blueprint Document Structure
![](./api-blueprint-cheatsheet-image.png)
View Kubernetes Utils
## Cluster
### Cluster info
kubectl cluster-info
kubectl get nodes
kubectl describe node
### Listar os eventos
kubectl get events
@wesleyegberto
wesleyegberto / jwt-expiration.md
Created May 29, 2019 — forked from soulmachine/jwt-expiration.md
How to deal with JWT expiration?
View jwt-expiration.md

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:

You can’t perform that action at this time.