Skip to content

Instantly share code, notes, and snippets.

@robinmonjo
robinmonjo / init.sh
Last active December 15, 2015 19:39
set -e
sudo apt-get update
sudo apt-get install -y curl build-essential bison openssl libreadline6 libreadline6-dev git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf ssl-cert libcurl4-openssl-dev nginx
echo "Installing Ruby..."
echo " -> Downloading Ruby"
wget -q http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz
echo " -> Extracting tarball"
@robinmonjo
robinmonjo / init_container.sh
Last active December 16, 2015 07:59
Script used to provision a lxc container on productions servers
set -e
sudo apt-get install -y curl build-essential bison libreadline6 libreadline6-dev zlib1g zlib1g-dev libyaml-dev libxml2-dev libxslt-dev autoconf
#installing ruby
wget -q http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz
tar xf ruby-1.9.3-p0.tar.gz
cd ruby-1.9.3-p0
./configure --disable-install-doc
make
@robinmonjo
robinmonjo / init_prod_server.sh
Last active December 16, 2015 14:59
Script used to provision a production server managed by dcdget deployment platform
set -e
sudo apt-get update
sudo apt-get install -y curl build-essential bison openssl libreadline6 libreadline6-dev git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf ssl-cert libcurl4-openssl-dev nginx
echo "Installing Ruby..."
echo " -> Downloading Ruby"
wget -q http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz
echo " -> Extracting tarball"
@robinmonjo
robinmonjo / server.go
Created June 29, 2013 22:13
Simple http server skeleton in Go
package main
import (
"fmt"
"net/http"
"os"
"io/ioutil"
)
func main() {
@robinmonjo
robinmonjo / app.coffee
Created July 3, 2013 22:19
Simple static file server in express with authentication
express = require 'express'
fs = require 'fs'
app = express()
authenticationFilter = (req, res, next) ->
auth_token = req.query.auth_token
if auth_token == process.env.AUTH_TOKE
next()
else
tls = require 'tls'
fs = require 'fs'
Connection = require('./connection').Connection
class Rendezvous
@unPairedConnections = []
connectionFindOutSecret: (connection, cb) =>
#check if a connection with the same secret exists in the unPairedConnections list
class Connection
constructor: (@socket, @manager) ->
@socket.setEncoding 'utf-8'
@socket.on 'data', incomingData
@socket.on 'end', connectionClosed
@peerMet = false
incomingData = (chunck) =>
@robinmonjo
robinmonjo / nginx
Last active December 28, 2015 18:59
Upstart script for nginx
# nginx
description "nginx http daemon"
author "George Shammas <georgyo@gmail.com>"
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
env DAEMON=/usr/sbin/nginx
env PID=/var/run/nginx.pid
#user nginx;
# TODO(0): Changer welcome to nginx par Welcome to your app et si l'app n'exsite pas faire une erreur 500
user root root;
error_log /var/log/nginx.error.log;
pid /var/run/nginx.pid;
#Config changes found here: http://stackoverflow.com/questions/7325211/tuning-nginx-worker-process-to-obtain-100k-hits-per-min
worker_processes 4; # 2*number of cpus
set -e
sudo apt-get update
echo "Installing base stack"
packagelist=(
curl
build-essential
bison