Skip to content

Instantly share code, notes, and snippets.

View asantos2000's full-sized avatar
🏠
Working from home

Anderson Santos asantos2000

🏠
Working from home
View GitHub Profile
@asantos2000
asantos2000 / KongJwt.md
Last active June 29, 2017 17:46 — forked from martinheld/KongJwt.md
Short example to use JWT with Kong

JWT Kong Example

  • Get and Start Kong and Co
git clone https://github.com/Mashape/docker-kong.git
cd docker-kong/compose
docker-compose up
  • Create Kong API Route
0x646280eB8985523FA050De01e4C51D665F31d5e7
@asantos2000
asantos2000 / NetworkServiceDiscovery.java
Created February 18, 2018 20:00 — forked from icastell/NetworkServiceDiscovery.java
Using Network Service Discovery (Bonjour) in Android
package com.solarfighter.activities;
import java.io.IOException;
import java.net.InetAddress;
import javax.jmdns.JmDNS;
import javax.jmdns.ServiceEvent;
import javax.jmdns.ServiceListener;
import android.content.Context;
@asantos2000
asantos2000 / ResizeImage.java
Created March 5, 2018 18:35 — forked from werbth/ResizeImage.java
Given a jpeg image as InputStream, resize it and return another InputStream.
public static InputStream resizeImage(InputStream inputStream, int width, int height) throws IOException {
BufferedImage sourceImage = ImageIO.read(inputStream);
Image thumbnail = sourceImage.getScaledInstance(width, height, Image.SCALE_SMOOTH);
BufferedImage bufferedThumbnail = new BufferedImage(thumbnail.getWidth(null),
thumbnail.getHeight(null),
BufferedImage.TYPE_INT_RGB);
bufferedThumbnail.getGraphics().drawImage(thumbnail, 0, 0, null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bufferedThumbnail, "jpeg", baos);
return new ByteArrayInputStream(baos.toByteArray());
# Make sure you grab the latest version
curl -OL https://github.com/google/protobuf/releases/download/v3.5.1/protoc-3.5.1-linux-x86_64.zip
# Unzip
unzip protoc-3.5.1-linux-x86_64.zip -d protoc3
# Move protoc to /usr/local/bin/
sudo mv protoc3/bin/* /usr/local/bin/
# Move protoc3/include to /usr/local/include/
# Reference: https://github.com/tzutalin/labelImg/issues/141
# create conda env using python 2.7
conda create -n py2 python=2.7
source activate py2
# install necessary libs using conda install
conda install pyqt=4
conda install libxml2
conda install lxml
#Reference: https://github.com/tzutalin/labelImg
#change en1 (wifi) for your connected network interface
export IP=$(ifconfig en1 | grep inet | awk '$1=="inet" {print $2}')
export DISPLAY=$IP:0
xhost +$IP
docker run -it \
-e DISPLAY=$DISPLAY \
--workdir="/home/$USER" \
@asantos2000
asantos2000 / dredd.sh
Created June 25, 2018 12:51
Run dredd image as a command line
#!/bin/bash
echo '***'
echo 'Root dir is /api'
export MYIP=`ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'`
echo 'Configure URL of tested API endpoint: http://api-srv::<enpoint-port>. Set api-srv to point to your server.'
echo 'This script will set api-srv to docker host machine - ' $MYIP
echo 'Optional. Save this script in your PATH and give it an alias:'
echo "alias dredd='bash ./scripts/dredd.sh'"
echo '***'
@asantos2000
asantos2000 / hook.js
Created June 25, 2018 17:13
Dredd hook sample - Adding apikey to each request
// Writing Dredd Hooks In Node.js
// Ref: http://dredd.org/en/latest/hooks-nodejs.html
var hooks = require('hooks');
hooks.beforeEach(function(transaction) {
hooks.log('before each');
// add query parameter to each transaction here
let paramToAdd = 'api-key=23456';
if (transaction.fullPath.indexOf('?') > -1)
@asantos2000
asantos2000 / drakov.sh
Created June 25, 2018 17:47
Run drakov mock on docker
#!/bin/bash
docker run --rm -it --name drakov-mock -v $PWD/doc:/tmp -p 5000:3000 adsantos/drakov drakov -f api.md --public --watch --discover