Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am tylercb on github.
  • I am thanway (https://keybase.io/thanway) on keybase.
  • I have a public key ASCN08z8zBShWzcDjM2_skfaDBkEPirrGejK5ShI3UGWjgo

To claim this, I am signing this object:

@tylercb
tylercb / .block
Created September 1, 2016 20:59 — forked from mbostock/.block
Processing Fixed-Width Data
license: gpl-3.0
@tylercb
tylercb / gist:d8c1407c1122c40a867f
Created August 17, 2015 19:55
Install Memcached with Homebrew
# Install Homebrew
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
# Update and fix any homebrew problems
brew update
brew doctor
# Install Memcached
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/share/postgres
pg_ctl -D /usr/local/share/postgres -l /usr/local/share/postgres/server.log start
#2. Create a template to be used on creating GIS-enabled databases
createdb postgis_template
createlang plpgsql postgis_template
# Set cache dir
proxy_cache_path /var/cache/nginx levels=1:2
keys_zone=microcache:5m max_size=1000m;
# Virtualhost/server configuration
server {
listen 80;
server_name yourhost.domain.com;
# Define cached location (may not be whole site)
http {
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;
#Install dpkg-dev and package dependencies
sudo apt-get install dpkg-dev
sudo apt-get install software-properties-common
sudo apt-get install python-software-properties
sudo apt-get install init-system-helpers
#Add repository:
sudo add-apt-repository ppa:nginx/stable
#Edit /etc/apt/sources.list.d/nginx-stable-lucid.list, add dpkg-src (no need if ubuntu verson >= 12.04):
#!/bin/bash
echo "This script will rebuild a Debian style package (deb) of latest stable"
echo "Nginx. The original deb is from nginx.org apt repository."
echo
echo "This will prompt you yes or no on a few changes to the build as well as"
echo "it will compile and package the latest Google NGX Pagespeed module."
echo
echo "This is built and tested on Ubuntu 12.04 LTS, fresh OS install."
echo "There are no guarantees, and I take no liability if it breaks, but it"

The idea is to have nginx installed and node installed. I will extend this gist to include how to install those as well, but at the moment, the following assumes you have nginx 0.7.62 and node 0.2.3 installed on a Linux distro (I used Ubuntu).

In a nutshell,

  1. nginx is used to serve static files (css, js, images, etc.)
  2. node serves all the "dynamic" stuff.

So for example, www.foo.com request comes and your css, js, and images get served thru nginx while everything else (the request for say index.html or "/") gets served through node.

  1. nginx listens on port 80.