Skip to content

Instantly share code, notes, and snippets.

View sjpuas's full-sized avatar

Sergio sjpuas

View GitHub Profile
/** to use in https://iniciativas.chileconvencion.cl/m/iniciativa_popular/# **/
let propuestas = [];
$("#iniciativas>.card").each((i,e) => {
let propuesta = {
textId: $(e).children("h2").text().trim(),
title: $(e).children("h1").text().trim(),
text: $(e).children("p").text().trim(),
votes: $(e).data("apoyos")
};
propuestas.push(propuesta);
@sjpuas
sjpuas / docker-compose.yml
Created June 5, 2018 13:36
Kong CE Docker Compose
version: '2.1'
services:
kong-database:
image: postgres:9.5
environment:
- POSTGRES_USER=kong
- POSTGRES_DB=kong
healthcheck:
@sjpuas
sjpuas / docker-compose.yml
Last active September 28, 2017 23:06
Example Docker Stack
version: '3.2'
services:
proxy:
image: containous/traefik:latest
command: --web --docker --docker.swarmmode --docker.watch --logLevel=DEBUG
ports:
- 80:80
- 8080:8080
@sjpuas
sjpuas / docker-compose.yml
Created January 12, 2017 23:48
docker-compose v2.1 healthcheck and service_healthy
version: '2.1'
services:
web:
image: nginx:alpine
depends_on:
db:
condition: service_healthy
db:
image: redis:alpine
healthcheck:
@sjpuas
sjpuas / Base64Servlet.java
Created August 13, 2013 02:41
Servlet for decode base64 of images. You would change content type for others type.
package cl.puas.web.servlet;
import sun.misc.BASE64Decoder;
import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
@sjpuas
sjpuas / GeoUtils.java
Created December 7, 2012 15:41
Calculate Diameter for 2 points(lon, lat )
private static final Double EARTH_RADIUS = 6371D; // KM
public static Double getDiametro(Double latFirst, Double lonFirst, Double latMiddle, Double lonMiddle) {
Double dLat = Math.toRadians(latMiddle - latFirst);
Double dLon = Math.toRadians(lonMiddle - lonFirst);
Double lat1 = Math.toRadians(latFirst);
Double lat2 = Math.toRadians(latMiddle);