tag:blogger.com,1999:blog-10813356001856982352024-03-13T03:33:22.533-05:00The Underdog's Computer SpotThis spot is dedicated to computer issues and ideas. There will be articles related to web development, C++, operating systems, Linux, Windows, etc.
DISCLAIMER: NOTHING POSTED IN THIS BLOG IS GUARANTEED TO WORK AS EXPECTED. I WILL DO MY BEST, BUT I AM NOT LIABLE FOR ANYTHING.Andréshttp://www.blogger.com/profile/13374542931850629094noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-1081335600185698235.post-38731552910546232762009-08-12T12:47:00.006-05:002009-12-20T23:21:24.987-06:00Can the weight of a hard drive increase?<p align="justify"><b>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.</b></p><br /><p align="justify">A few days ago, I came upon a very interesting post in a Microsoft forum. Take a look at it:</p><blockquote><p align="justify"><em>Apologies if this is the incorrect area for this question.<br />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.<br />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.<br />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.<br />Thanks in advance!<br />- K</em></p></blockquote><p align="justify">I copied all of the grammar and English errors faithfully (Ctrl+C & Ctrl+V).</p><p align="justify">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:</p><p align="justify"><strong>First answer:</strong></p><p align="justify">It’s worth noting that this answer was “Marked as Answer” by the person who asked the question (K_McLovin).</p><blockquote><p align="justify"><em>Hi K_McLovin,</em></p><p align="justify"><em>Thank you for posting on Microsoft Answers Forum.</em></p><p align="justify"><em>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.</em></p><p align="justify"><em>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.</em></p><p align="justify"><em>If we are misunderstanding your question please clarify so that we may further assist you.</em></p><p align="justify"><em></em></p><hr /><br /><p></p><p></p><p align="justify"><em>Robyn<br />Microsoft Answers Support Engineer<br />Visit our </em><a href="http://social.answers.microsoft.com/Forums/en-US/answersfeedback/threads/"><em>Microsoft Answers Feedback Forum</em></a><em> and let us know what you think.</em></p></blockquote><p align="justify"><strong>Second answer:</strong></p><p align="justify">This can be considered an evil answer.</p><blockquote><p align="justify"><em>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. </em></p><p align="justify"><em>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.</em></p></blockquote><p align="justify">There were many other interesting answers and I invite you to read them. You can go to this thread using</p><p align="left"><a title="http://social.answers.microsoft.com/Forums/en-US/vistahardware/thread/720108ee-0a9c-4090-b62d-bbd5cb1a7605" href="http://social.answers.microsoft.com/Forums/en-US/vistahardware/thread/720108ee-0a9c-4090-b62d-bbd5cb1a7605">http://social.answers.microsoft.com/Forums/en-US/vistahardware/thread/720108ee-0a9c-4090-b62d-bbd5cb1a7605</a></p><p>Thank you</p>Andréshttp://www.blogger.com/profile/13374542931850629094noreply@blogger.com1tag:blogger.com,1999:blog-1081335600185698235.post-78771682367040852732009-05-17T20:49:00.002-05:002009-08-12T19:40:30.821-05:00How to mount an ISO image in Linux<p align="justify">Use the following command to mount an ISO image in openSUSE 11.0. It should work with other distributions.</p><p align="justify"><span style="color:#3333ff;">mount -t iso9660 -o loop <i><isoimage></i> <i><folder></i></span></p><p align="justify">You might need to replace <strong>loop</strong> by <strong>/dev/loop</strong>. <strong><isoimage></strong> is the ISO file, and <strong><folder></strong> is the folder to where you want to mount the files “inside” the ISO image.</p>Andréshttp://www.blogger.com/profile/13374542931850629094noreply@blogger.com0tag:blogger.com,1999:blog-1081335600185698235.post-37243779307423103872009-05-07T14:17:00.001-05:002009-05-07T14:17:18.294-05:00New Look!<p align="justify">Hi everybody</p> <p align="justify">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.</p> <p align="justify">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.</p> <p align="justify">I decided to be more active in my blog now that I am getting more visits.</p> Andréshttp://www.blogger.com/profile/13374542931850629094noreply@blogger.com1tag:blogger.com,1999:blog-1081335600185698235.post-77373528898415156792009-02-07T21:34:00.019-06:002009-12-20T23:23:05.567-06:00Remote access to KDE from a Windows desktop<p align="justify"><b>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.</b></p><br /><p align="justify">OpenSUSE is a nice Linux distribution because of its administration tool called <strong><u>YaST</u></strong>. Even if you use openSUSE in text-mode only, YaST is a very friendly system management tool. However, some of us still like the <em>look'n'feel</em> 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.</p><p align="justify">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.</p><p align="justify">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 <span style="FONT-STYLE: italic">forward</span> 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 <span style="FONT-WEIGHT: bold"><u>Xming</u> </span>and you can download it freely from</p><p align="justify"><a href="http://sourceforge.net/projects/xming">http://sourceforge.net/projects/xming</a></p><p align="justify">The installation is self explanatory. These are the options that I selected for the installation:</p><p align="justify"><img id="BLOGGER_PHOTO_ID_5300271517278202530" style="DISPLAY: block; FLOAT: none; MARGIN: 10px auto; WIDTH: 400px; HEIGHT: 308px; TEXT-ALIGN: center" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi47DctTTpTuf3O1Pr0aNBi121sdOpn09WVBdYZGcnrXT-2XStYcMTqjcqc-JGlMBIHsgP6JQjJgjP5RDitIXkIFDWuceJpoMF9WP8fXNHmOhUmk4Bi384p7cV4ddbD4-B8TSsabxojx6IV/s400/image1.jpg" /> </p><p align="justify">Also, instruct the installation program to place a shortcut for <strong><u>XLaunch</u></strong> on the desktop.</p><p align="justify"><img id="BLOGGER_PHOTO_ID_5300289015575593650" style="DISPLAY: block; MARGIN: 10px auto; WIDTH: 400px; HEIGHT: 308px; TEXT-ALIGN: center" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo2BNNsJ_1aMNA4ZYfjpotuXB4gN6MwN2MhABolzwId35-2XVLgZbk4QQVv1nt6fSNGXwiUgucZyc70o725LzbGAywTAed2R4rkbWWNAZN_tvXsPasxttd1iBQ8mOjoV1Tv_6mDB4408on/s400/image2.jpg" /> </p><p align="justify">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.</p><p align="justify">First, we need to make sure the SSH server is configured correctly to handle X11 forwarding. I took the following from</p><p align="justify"><a href="http://solaris.reys.net/english/2006/04/x11_forwarding">http://solaris.reys.net/english/2006/04/x11_forwarding</a></p><p align="justify">1. Open the file <span style="COLOR: rgb(51,51,255)">/etc/ssh/sshd_config</span><br />2. The following lines should be uncommented: </p><p align="justify"><span style="COLOR: rgb(51,51,255)">X11Forwarding yes</span><br /><span style="COLOR: rgb(51,51,255)">X11DisplayOffset 10</span><br /><span style="COLOR: rgb(51,51,255)">X11UseLocalhost yes</span></p><p align="justify"><span style="COLOR: rgb(51,51,255)"></span>3. Restart the SSH Deamon. In my Linux distribution, you just have to type:</p><p align="justify"><span style="COLOR: rgb(51,51,255)">rcsshd restart</span></p><p align="justify"><span style="COLOR: rgb(51,51,255)"></span>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:<img id="BLOGGER_PHOTO_ID_5300280885509212002" style="DISPLAY: block; MARGIN: 10px auto; WIDTH: 400px; HEIGHT: 307px; TEXT-ALIGN: center" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgSsj338kO62s4RYnCMbAk2svvf2K8NLJpNwXbBR1TlHsTEfmKu6xpnkF8-A-CK64e5Ma-Lzy1HauidWXXTCtLQcXcwEzdFzfsQCQcSfjQhoYTsaFs0GkEH2OiY6VeYlRZt3NCm-VqJkQj/s400/image3.jpg" /></p><p align="justify">Make sure you select "One window". Then, click next.</p><p align="justify"><img id="BLOGGER_PHOTO_ID_5300281738886874082" style="DISPLAY: block; MARGIN: 10px auto; WIDTH: 400px; HEIGHT: 307px; TEXT-ALIGN: center" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijMAZR0S8FGPBxMS2V2m6wfgWx297r6RvYQDmwX834o8uws36vJ6DC4ruwUpcA7YsKN4P_8Fq_hRr462N4nkAf-178IcBVcRRiUdwE1sAo8hX-PlBSjgzrC1Nei5hyphenhyphenFPZOBse19CEhQLOx/s400/image4.jpg" /></p><p align="justify">Select "Start a program" and click next.</p><p align="justify"><img id="BLOGGER_PHOTO_ID_5300282230580106338" style="DISPLAY: block; MARGIN: 10px auto; WIDTH: 400px; HEIGHT: 309px; TEXT-ALIGN: center" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYvgeocJiti8Uv3z4m-Wy3JaJ_BKJxUWMRHb1HNSbGYUFXI2f2LBsQhNZSpr6FaNj2fdoE9OSVbTfKbR-6Q5iWeDeHtV_Rr58hnVO9iatns8yV0xqXmURa3BLOrR28iVVQEq5tFbQUymkr/s400/image5.jpg" /></p><p align="justify">Enter "<span style="COLOR: rgb(51,51,255)">startkde</span>" 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.</p><p align="justify"><img id="BLOGGER_PHOTO_ID_5300283009979504402" style="DISPLAY: block; MARGIN: 10px auto; WIDTH: 400px; HEIGHT: 306px; TEXT-ALIGN: center" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFc8GHXOtFLMrTUhluktrwxzH-QB905NDqZxef9h9FdEie52JabxjycQCOXG9_frzbeKt0DWyTKFa1g179eYooPWSTPqGtWYT7T-plqL3Epq44vMfF3p5da6h-6y7S7B2hXVGUiQIgzHJr/s400/image6.jpg" /></p><p align="justify">Leave this additional parameters as they are and click next.</p><p align="justify"><img id="BLOGGER_PHOTO_ID_5300283421637727682" style="DISPLAY: block; MARGIN: 10px auto; WIDTH: 400px; HEIGHT: 307px; TEXT-ALIGN: center" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgY7UsrTDqi0_au14C2Dsubm1g_U7GjKlrXx1Ub3HkHEC0t8siQeaGlWBVNNOebIXIicTF9wRtMuTbx1xMfjs2C0r07oqSUFd_Q35VBpArjJEkNplbmdCTu8wIuwGVUxIdO70VPXxRvCBJ-/s400/image7.jpg" /></p><p align="justify">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.</p><p align="justify">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 "<span style="COLOR: rgb(51,51,255)">firefox</span>") instead of "<span style="COLOR: rgb(51,51,255)">startkde</span>".</p><p align="justify">A useful application of this is that you can run YaST in graphical mode by using the commands:</p><p align="justify"><span style="COLOR: rgb(51,51,255)">yast2 --qt</span><br />or,<br /><span style="COLOR: rgb(51,51,255)">yast2 --gtk</span></p><p align="justify">I hope this post was helpful</p>Andréshttp://www.blogger.com/profile/13374542931850629094noreply@blogger.com27tag:blogger.com,1999:blog-1081335600185698235.post-22853824146688793832009-01-31T12:27:00.019-06:002009-05-07T21:12:17.925-05:00Valid Javascript in XHTML<p align="justify">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).</p> <p align="justify">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.</p> <p align="justify">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:</p> <div class="customcode"><code><?xml version="1.0" encoding="UTF-8"?> <br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br /><html xmlns="http://www.w3.org/1999/xhtml"> <br /> <br /><head> <br /><title>My Document</title> <br /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <br /><script language="JavaScript" type="text/javascript"> <br /> <br />function initScript() { <br /> <br />myArray[0] = "Element 0"; <br />myArray[1] = "Element 1"; <br /> <br />for(var i=0;i<myArray.length;i++) { <br />alert(myArray[i]); <br />} <br /> <br />} <br /> <br /></script> <br /> <br /></head> <br /> <br /><body onload="javascript:initScript();"> <br /><div>Hello World</div> <br /></body> <br /> <br /></html></code></div> <p align="justify">If we try to validate this document at</p> <p align="justify"><a href="http://validator.w3.org/#validate_by_input">http://validator.w3.org/#validate_by_input</a></p> <p align="justify">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.</p> <p align="justify">I found different methods online to tell this to the validator, but the best one that I found was at</p> <p align="justify"><a href="http://javascript.about.com/library/blxhtml.htm">http://javascript.about.com/library/blxhtml.htm</a></p> <p align="justify">We enclose the Javascript code using:</p> <p align="left"><span style="color: rgb(51,51,255)">/* <![CDATA[ */</span> <br /><em style="color: rgb(51,51,255)">Javascript code;</em> <br /><span style="color: rgb(51,51,255)">/* ]]> */</span></p> <p align="justify"><span style="color: rgb(51,51,255)"></span>For my example, the final document would look like this:</p> <div class="customcode"><code><?xml version="1.0" encoding="UTF-8"?> <br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br /><html xmlns="http://www.w3.org/1999/xhtml"> <br /> <br /><head> <br /><title>My Document</title> <br /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <br /><script language="JavaScript" type="text/javascript"> <br />/* <![CDATA[ */ <br /> <br />function initScript() { <br /> <br />myArray[0] = "Element 0"; <br />myArray[1] = "Element 1"; <br /> <br />for(var i=0;i<myArray.length;i++) { <br />alert(myArray[i]); <br />} <br /> <br />} <br /> <br />/* ]]> */ <br /></script> <br /> <br /></head> <br /> <br /><body onload="javascript:initScript();"> <br /><div>Hello World</div> <br /></body> <br /> <br /></html></code></div> Andréshttp://www.blogger.com/profile/13374542931850629094noreply@blogger.com1tag:blogger.com,1999:blog-1081335600185698235.post-65573027213530638862009-01-30T19:46:00.018-06:002009-05-07T21:15:12.724-05:00Converting a lot of images<p align="justify">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?</p> <p align="justify">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.</p> <p align="justify">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.</p> <p align="justify">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.</p> <p align="justify"><span style="font-size: 100%; color: rgb(51,51,255)">find ./ -iname '*.gif' -exec convert '{}' '{}.bmp' \;</span></p> <p align="justify"><span style="font-size: 100%; color: rgb(51,51,255)"></span>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'.</p> <p align="justify">Let me explain the command. We tell 'find' to search for all GIF files (*.gif) in the current folder (<span style="font-family: courier new">./</span>) 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 (<span style="font-family: courier new">;</span>) is found. We are telling 'find' to execute 'convert' for every GIF file that it finds. The '<span style="font-family: courier new">{}</span>' represents the path and filename of a file found. We then finish the command with '<span style="font-family: courier new">\;</span>'. The backslash is used to escape the semicolon, so the shell does not interpret it as a special thing.</p> <p align="justify">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):</p> <p align="left"><span style="font-size: 100%; color: rgb(51,51,255)">find ./ -iname '*.gif.bmp' -exec convert '{}' +matte '{}' \;</span></p> <p align="justify"><span style="font-size: 100%; color: rgb(51,51,255)"></span>Then, I deleted the original files using:</p> <p align="left"><span style="font-size: 100%; color: rgb(51,51,255)">find ./ -iname '*.gif' -exec rm -f '{}' \;</span></p> <p align="justify"><span style="font-size: 100%; color: rgb(51,51,255)"></span>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:</p> <p align="left"><span style="font-size: 100%; color: rgb(51,51,255)">find ./ -iname '*.JPG' -exec convert '{}' -resize '375' '{}' \;</span></p> <p align="justify"><span style="font-size: 100%; color: rgb(51,51,255)"></span>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.</p> Andréshttp://www.blogger.com/profile/13374542931850629094noreply@blogger.com1tag:blogger.com,1999:blog-1081335600185698235.post-29679787029246713282009-01-30T19:24:00.005-06:002009-05-07T21:19:14.207-05:00Converting PDF files to images<p align="justify">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</p> <p><a href="http://www.usenet-forums.com/php-language/35516-convert-pdf-image-format-imagemagick.html">http://www.usenet-forums.com/php-language/35516-convert-pdf-image-format-imagemagick.html</a></p> <p align="justify">To convert input.pdf to output.jpg use:</p> <p><span style="color: rgb(51,51,255)">convert -density 300 input.pdf output.jpg</span></p> <p align="justify">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.</p> <p align="justify">You might experiment with different options of the convert command. The full documentation for this command is at</p> <p><a href="http://www.imagemagick.org/script/convert.php">http://www.imagemagick.org/script/convert.php</a></p> Andréshttp://www.blogger.com/profile/13374542931850629094noreply@blogger.com1