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

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
akiatoji / purgemerged.sh
Created Feb 9, 2019
Clean merged branches
View purgemerged.sh
# 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
akiatoji / postgres_process.sql
Last active Jan 24, 2019
Hunting down blocking queries in Postgres
View postgres_process.sql
-- Who is being blocked?
SELECT
pid
, usename
, pg_blocking_pids(pid) AS blocked_by
, query AS blocked_query
FROM pg_stat_activity
WHERE
cardinality(pg_blocking_pids(pid)) > 0
;
@akiatoji
akiatoji / Installing ML dev stack on MacOS.md
Last active Feb 19, 2019
Installing ML dev stack on MacOS
View Installing ML dev stack on MacOS.md

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
View histogram_interpolation.py
# 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
akiatoji / Configure XGBoost GPU on AWS.md
Created May 12, 2018
Install XGBoost with GPU Support on AWS GPU Instance
View Configure XGBoost GPU on AWS.md

(WIP)

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
akiatoji / AddCloudWatchEC2.md
Last active Mar 27, 2019
Add CloudWatch Memory/Disk monitoring to EC2
View AddCloudWatchEC2.md

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.