Wednesday, August 12, 2009

Can the weight of a hard drive increase?

I would greatly appreciate your visit if you take the time to leave a comment or rate this post. Feelings or suggestions will be welcome.


A few days ago, I came upon a very interesting post in a Microsoft forum. Take a look at it:

Apologies if this is the incorrect area for this question.
I've noticed that as I copy data/install programs on my Laptop, the weight of the Laptop increases. I have a bad back and am medically limited on the amount of weight I can carry so I need to be very carefull not to inflict injury upon myself.
I have also noticed my XBox feels heavier as well (the more games I save or purchase from arcade). I generally don't travel with my XBox so that is not an issue for me, but note the I am having the same results.
My ask, what is the weight/file ratio? So for example, how many GB's = 6oz? I dread the day I need a dolly to commute to work with my Laptop.
Thanks in advance!
- K

I copied all of the grammar and English errors faithfully (Ctrl+C & Ctrl+V).

Whether the question was serious or simply a joke is irrelevant. There were a variety of answers to it. I am going to show you two that I liked. You decide which one is correct:

First answer:

It’s worth noting that this answer was “Marked as Answer” by the person who asked the question (K_McLovin).

Hi K_McLovin,

Thank you for posting on Microsoft Answers Forum.

If we understand your question correctly, there is no possible way that copying files or installing programs is increasing the weight of your laptop. Also, the same with your Xbox, downloading games from the Arcade will not increase the weight of your Game Console.

Just to explain a little bit more as to why the hard drive will not “gain weight”; if you were to look inside a hard drive you would see what would resemble a record player. There are small platters that resemble the record then you have a read/write head attached to an arm. The platters are coated with tiny magnetic particles when the hard drive gets "written on" the read/write head simply alters the polarity of the millions of different little sections on different parts of the hard drive. So when you write on a hard drive you don't really "Write" on it, you rearrange things on it, and because of that the weight doesn’t change.

If we are misunderstanding your question please clarify so that we may further assist you.



Robyn
Microsoft Answers Support Engineer
Visit our
Microsoft Answers Feedback Forum and let us know what you think.

Second answer:

This can be considered an evil answer.

This is a rare error when the overwriting mechanism of the memory banks lead to an overflow of data because it cannot add on and thus super-stack, increasing the weight significantly. While normal weight/file ratio is approximately 0.02 oz/GB, in rare cases such as these, it can go as high as somewhere around 6 oz/GB.

One solution is going to the system32 folder (C:\WINDOWS\system32) and deleting certain unnecessary files, but too much tampering may cause permanent changes to your computer.

There were many other interesting answers and I invite you to read them. You can go to this thread using

http://social.answers.microsoft.com/Forums/en-US/vistahardware/thread/720108ee-0a9c-4090-b62d-bbd5cb1a7605

Thank you

Sunday, May 17, 2009

How to mount an ISO image in Linux

Use the following command to mount an ISO image in openSUSE 11.0. It should work with other distributions.

mount -t iso9660 -o loop <isoimage> <folder>

You might need to replace loop by /dev/loop. <isoimage> is the ISO file, and <folder> is the folder to where you want to mount the files “inside” the ISO image.

Thursday, May 7, 2009

New Look!

Hi everybody

I have noticed I have been receiving visits lately from all over the world. I appreciate it very much. I decided to change the look of my blog a little bit because it was too dark, and I would prefer it to look professional.

Please leave comments if you feel I made a mistake or should add something. Also, if you have questions about my posts, I will be glad to answer.

I decided to be more active in my blog now that I am getting more visits.

Saturday, February 7, 2009

Remote access to KDE from a Windows desktop

I would greatly appreciate your visit if you take the time to leave a comment or rate this post. Feelings or suggestions will be welcome.


OpenSUSE is a nice Linux distribution because of its administration tool called YaST. Even if you use openSUSE in text-mode only, YaST is a very friendly system management tool. However, some of us still like the look'n'feel of a window manager like KDE, and sometimes we do not have physical access to the Linux computer. There are solutions like VNC (which is not secure) and VPN (which is hard to set up) that allows us to access the computer remotely.

Recently, I found a "hidden" way to access KDE from another computer. The computer from where I am accessing KDE has Windows Vista Home Premium installed. The Linux computer that I am accessing uses openSUSE 11.1 + KDE. This method, however, should be easy to apply to different system configurations.

The keys to this method are SSH, to make it secure, and the power of the X System, to get KDE working remotely. We are going to forward all the X11 requests from the Linux computer to another computer using SSH tunneling. It sounds easy so far, but the problem comes when we realize that we need an X server to process the requests from the Linux client. Windows, unfortunately, does not have native support for the X System. However, there is a very nice application to add X System functionality to a Windows desktop. It is called Xming and you can download it freely from

http://sourceforge.net/projects/xming

The installation is self explanatory. These are the options that I selected for the installation:

Also, instruct the installation program to place a shortcut for XLaunch on the desktop.

Now, the secure part. Make sure that you can access your Linux computer in text mode using SSH. If you can do this, the rest is easy.

First, we need to make sure the SSH server is configured correctly to handle X11 forwarding. I took the following from

http://solaris.reys.net/english/2006/04/x11_forwarding

1. Open the file /etc/ssh/sshd_config
2. The following lines should be uncommented:

X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes

3. Restart the SSH Deamon. In my Linux distribution, you just have to type:

rcsshd restart

The SSH client that I am using is PuTTY (I assume that you need to have it installed). Click on the XLaunch icon on the desktop. This will open the following window:

Make sure you select "One window". Then, click next.

Select "Start a program" and click next.

Enter "startkde" in the text field "Start program". Select "Using PuTTY (plink.exe)" and fill out the fields as if you were connecting through SSH. Also, select "With compression". Then, click next.

Leave this additional parameters as they are and click next.

Your configuration is finished. Click "Finish" to start KDE. It might take a while before it starts, but it will eventually. One of the disadvantages of this method is that it is very slow, partly because it uses SSH to encrypt the communication and partly because the quality of the graphics is perfect. It might not be very convenient to access this from the WAN, unless you have a really fast internet for both machines.

Something that you might prefer doing is starting individual applications instead of the entire KDE desktop. It makes it significantly faster. In that case, you type a different command (like "firefox") instead of "startkde".

A useful application of this is that you can run YaST in graphical mode by using the commands:

yast2 --qt
or,
yast2 --gtk

I hope this post was helpful

Saturday, January 31, 2009

Valid Javascript in XHTML

Some of us, web developers, are trying to stick with the standards established by the W3C for markup documents. We want browsers to interpret our documents in a standard way instead of having to write dirty quirks for each browser (especially Internet Explorer).

In the World Wide Web, we have seen a tendency to shift from HTML 4.01 documents to XHTML pages. Sometimes the transition is easy, bt some other times, things that seemed normal in one specification are invalid in the other.

Let's take a look at the <script></script> tag. We use this commonly to write Javascript code. Sometimes, we need the code to be inside the (X)HTML document instead of having a separate .js file (for whatever reason). When trying to validate XHTML documents that contain Javascript code in the W3C validator, we come upon some strange errors. Let's look at the following example:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>My Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script language="JavaScript" type="text/javascript">

function initScript() {

myArray[0] = "Element 0";
myArray[1] = "Element 1";

for(var i=0;i<myArray.length;i++) {
alert(myArray[i]);
}

}

</script>

</head>

<body onload="javascript:initScript();">
<div>Hello World</div>
</body>

</html>

If we try to validate this document at

http://validator.w3.org/#validate_by_input

we get 6 errors. All of them suggest that the Javascript code is being interpreted by the validator as HTML code (and therefore by a standard-compliant browser). The solution to this problem is to tell the validator/browser that the Javascript code should be interpreted as Character Data (CDATA) and not as some strange HTML entity.

I found different methods online to tell this to the validator, but the best one that I found was at

http://javascript.about.com/library/blxhtml.htm

We enclose the Javascript code using:

/* <![CDATA[ */
Javascript code;
/* ]]> */

For my example, the final document would look like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>My Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script language="JavaScript" type="text/javascript">
/* <![CDATA[ */

function initScript() {

myArray[0] = "Element 0";
myArray[1] = "Element 1";

for(var i=0;i<myArray.length;i++) {
alert(myArray[i]);
}

}

/* ]]> */
</script>

</head>

<body onload="javascript:initScript();">
<div>Hello World</div>
</body>

</html>

Friday, January 30, 2009

Converting a lot of images

In my previous post, I explained how to convert a PDF file to an image. It is easy to convert one single file, but what if you have hundreds?

A couple of days ago, a friend of mine asked me if it was possible to convert a lot of images from one format to another without having to go through each one. He was making an RPG and the program he had accepted 24-bit BMP files only. He had hundreds (700+) of images to convert from GIF to BMP. He was doing it by opening each one in MS Paint and then saving it as a 24-bit BMP. He sure is glad that he asked me about it.

I immediately thought about the 'convert' command in Linux, but how could I get it to repeat for 700+ files? I don't know a lot about BASH scripting and I didn't want to learn just to get a list of files. Then, the 'find' command came to mind. In Linux, we use this command to find files if we know part of their names. Luckily, 'find' has an option that allows you to execute a command for every file that it finds. This suits perfect for our situation.

Let's say we have a folder. In that folder, we have lots of subfolders, each one containing lots of pictures (as in my friend's case). Being in that folder, we can execute the following command to convert all of the images in that folder and subfolders to a format that we want. Let's assume we are trying to convert from a GIF image to a BMP file.

find ./ -iname '*.gif' -exec convert '{}' '{}.bmp' \;

For every GIF image named 'input.gif', there will be a BMP output file named 'input.gif.bmp' in the same folder as 'input.gif'.

Let me explain the command. We tell 'find' to search for all GIF files (*.gif) in the current folder (./) and subfolders. The '-iname' option tells 'find' to do a case-insensitive search. Using the '-exec' option, we tell 'find' to execute a command for every file it finds. 'find' considers the command to be everything that follows '-exec' until a semicolon (;) is found. We are telling 'find' to execute 'convert' for every GIF file that it finds. The '{}' represents the path and filename of a file found. We then finish the command with '\;'. The backslash is used to escape the semicolon, so the shell does not interpret it as a special thing.

The output files that we get might not be 24-bit BMP files. To do this, I had to execute the following command (after I executed the one above):

find ./ -iname '*.gif.bmp' -exec convert '{}' +matte '{}' \;

Then, I deleted the original files using:

find ./ -iname '*.gif' -exec rm -f '{}' \;

This way of converting images is very powerful for other applications. Let's say you need to resize a lot of JPEG images. You can use:

find ./ -iname '*.JPG' -exec convert '{}' -resize '375' '{}' \;

This command will resize the images that it finds so that they are 375px width. The height is adjusted automatically by 'convert' to preserve the aspect ratio.

Converting PDF files to images

This is easily done in Linux using ImageMagick. This application provides a command-line tool to convert between images formats. However, you can use it to convert a PDF file to an image file like a JPEG. ImageMagick seems to use Ghostscript for this purpose. See thread at

http://www.usenet-forums.com/php-language/35516-convert-pdf-image-format-imagemagick.html

To convert input.pdf to output.jpg use:

convert -density 300 input.pdf output.jpg

The argument 'density' specifies the resolution of the output file. 300 can be used for most purposes. The units are DPI. If you don't specify a density, the default (72) will be used. You can either specify the density as HORIZONTAL (like in this example to preserve aspect ratio) or HORIZONTALxVERTICAL.

You might experiment with different options of the convert command. The full documentation for this command is at

http://www.imagemagick.org/script/convert.php