Skip to content

Instantly share code, notes, and snippets.

View askldjd's full-sized avatar

Alan Ning askldjd

View GitHub Profile
@askldjd
askldjd / gist:29a1234163a13d3bd76e736fa5f125b8
Created May 18, 2018 02:50
Force cloud init to run in Ubuntu AWS
rm -rf /var/lib/cloud/sem/* /var/lib/cloud/instance /var/lib/cloud/instances/*
cloud-init init
cloud-init modules -m final
@askldjd
askldjd / debug-ansible.md
Created April 27, 2018 01:09
Debugging ansible

Best way to debug ansible is to dump the entire state out.

This is a play that would do the job

- name: Debug
  hosts: localhost
  connection: local
  tasks:
  - name: Display all variables/facts known for a host
 debug:
@askldjd
askldjd / gist:ba287178a736b2865f0255aeba879601
Created April 26, 2018 15:46
How to break up certs into 64 char
Say you have a test.pem file all in one line, how to make it into a proper pem file?
```
fold -w64 test.pem
```
add to the beginning and end of buffer
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
@askldjd
askldjd / 100-million-blog-draft.md
Last active December 23, 2017 04:37
Draft of the 100 million dollar blog post

For the past year, the VA Enterprise Cloud team (VAEC) has been coordinating a massive effort to migrate the VA's on-premise applications to the cloud. By taking advantage of cloud technologies, VA is looking to reduce IT costs and to improve the scalablility and reliability of its applications. Through Vets.gov and Caseflow, we the Digital Service team at the VA is an early adopter of AWS within the agency. With our experience in AWS Govcloud, the Digital Service SRE team was consulted to review the VA's Initial Cloud Reference Architecture for AWS. During the one hour meeting, we spotted an opportunity to streamline the architecture to save over a 100 million dollars over 10 years.

The Cloud Migration

The VA is a massive organization with over 377,000 employees. There are nearly 600 on-p

@askldjd
askldjd / jiffies-blog-post.md
Created June 21, 2017 01:21
jiffies-blog-post

In the VA Digital Service's Appeals Modernization effort, we developed a React on Rails applications called Caseflow. We follow the industry's best practices with Continuous Integration and Continuous Deployment (CI/CD) using Travis and Jenkins. Our team develops features quickly, and deploy changes daily to production environment. However, our deployment pipeline was not always smooth. This is a story of a bug that haunted us for months.

Five minutes of actions

Around January 2017, deploying Caseflow to production environment was an exhausting event. Our deployment pipeline uses the Immutable Server Pattern to create an Amazon Machine Image (AMI), and performs rolling deploys onto our AWS AutoScaling group. The newly deployed EC2 instances would serve traffic beautifully for five minutes, and the servers would tied up all its threads on queri

@askldjd
askldjd / index.js
Last active May 4, 2017 22:40
Node.js S3 Streamer for Efolder Express
// This Express server is designed to support Efolder-Express Rails server to
// allow streaming data from S3 without first saving a local copy on disk.
const express = require('express')
const app = express()
const AWS = require('aws-sdk');
AWS
.config
.update({region: 'us-gov-west-1'});
@askldjd
askldjd / inventory.py
Created March 17, 2017 20:34
Simple ansible inventory without ec2.py
#!/usr/bin/python
import boto3
import json
import os
client = boto3.client('ec2')
# filter.json
# [
@askldjd
askldjd / sh
Created January 30, 2017 21:52
Dump all threads
#!/bin/bash
for i in {0..64}
do
echo displaying $i thread
rbtrace -p 2475 -e "Thread.list[$i].backtrace.join('\n')"
done
Go to line
- Esc
- Line number
- shift-g
Auto complete
- Ctrl-n
Multi-line-edit
- Esc
@askldjd
askldjd / analyze.rb
Created January 11, 2017 18:45
Perform a top level analysis on the ruby heap dump.
require 'json'
class Analyzer
def initialize(filename)
@filename = filename
end
def analyze
data = []
File.open(@filename) do |f|
f.each_line do |line|