Skip to content

Instantly share code, notes, and snippets.

Steven Lu sjlu

Block or report user

Report or block sjlu

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
@sjlu
sjlu / sunrise.sh
Created Feb 2, 2014
A nice script to initialize a CodeIgniter Sunrise project.
View sunrise.sh
#!/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."
View keybase.md

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:

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');
@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": {
@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 \
View readfile.c
#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
View gist:ca9891ad27cb2075a8bef777ec03e47a
func resetAndChooseView() {
window?.rootViewController = nil
if (AuthRepository.sharedInstance.isLoggedIn()) {
showCameraView()
} else {
showLoginView()
}
}
@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
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))
}
View gist:04011be67ab40a086d52be16edeacc2c
%23%20Please%20set%20the%20following%20variables%20inside%0A%23%20this%20varnish%20config%20or%20through%20the%20Fastly%0A%23%20control%20panel%0A%23%0A%23%20backend%20F_aws_bucket%0A%23%20backend%20F_api%0A%0Asub%20vcl_recv%20%7B%0A%23FASTLY%20recv%0A%0A%20%20%23%20redirect%20any%20crawlers%20directly%20to%20the%20Ruby%20API%0A%20%20%23%20so%20that%20we%20can%20serve%20metatags%20to%20them%0A%20%20if%20(req.url%20~%20%22_escaped_fragment_%22%20%7C%7C%20req.http.user-agent%20~%20%22baiduspider%7Ctwitterbot%7Cfacebookexternalhit%7Crogerbot%7Clinkedinbot%7Cembedly%7Cquora%20link%20preview%7Cshowyoubot%7Coutbrain%7Cpinterest%7Cslackbot%7CvkShare%7CW3C_Validator%7Credditbot%7CSlackbot-LinkExpanding%22)%20%7B%0A%20%20%20%20set%20req.backend%20%3D%20F_api%3B%0A%20%20%20%20%23%20set%20req.http.Host%20%3D%20F_api.host%3B%0A%20%20%20%20set%20req.http.X-Crawler%20%3D%20%22yes%22%3B%0A%20%20%7D%0A%0A%20%20%23%20enforce%20APEX%20domains%20to%20direct%20to%20%22www.%22%20instead%0A%20%20%23%20if%20not%20already%20%22www.%
You can’t perform that action at this time.