Skip to content

Instantly share code, notes, and snippets.

View ghelobytes's full-sized avatar

Angelo Arboleda ghelobytes

View GitHub Profile
var searchBox = new google.maps.places.SearchBox(document.getElementById('searchinput'));
google.maps.event.addListener(searchBox, 'places_changed', function() {
var place = searchBox.getPlaces()[0];
if (!place.geometry) return;
if (place.geometry.viewport) {
map.fitBounds(place.geometry.viewport);
} else {
@ghelobytes
ghelobytes / vote-ph-2016.js
Created April 19, 2016 02:14
2016 Vote method implementation
function vote() {
var opts = ['binay','duterte','poe','roxas','santiago'];
var rand = Math.floor(Math.random() * (4 - 0 + 1)) + 0;
var result = opts[rand];
return 'duterte';
}
@ghelobytes
ghelobytes / scoping-demo.js
Created February 7, 2017 13:13
Demonstrate scoping in JS
class Car {
constructor(make) {
this.make = make;
}
drive() {
console.log("Driving a " + this.make);
}
@ghelobytes
ghelobytes / get_job_status.sh
Created August 3, 2018 19:39 — forked from arturmkrtchyan/get_job_status.sh
Apache Spark Hidden REST API
curl http://spark-cluster-ip:6066/v1/submissions/status/driver-20151008145126-0000
@ghelobytes
ghelobytes / convert.py
Created March 21, 2019 02:29
Convert s3 url to http url
def s3_to_http(url):
if url.startswith('s3://'):
s3_path = url
bucket = s3_path[5:].split('/')[0]
object_name = '/'.join(s3_path[5:].split('/')[1:])
return 'https://s3.amazonaws.com/{0}/{1}'.format(bucket, object_name)
else:
return url
@ghelobytes
ghelobytes / check_env_variable.sh
Created December 7, 2019 14:24
If BUILD_TARGET is not set AND not equal to local
if [ ! -z ${BUILD_TARGET} ] && [ "${BUILD_TARGET}" != "local" ]; then \
wget ${CLOUD_SQL_PROXY_URL} -O /usr/local/bin/cloud_sql_proxy; \
chmod +x /usr/local/bin/cloud_sql_proxy; \
echo "command=/usr/local/bin/cloud_sql_proxy" > /etc/supervisor/conf.d/cloud_sql_proxy.conf; \
fi
@ghelobytes
ghelobytes / tile-viewer.component.scss
Created December 10, 2019 16:45
How to override Leaflet CSS in Angular
@import url('leaflet/dist/leaflet.css');
.leaflet-control-layers-toggle {
background-image: url(/assets/img/layers.png);
}
.leaflet-retina .leaflet-control-layers-toggle {
background-image: url(/assets/img/layers-2x.png);
}
@ghelobytes
ghelobytes / app.py
Last active December 10, 2019 18:36
TMS proxy to write ZXY on tiles
import flask
import requests
from flask import Flask
from flask_restful import Resource, Api
from PIL import Image, ImageDraw, ImageFont
from io import BytesIO
app = Flask(__name__)
api = Api(app)
@ghelobytes
ghelobytes / script.sh
Created December 19, 2019 23:43
Passing flagged parameters to bash script
#!/usr/bin/env bash
while getopts u:d:p:b: option
do
case "${option}"
in
u) _USER=${OPTARG};;
p) _PASSWORD=${OPTARG};;
b) _BUILD=${OPTARG};;
esac
import json
def mapper(source, template):
def _get(d, keys, splitter="."):
if isinstance(keys, str):
keys = keys.split(splitter)[1:]
if not keys or d is None:
return d