Archive for November, 2010

Posted by 6bytes at 17, November, 2010

Category: Apache, CentOS

Tags: , , , ,

I’m not going to write about whether I think mod_pagespeed is good or not, is it suitable for your website, why you should use it or not. I’ll focus only on installation.

Since you’re here and still reading I assume you want to speed up your website with Google’s mod_pagespeed. If you’re on a machine where for any reason installing from .rpm or .deb is not possible read on.


First we need to install Chromium ‘depot_tools’, which are used to build multiple open-source projects with dependencies on other open-source projects.

mkdir ~/bin
cd ~/bin
svn co

You will need to add the depot_tools to your path. i.e. in bash:

export PATH=$PATH:~/bin/depot_tools

Check out mod_pagespeed and dependencies

mkdir ~/mod_pagespeed    # any directory is fine
cd ~/mod_pagespeed
# always check for latest version by going to in your browser
# then copy link to /src ie.
gclient config
gclient sync --force     # this will download all source code

Compile mod_pagespeed

cd ~/mod_pagespeed/src
make BUILDTYPE=Release   # BUILDTYPE defaults to 'Debug'

Install mod_pagespeed

First edit and change parameters according to your needs. Then run it.

vim install/
cd install
./ staging
./ install

Restart Apache

/etc/init.d/httpd restart

Check if Apache loaded mod_pagespeed.

httpd -M # list static and shared modules, mod_pagespeed should be here
httpd -l # list compiled in modules

If above doesn’t work try something like this:

/usr/src/httpd/httpd -M
/usr/src/httpd/httpd -l

If it’s there go to /etc/httpd/pagespeed.conf and configure it. I’ll write a bit more about configuring mod_pagespeed in my next post. If it’s not there make sure is in Apache module directory and if not copy it there.

cp /tmp/mod_pagespeed.install/ /usr/local/apache2/modules/

Edit your Apache configuration file and add Include /etc/httpd/pagespeed.conf if it isn’t already there. Next edit /etc/httpd/pagespeed.conf and add

LoadModule pagespeed_module /usr/local/apache2/modules/

Restart Apache and you should see something like X-Mod-Pagespeed: in your website’s response headers.


Posted by 6bytes at 8, November, 2010

Category: PHP

Tags: , ,

A very simple PHP script to get almost live currency exchange rates from Yahoo Finance. I’m saying “almost” as as far as I know Yahoo updates it with some minor delay.

$from = 'GBP';
$to = 'USD';
$url = ''.$from.$to.'=X';
$handle = fopen($url, 'r');

if ($handle) {
	$result = fgetcsv($handle);

echo '1 '.$from.' is worth '.$result[0].' '.$to.' Based on data on '.$result[1].' '.$result[2];

On the day of writing this post, above script will display:

1 GBP is worth 1.6125 USD Based on data on 11/8/2010 10:26am

Short explanation

I think everything is clear except for the URL and its parameters. Lets have a closer look.
In our example

$url = ''.$from.$to.'=X';

translates to

Pasting this into your browser returns a csv file with three columns. Current exchange rate, date and time. Where:

  • l1 – exchange rate,
  • d1 – date,
  • t1 – time

If exact time is not what you’re looking for and all you need is just the exchange rate your url could look like this:

I couldn’t find full list of parameters on yahoo but this site seems to have it all covered.

Yahoo finance not only gives you access to exchange rates but also stock data.