Skip to content

Instantly share code, notes, and snippets.

@sjlu
sjlu / sunrise.sh
Created February 2, 2014 20:51
A nice script to initialize a CodeIgniter Sunrise project.
#!/bin/bash
# Must have a project name
if [ "$#" -ne 1 ]; then
echo "Usage: ./sunrise.sh <project_name>"
exit 1
fi
if [ -d "$1" ]; then
echo "ERROR: Directory already exists."
@sjlu
sjlu / keybase.md
Last active August 29, 2015 14:06

Keybase proof

I hereby claim:

  • I am sjlu on github.
  • I am sjlu (https://keybase.io/sjlu) on keybase.
  • I have a public key whose fingerprint is FC56 EEDC 66B1 61FB BE45 72DB B542 60ED E871 058D

To claim this, I am signing this object:

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');
@sjlu
sjlu / coreos.json
Created October 19, 2015 14:15
CoreOS CloudFormation that includes its own VPC mapping
{
"Mappings": {
"RegionMap": {
"eu-central-1": {
"AMI": "ami-840a0899"
},
"ap-northeast-1": {
"AMI": "ami-6c5ac56c"
},
"us-gov-west-1": {
@sjlu
sjlu / Dockerfile
Created October 19, 2015 16:49
Dockerfile into installing Node.js from a compiled source
# 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 \
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
// pretty standard operation on reading files
// into memory. fopen, fseek, etc.
char* read_file(const char *filename)
{
// open file operation
@sjlu
sjlu / notes.md
Created October 19, 2015 16:52
CircleCI with automated Docker builds

CircleCI Docker Integration

Grab a service account API credential as a JSON file

cat .json | base64 | pbcopy

Add the following environment variables

GCE_URL
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 October 19, 2015 16:51
Kubernetes and Google Container Engine cheatsheet

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
0xbD08E418EB33ecC56b2234d860397f77143cD2F3