img2table – Worst abuse of HTML table

img2table converts JPG/PNG into HTML table to render in browser.

Perhaps the only IE6 compatible embed image (But who cares about IE6 nowadays anyway?)
Perfect way to waste disk space, memory and cpu resources!

The PHP implementation:

<?php
$filename = 'original.png';

$pathinfo = pathinfo($filename);

if ($pathinfo['extension'] == 'png') {
    $image = imagecreatefrompng($filename);
} else if ($pathinfo['extension'] == 'jpg' || $pathinfo['extension'] == 'jpeg') {
    $image = imagecreatefromjpeg($filename);
}
if (!$image) die('Invalid image');
$size = getimagesize($filename);

$width = $size[0];
$height = $size[1];

$pixel_size = 16;
?>
<table cellpadding="0" cellspacing="0" border="0">
<?php for ($y = 0; $y < $height; $y += 1)  { ?>
<tr>
    <?php for ($x = 0; $x < $width; $x += 1)  { ?>
    <td width="<?php echo $pixel_size?>" height="<?php echo $pixel_size?>" style="background-color: #<?php echo str_pad(dechex(imagecolorat($image, $x, $y)), 6, '0', STR_PAD_LEFT);?>"></td>
    <?php } ?>
</tr>
<?php } ?>
</table>

Result: 252 bytes PNG converted into 18,204 bytes HTML (7223% bigger)

Cool? No… Just a quick idea for fun 😀

Ubuntu 14.04 unmet dependencies when installing Wine

tiger@Tiger-Desktop:~$ sudo apt-get install wine
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
wine : Depends: wine1.6 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

After a hour of trial and error,
I found out that the problem was caused by outdated software source.
Just changed back to “archive.ubuntu.com” and dependency error is fixed.
(The broken server is ubuntu.01link.hk)

Be careful when using 3rd party software sources!
You can check if a mirror is up-to-date here.

[BuzzWord拆解系列] 淺談雲端運算 Cloud Computing (上)

近年 IT 界 Buzzword 之最,莫過於 “Cloud” 一詞。
網上硬碟改名為「雲端儲存」、網上服務改名為「雲端服務」,甚至「雲端電郵」都跑出來了!

這好像跟「高清納米離子保濕Con」一樣,只是向客戶吹噓的虛浮名詞
“Cloud Computing” 實際是甚麼,則甚少有人考究。

即使在美國,竟然有 51% 人相信壞天氣會影響雲端運算

Continue reading “[BuzzWord拆解系列] 淺談雲端運算 Cloud Computing (上)”