Skip to content

Instantly share code, notes, and snippets.

View akiatoji's full-sized avatar
🕋
Currently traveling in time.

Aki Atoji akiatoji

🕋
Currently traveling in time.
  • TARDIS
View GitHub Profile
@akiatoji
akiatoji / Particle Boron Setup Notes.md
Last active December 7, 2020 18:45
Misc commands and notes for using Particle IoT devices on a Mac from command line

Particle Boron Setup Notes

Notes for using Particle.io Boron IoT via USB.

Flashing OTA has been a major paint for me as Boron 2G/3G can take forever before connecting to network. During development, it is best to use USB instead of Cell connection to Flash code.

Install Particle CLI

brew install dfu-util
@akiatoji
akiatoji / GCP VPC tunnels.md
Last active September 27, 2021 05:35
Manually creating GCP VPC tunnels

GCP VPC tunnel

Notes from Qwiklabs: Optimizing networks on GCP

Creating VPC tunnels manually. This is not how you connect VPC's in GCP, but this shows what all the pieces are.

Create two VPCs with a subnet and firewall rules

gcloud compute networks create cloud —subnet-mode custom
gcloud compute firewall-rules create cloud-fw —network cloud —allow tcp:22,tcp:5001,udp:5001,icmp
@akiatoji
akiatoji / disable_powermgmt.sh
Created August 8, 2020 14:33
Ubuntu headless disable power management and X startup
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
sudo systemctl set-default multi-user.target
@akiatoji
akiatoji / debug-scroll.md
Created June 2, 2020 15:54 — forked from cuth/debug-scroll.md
Find the elements that are causing a horizontal scroll. Based on http://css-tricks.com/findingfixing-unintended-body-overflow/

Debug Horizontal Scroll

(function (d) {
    var w = d.documentElement.offsetWidth,
        t = d.createTreeWalker(d.body, NodeFilter.SHOW_ELEMENT),
        b;
    while (t.nextNode()) {
        b = t.currentNode.getBoundingClientRect();
 if (b.right > w || b.left < 0) {

This is how I set up GCP VM and my Deep Learning PC for ML and Geo work.

On GCP, I normally use a n1-highmem-4 (4xvCPU, 26GB) with Tesla T4 GPU ($0.4/hr)

My own Deep Learning PC is a Ryzen 3900 (12 cores) 64GB memory and RTX2070 Super ($3K)

Install conda

Install MiniConda.

@akiatoji
akiatoji / Dockerfile
Created December 30, 2019 05:37
Google Edge TPU Retrain container Dockerfile
# The Dockerfile used in https://coral.ai/docs/edgetpu/retrain-classification/ is a bit old and does not work
# Below is the updated Dockerfile to retrain image classifier for use in Coral EdgeTPU
FROM tensorflow/tensorflow:1.11.0-devel-py3
# Install wget (to make life easier below) and editors (to allow people to edit
# the files inside the container)
RUN apt-get update && \
apt-get install -y wget vim emacs nano git && \
@akiatoji
akiatoji / keras_simple_callback.py
Created December 21, 2019 19:36
Simple callback in Keras
# Sometimes EarlyStopping is too much hassle
class myCallback(tf.keras.callbacks.Callback):
def on_epoch_end(self, epoch, logs={}):
if (logs.get('acc') >= 0.998):
print("\nReached 99.8% accuracy so cancelling training!")
self.model.stop_training = True
cb = myCallback()
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
#!/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
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')