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
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
wesleyegberto / backup_tracks_using_spotify_api.json
Last active Aug 3, 2018
Backup saved tracks from Spotify
View backup_tracks_using_spotify_api.json
$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" "$i" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $token" >> musics.json;
wesleyegberto /
Created Jul 9, 2018
Example of script to automatically stash updates, checkout and merge a branch and then commit the changes
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'
git push heroku deploy:master # Deploy to Heroku
wesleyegberto /
Created Jun 29, 2018
Script to generate traffic
# Source:
#set -x
while true
END=$((RANDOM % 10 +1 ))
echo $END
for i in `seq $END`
View Kubernetes Utils
## Cluster
### Cluster info
kubectl cluster-info
kubectl get nodes
kubectl describe node
### Listar os eventos
kubectl get events
wesleyegberto / Context.xml
Created Apr 8, 2017
CDI 1.2/2.0 on Tomcat
View Context.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- webapp/META-INF/Context.xml -->
<Manager pathname=""/>
<Resource name="BeanManager"
View AngularJS-sublime-package.sublime-settings
"disable_default_directive_completions": false
wesleyegberto / web.xml
Created Mar 7, 2017
web.xml for Servlet 3.1
View web.xml
<web-app xmlns=""
You can’t perform that action at this time.