Skip to content

Instantly share code, notes, and snippets.

@roblayton
roblayton / Vagrantfile
Last active August 29, 2015 14:20
2-core Trusty64
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provider "virtualbox" do |v|
v.memory = 1024
@roblayton
roblayton / Dockerfile
Created May 27, 2015 02:35
Example nodejs Dockerfile
FROM ubuntu
RUN apt-get install -y python-software-properties python
RUN add-apt-repository ppa:chris-lea/node.js
RUN echo "deb http://us.archive.ubuntu.com/ubuntu/ precise universe" >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y nodejs
RUN mkdir /var/www
ADD app.js /var/www/app.js
@roblayton
roblayton / app.js
Created May 27, 2015 02:43
Example nodejs app
var http = require('http');
// Http server
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
text = "Running Node.js:" + process.versions.node
response.end(text);
});
@roblayton
roblayton / docker-compose.yml
Last active August 29, 2015 14:21
Example Docker Compose File
web:
image: "youraccount/yourrepo:1.0.0"
ports:
- "8080:8080"
@roblayton
roblayton / Vagrantfile
Last active August 29, 2015 14:22
Basic Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.33.10"
end
@roblayton
roblayton / namewriter.py
Created June 6, 2015 23:18
Python server for writing names to a MySQL DB
import MySQLdb
import argparse
db = MySQLdb.connect(host="192.168.33.10", user="test", passwd="password", db="test")
cursor = db.cursor()
parser = argparse.ArgumentParser(description="Process some strings.")
parser.add_argument("firstname", type=str, help="firstname")
parser.add_argument("lastname", type=str, help="lastname")
args = parser.parse_args()
@roblayton
roblayton / namereader.py
Created June 6, 2015 23:20
A Python server for reading names from a MySQL DB
import MySQLdb
db = MySQLdb.connect(host="192.168.33.10", user="test", passwd="password", db="test")
cursor = db.cursor()
cursor.execute("SELECT firstname,lastname FROM test.name")
for row in cursor.fetchall():
firstname = str(row[0])
lastname = str(row[1])
@roblayton
roblayton / haproxy.cfg
Last active August 29, 2015 14:22
HAProxy config file for a MySQL cluster
global
log 127.0.0.1 local0 notice
maxconn 2000
user haproxy
group haproxy
defaults
log global
mode http
retries 3
@roblayton
roblayton / Vagrantfile
Last active August 29, 2015 14:22
A Vagrantfile to spin up 2 mysql instances for a master-master configuration
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provision "shell", inline: "apt-get update"
@roblayton
roblayton / Vagrantfile
Last active August 29, 2015 14:22
A Vagrantfile for a MongoDB cluster
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.define :configsvr1 do |configsvr1|