Archive

Archive for the ‘General’ Category

Generating cache-friendly URLS for parallel image loading

February 24, 2008 Comments off

The use of parallel image loading to improve page load time has been documented in multiple places. One of the key things to understand when one is using this technique is to always generate the same URL for the same static asset even if it resides on a different page.

This will allow the end-user to take advantage of HTTP proxy caches.

I wrote these set of simple PHP functions to demonstrate how one could incorporate this when generating the container HTML page for a website which uses parallel static asset loading

<?php
function path_to_origin_suffix($path,$NUM_ALIASES=2)
{
 /** Take hex value of md5 of $path. Get the ord value of the last
     hex char. Output it mod $NUM_ALIASES
 **/
 if (1 == $NUM_ALIASES)
     return 0 ;
 $hex = md5($path);
 return ord($hex[31]) % $NUM_ALIASES;
}

function make_url($path,$scheme="http",$origin="static.example.org")
{
 /**
    Add leading slash to $path. Generate suffix to append to basic
hostname
    basic hostname is the phrase before the 1st '.' in $origin
    Output a fully qualified URI encased in double quotes ""
 **/

 $pos = strpos($path,'/');
 if ($pos === FALSE || $pos != 0) {
  $path = sprintf('/%s',$path);
 }
 $suffix = path_to_origin_suffix($path);
 $array= explode('.',$origin,2);
 $host = "$array[0]$suffix.$array[1]";
 $abs_href = "$scheme://$host$path" ;
 echo "\"$abs_href\"";
}

function test() {
 echo make_url("/here/is/foobar") , "\n" ;
 echo make_url("here/is/foobar"), "\n" ;
 echo make_url("/there/is/foobar") , "\n" ;
 echo make_url("/there/was/never/a/foobar"), "\n" ;
 echo make_url("/please/mee/it/54"), "\n" ;
}

//test();
?>
   <html>
   <head><title>Parallel Static Asset Loading</title></head>
   <body>
   <img src=<?make_url("/john/rambo.gif")?> />
   <img src=<?make_url("here/was/john/rambo.gif")?> />
   </body>
   </html>

Hope this helps

Advertisements
Categories: General

Impact of OpenDNS on CDN services particularly when used in Asia

February 24, 2008 Comments off

At work, I am testing a CDN service run by Panther Express. I have been asking various colleagues and friends to run pings,traceroute and send me some HTTP response headers to analyze which Panther POP gets picked up where

Whilst working with a colleague in our Manila office, I found that he was being redirected to a Panther POP in San Jose California instead of being redirected to either a Hong Kong or Singapore POP as I expected.

I asked him for his /etc/resolv.conf entries and when he sent those to me, I found that one of the entries was that of OpenDNS dns cache. Whilst I truly appreciate OpenDNS’s work particularly its PhishTank system and API which we also use as part of SURBL, I think Asian users should understand that if they use OpenDNS then their DNS traffic leaves from the US and Content Delivery Networks like Akamai, Limelight, Mirror Image, Panther Express will route them to their US POP’s instead of their Asian POP’s

Once my colleague removed the OpenDNS entry, he was routed to the Asian POP for Panther Express

Technorati Tags:
Categories: General

Joi Ito, Pindar Wong in discussion with me about Creative Commons in Hong Kong

January 23, 2008 1 comment

On Monday 21st January 2008, I got a few hours notice that Joi Ito who wears many hats amongst which he is the Chairman of Creative Commons, board member of Mozilla Foundation, board member of SanrioDigital whose staff I work closely with regularly was visiting Outblaze’s offices.

Whilst Joi caught up with SanrioDigital staff members, Pindar Wong an Internet pioneer in Hong Kong who co-founded the first licensed ISP in Hong Kong dropped by to share a few words with Joi. The discussion amongst us veered towards the issues facing bringing Creative Commons to Hong Kong and I’ve blogged about on the Outblaze blog.

Towards the end of our discussion, I send a shout out to lawyers specializing in intellectual property to review the draft of the localized Creative Commons license for Hong Kong so if you are my reader who fits that profile I hope that you will do the right thing

It’s a bit wierd though watching yourself on YouTube though. How do you think I fair ?

Categories: General

In a digital world, what does it take to scrap CD's ?

January 14, 2008 Comments off

25 million pounds or
50 million US dollars

That’s what it takes EMI according to this article in the Financial Times

Read it and be flabbergasted

Categories: General

network logging via djb's multilog

November 8, 2007 1 comment

Had this recipe stuck in an old email somewhere, hope this helps someone else

The attached run files are required for the server who captures logs and the client which will send the logging data request.

Server

#!/bin/sh export PATH=”/usr/local/bin:$PATH” setuidgid remoteloguser tcpserver ip-addr-of-server listen-port-on-server multilog ./log

Client

#!/bin/sh export PATH=”/usr/local/bin:$PATH” 4>&1 | tcpclient ipaddr-of-server listen-port-on-server 6<&0

Technorati Tags :
Categories: General

How to get PHP5 with GD enabled with JPEG/PNG on x86-64

November 7, 2007 Comments off

I was trying to figure out why on CentOS 5.0 box on x86-64, I was unable to get GD support in PHP 5.2 for libjpeg and libpng. Lots of googling and looking through the PHP bug list and I finally worked out the magic invocation so for posterity (ie search engine’s sake) here it is

On an x86-64 environment ensure that you have the following configure options

-with-jpeg-dir=/usr \
–with-png-dir=/usr \
–with-libdir=lib64

Technorati Tags :
Categories: General

Amazing song by Kailash Kher – Teri Deewani

November 6, 2007 2 comments

I recently heard Kailash Kher’s phenomenal track Teri Deewani rendered by Toshi Sabri on Star Voice of India. A very moving experience. I searched for the original track at the usual places. I recommend to all my readers that they listen to this track at least once

Lyrics of Teri Deewani

Preet ki lath mohe aaisi laagi
Ho gayi main matwaali
Bal bal jaaun apane piya ko
Ke main jaaun vaari vaari
Mohe sudh budh naa rahee tan mann ki
Yeh toh jaane duniya saari
Bebas aur laachar phiru main
Haari main dil haari
Haari main dil haari

Tere naam se jee loon
Tere naam se marr jaaun
Tere naam se jee loon
Tere naam se marr jaaun
Teri jaan ke sadke mein kuchh aaisa kar jaaun
Tune kya kar dala marr gayi main mitt gayi main
Ho ji ha ji ho gayi main
Teri deewani deewani
Teri deewani deewani
Tune kya kar dala marr gayi main mitt gayi main
Ho ji ha ji ho gayi main
Teri deewani deewani
Teri deewani deewani

Ishq junoon jab hadh se badh jaaye
Ishq junoon jab hadh se badh jaaye
Hanste hanste aashiq suli chadh jaaye
Ishq ka jaadu sar chadhkar bole
Ishq ka jaadu sar chadhkar bole
Khoob laga lo pehre raste rab khole
Yahi ishq di marzi hain
Yahi rab di marzi hain
Yahi ishq di marzi hain
Yahi rab di marzi hain
Tere bin jeena kaisa
Aagush kar di hai
Tune kya kar dala marr gayi main mitt gayi main
Ho ji ha ji ho gayi main
Teri deewani deewani
Teri deewani deewani
Teri deewani deewani
Teri deewani deewani

E main rang rangili deewani
E main rang rangili deewani
E main albeli main mastani
Gaaun bajaaun sabko rijhaaun
E main diru taraph se begaani
Ee main deewani main deewani
Tere naam se jee loon tere naam se marr jaaun
Tere jaan ke sadle mein kuchh aaisa kar jaaun
Tune kya kar dala marr gayi main mitt gayi main
Ho ji ha ji ho gayi main
Teri deewani deewani
Teri deewani deewani
Teri deewani deewani
Teri deewani deewani…

Technorati Tags :
Categories: General
%d bloggers like this: