Skip to content

Instantly share code, notes, and snippets.

@robwilkerson
robwilkerson / fixtures.js
Created April 5, 2016 11:28
A simple integration test file
'use strict';
let Promise = require('bluebird');
let db = require('../config/knexfile')[process.env.NODE_ENV];
let knex = require('knex')(db);
/**
* Loads fixture data. Expects fixture data to be exported by a file in the
* ./fixtures/ directory (e.g. ./fixtures/users.js).
/* jshint node:true */
process.binding('http_parser').HTTPParser = require('http-parser-js').HTTPParser;
var http = require('http');
var url = require('url');
var printf = require('util').format;
var Promise = require('bluebird');
var modemRequest = Promise.method(function(modemUrl) {
@robwilkerson
robwilkerson / default.vcl
Created December 30, 2014 15:40
Varnish Config
backend default {
.host = "127.0.0.1";
.port = "8080";
}
acl purge {
# Add local/internal server IPs
"localhost";
"127.0.0.1";
@robwilkerson
robwilkerson / server-health.md
Created December 10, 2013 12:51
Tools & techniques for monitoring server health.

Server Health

Command Line Tools

  • top

  • uptime: Pay attention to the load average value.

  • free -m: Indicates how much memory is available. Some memory is used by the machine trying to anticipate, but it's still available. That's why the second row in the free column is key.

                   total       used       free     shared    buffers     cached
    

Mem: 991 763 227 0 69 464

@robwilkerson
robwilkerson / provision.vm.sh
Created November 21, 2013 02:32
A Vagrant provisioner file template.
#!/bin/bash
# Provisions the Vagrant VM for this project. This file should never be
# executed manually. It is intended to be run only in the context of the
# `vagrant up` execution.
# NOTE: This script is executed by Vagrant as the root user.
set -e
@robwilkerson
robwilkerson / Vagrantfile
Created November 21, 2013 02:12
Vagrant 1.3.x Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "precise64-dev"
@robwilkerson
robwilkerson / vagrant-set-hostname.sh
Created August 1, 2013 13:01
Sets and persists a custom hostname on an Ubuntu server.
# Set a helpful hostname as a convenient reference.
echo "project-name" > /etc/hostname
echo "127.0.0.1 project-name" >> /etc/hosts
hostname project-name
@robwilkerson
robwilkerson / install-varnish.sh
Created June 19, 2013 13:15
Installs Varnish. Tested in a Vagrant shell provisioner for a Ubuntu 12.04 VM.
# Install Varnish
if [ -z `command -v varnishd` ]; then
echo -n "Installing varnish (http://www.varnish-cache.org)..."
# curl http://repo.varnish-cache.org/debian/GPG-key.txt | sudo apt-key add - > /dev/null
# echo "deb http://repo.varnish-cache.org/ubuntu/ precise varnish-3.0" | sudo tee -a /etc/apt/sources.list > /dev/null
apt-get install varnish -qq -y > /dev/null
echo "complete."
else
echo "Varnish is aleady installed."
fi
@robwilkerson
robwilkerson / generate-self-signed-cert.sh
Last active December 17, 2015 14:59
Generates a self-signed SSL certificate. #bash #ssl
# Generate a self-signed certificate
echo -n "Generating a self-signed SSL cert..."
openssl req -new -x509 -days 365 -subj "/C=US/ST=MD/L=Baltimore/O=Rob Wilkerson Consulting, LLC/CN=*.MYDOMAIN.COM" -nodes -out /etc/ssl/certs/wildcard-cert.pem -keyout /etc/ssl/private/wildcard-cert.key
echo "complete."
@robwilkerson
robwilkerson / update-nginx-conf.sh
Created May 22, 2013 15:21
Enables gzip and adjusts for a Virtualbox bug w/ sendfile.
# Tweak the Nginx conf. sendfile is broken on Virtualbox.
echo -n "Setting the Nginx configuration..."
sed -i -r -e 's/sendfile\s*on/sendfile off/g' /etc/nginx/nginx.conf
sed -i -r -e 's/^(\s*)#\s*gzip on(.*)$/\1gzip on\2/' /etc/nginx/nginx.conf
sed -i -r -e 's/^(\s*)#\s*gzip_types(.*)$/\1gzip_types\2/' /etc/nginx/nginx.conf