Saturday, September 17, 2011

Things to do after installing Ubuntu 11.04

1. Unity or gnome classic

After installation Ubuntu 11.04 starts up with Unity style.
If you not like Unity style, switch back to gnome classic.

Here's how to:
At the bottom of login screen there is a tab, from where you can choose the style you want.

2. Install updates

Just type in terminal:
sudo apt-get update && sudo apt-get upgrade
 
 

Thursday, September 8, 2011

Html layers containing Flash swf object

Today, i bumped into a problem. I was trying to make 2 layers, one containing an swf object. The swf object displays on top of all layers regardless of z-index.
So i googled around and found that the transparent parameter must be set to the object.


Example:
   

Sunday, July 17, 2011

PHP Function to Check URL

The following PHP function is used to check if the URL exists. This php function will monitor the http requests and returns the header information. This function is very useful when you are validating the given URL

function checkUrl($url) {
$root = _getRoot($url);
$ctx = stream_context_create(array(
'http' => array(
'max_redirects' => 5, // allows 4 redirects :/
'timeout' => 5,
)
));
$fp = @fopen($url, 'r', false, $ctx);
$ret['success'] = false;
if (! $fp) {
return $ret;
}
$ret['locations'] = array();
$ret['metaData'] = stream_get_meta_data($fp);
fclose($fp);
// analyze HTTP headers
foreach ($ret['metaData']['wrapper_data'] as $line) {
if (preg_match('@^Location: (.*)$@i', $line, $m)) {
if ($m[1][0] === '/') {
// root-relative URI
$m[1] = $root . $m[1];
} elseif (strpos($m[1], '://') >= 4) {
// full URL
$root = _getRoot($m[1]);
}
$ret['locations'][] = $m[1];
}
if (preg_match('@^HTTP/1\.[01] 200@i', $line, $m)) {
$ret['success'] = true;
}
}
return $ret;
}

function _getRoot($url) {
list($proto, $url) = explode('://', $url, 2);
list($host) = explode('/', $url, 2);
return $proto . '://' . $host;
}



var_export(checkUrl('http://microsoft.com/ie'));

// outputs

array (
'success' => true,
'locations' =>
array (
0 => 'http://www.microsoft.com/ie',
1 => 'http://www.microsoft.com/ie/',
2 => 'http://www.microsoft.com/windows/internet-explorer/default.aspx',
),
'metaData' =>
array (
'wrapper_data' =>
array (
... abunch of HTTP headers
),
'wrapper_type' => 'http',
'stream_type' => 'tcp_socket/ssl',
'mode' => 'r+',
'unread_bytes' => 3478,
'seekable' => false,
'uri' => 'http://microsoft.com/ie',
'timed_out' => false,
'blocked' => true,
'eof' => false,
),
)



Check these out

http://hungred.com/how-to/php-check-remote-email-url-image-link-exist/

http://w-shadow.com/blog/2007/08/02/how-to-check-if-page-exists-with-curl/