Skip to content

Instantly share code, notes, and snippets.

View pdeschen's full-sized avatar

Pascal Deschênes pdeschen

  • Montréal, Canada
View GitHub Profile
@pdeschen
pdeschen / services.conf
Created December 17, 2010 19:47
nginx location based reverse proxy
upstream serviceA {
server 127.0.0.1:88;
server 127.0.0.1:88;
}
upstream serviceB {
server 127.0.0.1:89;
server 127.0.0.1:89;
}
upstream serviceC {
server 127.0.0.1:90;
@pdeschen
pdeschen / mod_rpaf_install.sh
Created January 14, 2011 23:10
Rough script for building and installing apache mod_rpaf
#!/bin/bash
#(for apxs)
yum install -y httpd-devel
cd /usr/local/src/
sudo wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
sudo tar xzf mod_rpaf-0.6.tar.gz
cd mod_rpaf-0.6
sudo apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
#Make sure you have keepalive off in httpd.conf
@pdeschen
pdeschen / nginx.conf
Created January 16, 2011 19:09
Base proxy and caching config for nginx.conf
http {
...
#caching related
client_body_temp_path /var/lib/nginx/body 1 2;
gzip_buffers 32 8k;
gzip on;
tcp_nodelay on;
gzip_types
text/html
@pdeschen
pdeschen / wordpress-blog.conf
Created January 17, 2011 20:38
nginx config for wordpress proxying
upstream wordpress {
server 127.0.0.1:80 weight=1 fail_timeout=120s;
}
server {
listen 81;
server_name blog.foo.bar;
proxy_cache_valid 200 20m;
access_log /var/log/httpd/nginx-access.log combined;
@pdeschen
pdeschen / test-cache-hits.sh
Created January 17, 2011 23:16
testing nginx caching behaviour
tail -F /var/log/nginx/blog.foo.bar-access.log&
curl --head http://blog.foo.bar:81
"HEAD / HTTP/1.1" 200 0 "-" "-" "HIT"
HTTP/1.1 200 OK
Server: nginx/0.7.67
Date: Mon, 17 Jan 2011 22:51:44 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
@pdeschen
pdeschen / static-server.js
Created April 6, 2011 19:58
A node.js static file server using mime.
var libpath = require('path'),
http = require("http"),
fs = require('fs'),
url = require("url"),
mime = require('mime');
var path = ".";
var port = 8088;
http.createServer(function (request, response) {
@pdeschen
pdeschen / foobar.js
Created April 9, 2011 01:02
sharing between modules?
/* foo.js */
var date = new Date();
exports.Date = date;
/* bar.js */
var foo = require('./foo.js');
exports.Date = foo.Date;
/* foobar.js */
@pdeschen
pdeschen / model.json
Created May 15, 2011 21:42
json model
{
"header": "Colors",
"items": [
{"name": "red", "first": true, "url": "#Red"},
{"name": "green", "link": true, "url": "#Green"},
{"name": "blue", "link": true, "url": "#Blue"}
],
"empty": false
}
@pdeschen
pdeschen / gist:973578
Created May 15, 2011 21:49
mustache template
<h1>{{header}}</h1>
{{#items}}
{{#first}}
<li>
<strong>{{name}}</strong>
</li>
{{/first}}
{{#link}}
<li>
@pdeschen
pdeschen / constroller.js
Created May 15, 2011 21:55
mustache.js rendering
render : function(view, model, callback) {
cst.model = model;
cst.view = view;
try {
var html = Mustache.to_html(view, model);
callback.call(this, html);
} catch (error) {
onError('Error while rendering template.');
}
}