Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Aki Atoji akiatoji

🏠
Working from home
  • TARDIS
Block or report user

Report or block akiatoji

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 Setup OSRM route server for North America on EC2.md

OSRM North America route server on EC2

Overview

OSRM route server is an extremely useful tool for getting the driving distance/time through multiple locations. The route server requires data that has to be downloaded and processsed before it can be used to serve routes from.

Processing OSRM data for large region like North America can be a real challenge due to memory and disk size requirements. It's also really time consuming. If you cut and try from scratch, you will repeatedly run into some constraints and fail after hours of running.

The following are summary notes from trying this with eventual success.

@akiatoji
akiatoji / Clojure_on_RaspberryPi_OSX.md
Last active Jun 25, 2019
Running Clojure on Raspberry Pi with OS X
View Clojure_on_RaspberryPi_OSX.md

Clojure on Raspberry Pi with OS X

"Clojure running on Raspberry Pi" sounded so cool that I just had to give it a try.

Install JDK

  • Download ARM JDK from Oracle and instlal on Raspberry Pi
  • Change visudo to contain the following
View Google Cloud Platform Load Balancing.md

In Cloud Console:

  • Create load balancer
  • Create Compute instances with network tag to use as load balancer target.
  • Create health check

Create target pool

gcloud compute target-pools create extloadbalancer  --region $MY_REGION --http-health-check webserver-health
@akiatoji
akiatoji / _sns_description
Last active Jun 13, 2019
AWS SNS Sample code.
View _sns_description
Notes on how to use AWS SNS:
1. Subscribe an HTTP endpoint (i.e. http://myhost/sns_endpoint) on AWS Console
2. AWS will send subscription confirmation right away
3. SNS_controller responds to subscription confirmation by sending confirmation using Fog.
4. Once AWS is happy, you can start sending notifications to your end point via SNS.
View gunicorn_dockerfile.sh
ENV APP_HOME /app ENV PORT 8080 CMD exec gunicorn --bind 0.0.0.0:$PORT \
--workers 1 --chdir $APP_HOME --threads 1 app:app
View encrypting_secrets.sh
#!/usr/bin/env bash
gcloud services enable cloudkms.googleapis.com
KEYRING=keyring
KEY=secrets
gcloud kms keys list --location global --keyring $KEYRING
if [[ $? -ne 0 ]]; then
gcloud kms keyrings create ${KEYRING} --location global
View encrypted_flask_config.py
def load_from_encrypted(app):
tempname = str(uuid.uuid4())
encrypted_file_name = "secrets-%s.cfg.encrypted" % tempname
decrypted_file_name = "secrets-%s.cfg.decrypted" % tempname
storage_client = storage.Client()
bucket = storage_client.get_bucket('vault')
blob = bucket.blob('secrets.cfg.encrypted')
blob.download_to_filename(encrypted_file_name)
View load_flask_secrets_from_bucket.py
import os
import uuid
from google.cloud import storage, kms_v1
def load(app):
config_file_name = "secrets-%s.cfg" % str(uuid.uuid4())
storage_client = storage.Client()
bucket = storage_client.get_bucket('vault')
View overlay_flask_config.py
from my_lib import secrets
app = Flask(__name__)
# Load default config
app.config.from_pyfile('config/default_settings.py')
# Overlay secure secrets
secrets.load(app)
View create_geo_from_lat_lon.sql
create table zones.locations_geo
as
(
select name, value, ST_GeogPoint(lng, lat) point
from `akis-geoproject.zones.locations`
)
You can’t perform that action at this time.