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 / Installing mysql2 and nokogiri gems.md
Last active April 6, 2019 19:51
Installing mysql2 and nokogiri gems without hassle on macos

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 February 9, 2019 16:25
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
akiatoji / postgres_process.sql
Last active January 24, 2019 17:10
Hunting down blocking queries in Postgres
-- 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 stack with PlaidML on MacOS.md
Last active May 24, 2020 04:38
Installing ML dev stack on MacOS

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   # look in .condarc and make sure this is the first one 
# 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 21:35
Install XGBoost with GPU Support on AWS GPU Instance

(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 March 27, 2019 08:24
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

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

In GCP Console, create VPC networks named vpn-1 and vpn-2 in us-east1 and europe-west1

In Cloud Shell:

Create VPN gateways

gcloud compute target-vpn-gateways \
create vpn-1 \
@akiatoji
akiatoji / SpeedupSynologyExpansion.sh
Last active February 8, 2018 00:17 — forked from stevenharman/expanding_raid_5_array.sh
Improving RAID Initialization and Expansion time on Synology DS418play
# Initializing DS418play with 4 x 6TB disks
# ssh to NAS as yourseld
# Check the RAID block device and tunable values
cat /proc/mdstat # was md2. Getting about 30M/s
# Get original values:
echo "speed_limit_max: `cat /proc/sys/dev/raid/speed_limit_max`" #=> 200000