Skip to content

Instantly share code, notes, and snippets.

Working from home

Aki Atoji akiatoji

Working from home
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
resource "google_compute_network" "vpc" {
name = "${format("%s","${}-${var.env}-vpc")}"
auto_create_subnetworks = "false"
routing_mode = "GLOBAL"
resource "google_compute_firewall" "allow-internal" {
name = "${}-fw-allow-internal"
network = "${}"
allow {
protocol = "icmp"
variable "project" {
default = "gcp-project-id"
variable "region1" {
default = "us-west2"
variable "region2" {
default = "us-central1"
provider "google" {
project = "${var.project}"
credentials = "${file("your_service_acct.json")}"
provider "google-beta" {
project = "${var.project}"
credentials = "${file("your_service_acct.json")}"
akiatoji / Installing mysql2 and nokogiri
Last active Apr 6, 2019
Installing mysql2 and nokogiri gems without hassle on macos
View Installing mysql2 and nokogiri

Suppress libxml2 version warning. Sometimes the wrong libxml2 version keeps getting loaded.

brew install libxml2 libxslt

Let's say above installed libxml2 2.9.9_2

bundle config --local build.nokogiri "--with-xml2-lib=/usr/local/Cellar/libxml2/2.9.9_2/lib --with-xml2-include=/usr/local/Cellar/libxml2/2.9.9_2/include"
akiatoji /
Created Feb 9, 2019
Clean merged branches
# I always forget how to do this
git branch -r --merged | grep -v master | sed 's/origin\///' | xargs -n 1 git push --delete origin
akiatoji / postgres_process.sql
Last active Jan 24, 2019
Hunting down blocking queries in Postgres
View postgres_process.sql
-- Who is being blocked?
, usename
, pg_blocking_pids(pid) AS blocked_by
, query AS blocked_query
FROM pg_stat_activity
cardinality(pg_blocking_pids(pid)) > 0
akiatoji / Installing ML dev stack on
Last active Feb 19, 2019
Installing ML dev stack on MacOS
View Installing ML dev stack on

Install conda

Install MiniConda.

Install dependencies

These are the go-to packages I use for Machine Learning/Geo/NLTK work.

conda config --add channels conda-forge
# Load the image into an array: image
image = plt.imread('some.jpg')
# Flatten the image into 1 dimension: pixels
pixels = image.flatten()
# Generate a cumulative histogram
cdf, bins, patches = plt.hist(pixels, bins=256, range=(0,256), normed=True, cumulative=True)
new_pixels = np.interp(pixels, bins[:-1], cdf*255)
akiatoji / Configure XGBoost GPU on
Created May 12, 2018
Install XGBoost with GPU Support on AWS GPU Instance
View Configure XGBoost GPU on


Install mesa-libGL-devel Install openmpi openmpi-devel Make sure you don't have newer GCC/G++ (must be 4.8.5) Rmove default install Cmake Download Cmake 3.2 or higher and build install Download xgboost Build xgboost

akiatoji /
Last active Mar 27, 2019
Add CloudWatch Memory/Disk monitoring to EC2

AWS EC2 Memory and Disk monitoring/alert

AWS kind of sucks when it comes to monitoring Memory and Disk usage on EC2, as in they don't provide it out of the box. AWS instead gives you a set of perl scripts to do this via CloudWatch custom metrics.

Details are here:

Monitoring Memory and Disk Metrics for Amazon EC2 Linux Instances

The following is the actual steps used to get Disk/Memory stats into CloudWatch

You can’t perform that action at this time.