Archive for January 2008

I recently formatted my laptop and installed Windows first, using half of the hard drive, and then installing Ubuntu 7.10 on the other half. It had been a while since I tried Ubuntu – it has a come a long way – but that is another story.

The install worked fine, however at the end, it just sort of hung while installing grub. GREAT. I reboot and it kicks me to a (grub) standard prompt.

It took me a while to figure this out, but you can manually boot Ubuntu via the grub prompt. The tricky part is finding out the right commands since your system is totally inaccessible.

You can find your available hard drive name by typing:

> root ( <tab>

pressing tab will list your available hard drives and partitions and hopefully your Ubuntu ext3 partition.

Continue setting the root boot partition. This includes your partition with all /boot files. For example, mine was installed onto the root / filesystem, and not a separate filesystem.

> root (hd0,2)
>

This sets your root that grub uses.

You then need to set the kernel. Use:

> kernel /boot/vmlin <tab>

Tab will show you the available files to use. Also you can use this at any level to explore your filesystem. So for example:

> kernel /boot/vmlinuz-2.6.15-20-386

But wait before you hit enter!

You will get a pivot root error – the kernel doesn’t know where the rest of your file system is. In a file called device.map in your /boot directory, this location should be specified. In my case, it is listed as /dev/sda3. This is important for your kernel. Fortunately, GRUB has a ‘cat’ command you use to get the text output of this file. We also set this to a read-only filesystem – Ubuntu takes care of setting it back to rw when it boots.

So the final kernel line is:

> kernel /boot/vmlinuz-2.6.15-20-386 root=/dev/sda3 ro
>

Now we need to set the initrd file – hopefully you by now know to use to find this if you do not know it off of the top of your head:

> initrd /initrd.img-2.6.15-20-386
>

And finally, type ‘boot’ to begin the boot process:

> boot

Hopefully ubuntu will boot for you now without problems. Again, if you get a pivot root or ‘unable to mount root VFS’ error – you need to check the root=/dev/sda3 line part of the grub commands. This means that the kernel could not find your main filesystem.

Once you are logged into Ubuntu – use the following command to regenerate menu.lst for you. Once this is rebuilt, you will be presented with the normal Grub menu and you won’t need to follow the process above!

sudo update-grub

The goal here is to watermark all images in a certain directory, except for thumbnails or other selection. You can either do this on each file prior to placing on your webserver – which is probably wise for CPU load issues – but let’s just say you want to do this for all files served in a single directory dynamically, a gallery for example.

The first step is to create a .png file with transparency which holds your watermark image. For this exercise, I’ve created this image:

tbwm.png

(I’ve added the border to stand the image out from the background of the page).

Here is the original image we are going to test with:

boratwow.jpg

After we have our watermark and sample image, we need to write a php file to use PHP’s GD function to apply this image to our original image. The particular function we use is imagecopy(). Here is the code I am using, I name it w.php:

$basedir=”/home/user/public_html/com/gallery/”;
$watermarkimage=”tbwm.png”;

$file=basename($_GET['i']);

$image = $basedir.”/”.$file;
$watermark = $basedir.”/”.$watermarkimage;

$im = imagecreatefrompng($watermark);

$ext = substr($image, -3);

if (strtolower($ext) == “gif”) {
if (!$im2 = imagecreatefromgif($image)) {
echo “Error opening $image!”; exit;
}
} else if(strtolower($ext) == “jpg”) {
if (!$im2 = imagecreatefromjpeg($image)) {
echo “Error opening $image!”; exit;
}
} else if(strtolower($ext) == “png”) {
if (!$im2 = imagecreatefrompng($image)) {
echo “Error opening $image!”; exit;
}
} else {
die;
}
imagefilledrectangle($im2, 0 , (imagesy($im2))-(imagesy($im)) , imagesx($im2) , imagesy($im2) , imagecolorallocatealpha($im2, 0, 0, 0, 100) );
imagecopy($im2, $im, (imagesx($im2)-(imagesx($im))), (imagesy($im2))-(imagesy($im)), 0, 0, imagesx($im), imagesy($im));

$last_modified = gmdate(’D, d M Y H:i:s T’, filemtime ($image));

header(”Last-Modified: $last_modified”);
header(”Content-Type: image/jpeg”);
imagejpeg($im2,NULL,95);
imagedestroy($im);
imagedestroy($im2);

?>

This file is placed in the images directory.

Also in the images, create an .htaccess file with the following code:

RewriteEngine on
RewriteRule ^([^thumb].*\.[jJ].*)$ /com/gallery/w.php?i=$1

This tells the web server that instead of serving jpg files out of this directory, that we should instead process the filename with w.php and then serve to the browser. It also adds in a clause that if it starts with thumb_, that it will not run on this file. This is so it does not run on thumbnails.

Here is the resulting image, with watermark! This is served right out of an image directory with no watermark on the original picture:

Borat with watermark from php

I’ve used RSS readers in the past – they are great for aggregating information from sites which I view. However – adding all of my daily sites, as well as all of my ’sometimes’ sites I quickly have 50 or 100 RSS Feeds and it is impossible to keep up to date on feeds because getting through all content takes forever.

Part of this problem, I’ve noticed, is that many articles around the web mirror each other – for example when the MacBook Air was announced, every site came out with a news item about it. That means I have to click through so many items in my newsreader to just mark it as read and make sure I haven’t missed anything.

So – what I am looking for is an RSS client which will not segregate each individual RSS feed, but create a mesh of all of them and highlight the important items, and somehow also promote smaller, less popular items that may have been missed by other sites. This would involve somehow analyzing the text and date of the post and correlating the items together. For less popular posts but ones that are nonetheless interesting, maybe create a ranking system based on social bookmarking sites like reddit or stumbleupon.

In a way this is done by some sites – Google News is one example of news sites; and TechMeme is another one for technology related items.

Does anyone know of a program, either online or offline, which will do what I am asking? If not, would you be willing to program it?

Downloading a CAB file to install onto your Windows Mobile device can be a pain – after downloading the cab file to your desktop, you need to first copy it to your device, then find the cab file to install and then proceed to install it.

CABviaActiveSync is a simple, free program that adds a context menu to automatically parse the cab file on your desktop and install it via activesync. This can save you a bunch of steps and is incredibly handy if you are like me and are always installing/uninstalling programs to check out.

Download CABviaActiveSync from Modaco.

Jan 02

Skype Me

No comment - Post a comment

I’m trying to get more people to contact me via Skype rather than cell phone – so feel free to use the ‘Skype Me’ button on the right; or Add me to your contact list.

By the way, Skype, why won’t you get Caller ID working for US based phone numbers? This is the only thing stopping me, and I am sure a lot of people, from adopting Skype full on. Many people block Unknown numbers, or won’t answer if they see 0012345678 calling them!

On that topic… Skype Journal is a really great blog with regards to Skype and VOIP in general. If you are interested in VOIP, I would check it out!

  • Welcome to systemBash, a technology and system administration blog by David Drager. If you enjoy this sort of content, can can subscribe to the RSS clicking on that big icon to the right.