Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

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 np.java
import java.util.Arrays;
import java.util.Random;
/**
*
* @author Deus Jeraldy
* @Email: deusjeraldy@gmail.com
*/
public class np {
View ExportJsonFile.java
private ObjectMapper jsonMapper = new ObjectMapper();
private ExecutorService executorService = Executors.newFixedThreadPool(5);
@Async
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
wesleyegberto / git.md
Created Dec 28, 2018 — forked from leocomelli/git.md
Lista de comandos úteis do GIT
View git.md

#GIT

Estados

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

Ajuda

View progressiveImageLoader.directive.ts
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 Sep 18, 2018 — forked from bmchild/Controller.java
Example of how to wire up a chunked response and how to consume it via angular.
View Controller.java
@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) {
View jpa-h2-persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="h2" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
<property name="hibernate.connection.driver_class" value="org.h2.Driver" />
<property name="hibernate.hbm2ddl.auto" value="update" />
@wesleyegberto
wesleyegberto / api-response-examples.md
Created Aug 23, 2018
Examples of API response to webapp
View api-response-examples.md

Template

{
  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
}
@wesleyegberto
wesleyegberto / backup_tracks_using_spotify_api.json
Last active Aug 3, 2018
Backup saved tracks from Spotify
View backup_tracks_using_spotify_api.json
# https://developer.spotify.com/console/get-current-user-saved-tracks
$token="<Your Token>"
# API limits 50 tracks per request, so I paginate my 1100+ musics here
for i in `seq 0 50 1300`;
do curl -k -X "GET" "https://api.spotify.com/v1/me/tracks?limit=50&offset=$i" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $token" >> musics.json;
done;
@wesleyegberto
wesleyegberto / stash_merge_commit_push.sh
Created Jul 9, 2018
Example of script to automatically stash updates, checkout and merge a branch and then commit the changes
View stash_merge_commit_push.sh
#!/bin/bash
set -o errexit # Exit on error
git stash save 'Before deploy' # Stash all changes before deploy
git checkout deploy
git merge master --no-edit # Merge in the master branch without prompting
npm run build # Generate the bundled Javascript and CSS
if $(git commit -am Deploy); then # Commit the changes, if any
echo 'Changes Committed'
fi
git push heroku deploy:master # Deploy to Heroku
@wesleyegberto
wesleyegberto / traffic_generator.sh
Created Jun 29, 2018
Script to generate traffic
View traffic_generator.sh
#!/bin/sh
# Source: https://github.com/pilhuhn/microprofile-demo/blob/mpm-2.0-testing/parallel_count_traffic_generator.sh
#set -x
while true
do
END=$((RANDOM % 10 +1 ))
echo $END
for i in `seq $END`
You can’t perform that action at this time.