Skip to content

Instantly share code, notes, and snippets.

@sjlu
sjlu / Migrating from Amazon Linux to Amazon Linux 2 with Elastic Beanstalk and Node.js.md
Last active May 23, 2020
Migrating from Amazon Linux to Amazon Linux 2 with Elastic Beanstalk and Node.js
View Migrating from Amazon Linux to Amazon Linux 2 with Elastic Beanstalk and Node.js.md

This file is a log of everything I've encountered when trying to migrate a Node.js, Elastic Beanstalk application from the Amazon Linux platform to the Amazon Liunx 2 platform. Here's why you should migrate:

  1. LTS support up to 2023 source
  2. The Amazon Linux AMI's end-of-life is December, 2020 source
  3. Amazon Linux 2 has some big package upgrades (GCC, Glibc, etc.)
  4. Elastic Beanstalk also has some upgrades on top of Amazon Linux 2 (e.g. faster deploys)

Challenges

Disabling NPM install

@sjlu
sjlu / Contentful.js
Last active Jun 3, 2019
This helps compile Jekyll posts from Contentful
View Contentful.js
var Promise = require('bluebird')
var _ = require('lodash')
var fs = require('fs')
var contentful = require('contentful')
var client = contentful.createClient({
space: '0eybfmw2qkbf',
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
host: process.env.CONTENTFUL_HOST
})
@sjlu
sjlu / metabase
Created Mar 15, 2018
metabase init.d
View metabase
#!/bin/sh
# /etc/init.d/metabase
### BEGIN INIT INFO
# Provides: Metabase
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Metabase analytics and intelligence platform
### END INIT INFO
View gist:efa7152fc13219bf01d357e195e3acaf
return request({
method: 'POST',
url: 'https://api.fastly.com/service/' + main.SERVICE_ID + '/version/' + this.number + '/vcl',
headers: {
'Fastly-Key': main.API_KEY
},
form: {
name: 'gulp-fastly-uploaded-vcl',
file: encodeURIComponent(String(file.contents))
}
@sjlu
sjlu / notes.md
Created Oct 19, 2015
CircleCI with automated Docker builds
View notes.md

CircleCI Docker Integration

Grab a service account API credential as a JSON file

cat .json | base64 | pbcopy

Add the following environment variables

GCE_URL
@sjlu
sjlu / notes.md
Created Oct 19, 2015
Kubernetes and Google Container Engine cheatsheet
View notes.md

Setting project:

gcloud config set project tidy-bindery-110323

Creating a cluster:

gcloud container clusters create web --num-nodes=1 --machine-type=g1-small --zone=us-east1-b
@sjlu
sjlu / Dockerfile
Created Oct 19, 2015
Dockerfile into installing Node.js from a compiled source
View Dockerfile
# Install base OS
FROM ubuntu:14.04
# Author
MAINTAINER Steven Lu <tacticalazn@gmail.com>
# Installing base packages that we need
# to run node with along with our code
RUN apt-get update && apt-get install -y --force-yes --no-install-recommends \
build-essential \
@sjlu
sjlu / coreos.json
Created Oct 19, 2015
CoreOS CloudFormation that includes its own VPC mapping
View coreos.json
{
"Mappings": {
"RegionMap": {
"eu-central-1": {
"AMI": "ami-840a0899"
},
"ap-northeast-1": {
"AMI": "ami-6c5ac56c"
},
"us-gov-west-1": {
View Promises.md

Lets take an example where we have to load a dyanmic set of files. Normally we would have to iterate through the array, grab one file, then the next, etc. PHP is a good example of this and it'd take it a really long time to access each file since the computer's disk is slower than the CPU. This is what we call I/O wait.

$files = array("file1.txt", "file2.txt")
for ($i = 0; $i < count($files); $i++) {
  $fh = fopen($myFile, 'r');
You can’t perform that action at this time.