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 / 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 / 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 / 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 / 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 / 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 / serviceA.conf
Created December 17, 2010 19:03
Apache Virtual Host for Service A
Listen localhost:88
<VirtualHost localhost:88>
DocumentRoot /var/www/A
<Directory "/var/www/A/">
ErrorDocument 404 /
AddDefaultCharset UTF-8
Options FollowSymLinks MultiViews Includes
AllowOverride All
</Directory>
</VirtualHost>
@pdeschen
pdeschen / update-dns.sh
Created December 10, 2010 19:46
dynamic geoscaling dns update
IP_ADDRESS=`curl http://labs.rassemblr.com/go/ip`
USERNAME=<yourusername>
PASSWORD=<yourpassword>
HOST=<yourAhost>
curl -u $USERNAME:$PASSWORD /
"http://api.geoscaling.com/dns2/dynamic/?host=$HOST&content=$IP_ADDRESS"
@pdeschen
pdeschen / ip.rb
Created December 10, 2010 19:37
http client ip output
#!/usr/bin/ruby
require "cgi"
cgi = CGI.new("html3")
cgi.out() do
ENV['REMOTE_ADDR']
end
@pdeschen
pdeschen / TropoSmsNotification.java
Created October 28, 2010 22:07
Sends a SMS message to provided number using Apache HttpClient
// Uses a very very simple tropo script configured for your application
// See http://github.com/pdeschen/nubot-labs/raw/master/tropo/src/Sms.groovy
HttpClient mHttpClient = new HttpClient();
String mBaseUrl = "http://api.tropo.com/1.0/sessions";
GetMethod method = new GetMethod();
// here we have to throttle. We can't have more then x sms/minutes.
event = prompt(text, [
repeat:3,
timeout:7,
choices:listOptions( contacts ),
onEvent:
{ handlingEvent->
handlingEvent.onTimeout( {
say( "I'm sorry, I didn't hear anything." )
}
)