Sharing Folders in Ubuntu 9.10 using VirtualBox

I just wanted to share a folder in Ubuntu 9.10 which I have installed using VirtualBox. Whenever I tried mounting the shared folder using the mount command, I kept getting the following error:

/sbin/mount.vboxsf: mounting failed with the error: No such file or directory

After wandering through forum after forum and post after post, I finally got to share my folder in Ubuntu 9.10 using VirtualBox. The whole process was a mesh so I thought I should create a simple post, so here goes:

Adding Share Folder to VirtualBox

  1. Start by opening VirtualBox (making sure Ubuntu is Powered Off), right-click the Ubuntu Virtual Machine in the left column and choose Settings
  2. Click Shared Folders option in the left column
  3. Click the Add new shared folder button (its a folder with a + sign) located on the right
  4. A small window pops up asking you the Folder Path (a drop-down) and a Folder Name (no spaces)
  5. Once you are happy with everything, press OK twice to close this pop up and the Settings window. Now start the Ubuntu 9.10 Virtual Machine

Mounting Shared Folder in Ubuntu 9.10

  1. Start the Terminal by going to Applications > Accessories > Terminal
  2. Create a folder under mnt directory by:

    sudo mkdir /mnt/my_shared_folder

    replace my_shared_folder with whatever you want to call the shared folder

  3. Now mount the shared folder by:

    sudo mount -t vboxsf my_folder /mnt/my_shared_folder

    replace my_folder with what you entered in the Folder Name when you added the folder under Settings and replace my_shared_folder with whatever you have called the folder in the previous step

  4. You’re done!

Please do leave a comment if this works for you 🙂

Flattr this!

Function to dynamically resize images using jQuery

UPDATE: I have created a jQuery plugin that dynamically resizes the images. It is faster and is optimized better (minified).

I have noticed that there has been quite a bit of interest in my post about dynamically resizing images using jQuery. I have created a function to do this job better. Not only it makes the code cleaner but it also makes it a lot easier to use it.

First, for those people looking for a quick lookup of solution, here is the optimized version of the function followed by a couple of examples to use it:

And now the explanation.. The function takes one argument, a number, which is the maximum height and/or the width of the image. The function automatically decides what is the best way to resize the image as its all calculated from the proportions of the original image.

What follows below is an expanded (non-optimized) version of the function and explanation on what each statement does:

NOTE: I do highly recommend using the optimized version of the function above

Line 1 declares the function “resize” and accepts a variable for maximum height/width.
Line 2 stores the Math.ceil function to a single letter variable for calling up later by m(). It is same as calling Math.ceil() and is done this way for reducing the size of the script (called minifying).
Lines 3 to 5 check if a maximum height/width was specified, if not, the script defaults to a maximum size of 200px.
Line 6 & 7 sets two variables ‘h’ for height and ‘w’ for width to the maximum size. One of these variables will be changed depending up the proportions of the image being resized.
Line 9 starts the jQuery.each function that iterates over each image one by one.
Line 10 stores the image’s height to a variable and is for reducing the size of the script.
Line 11 stores the image’s width to a variable and is for reducing the size of the script.
Line 12 checks if the image height is greater than the image width.
Line 13 only executes when the image’s height is bigger than the width. It calculates the image’s new width with proportion to its original size (which would be less than the height).
Line 14 is basic else statement.
Line 15 only executes when the image’s width is bigger than the height. It calculates the image’s new height with proportion it its original size (which would be less than the width).
Line 17 uses the jQuery’s built-in CSS function to set the new height and width for the image.

Flattr this!

Realtek’s network controller deep sleep mode issue

As I’ve noticed a fair bit of visitors interested in my post of Windows 7 and Network Controller Deep Sleep Mode problem, I thought I should write a “clean” version of the post (basically the fix for the problem minus my ramblings 🙂 )

The problem starts when the computer goes into sleep/standby mode, a few components of the PC including the network controller (or adapter) are turned off. The issue occurs when the PC wakes up and power to everything is restored. The network controller doesn’t come on and as per Realtek installation message:

The Realtek Network Adapter/Controller was not found.
If Deep Sleep Mode enabled Please Plug the Cable

The best fix is to reset the motherboard and the best way to reset your motherboard is to remove your RAM chips. Leave them out for some time (in my case 30 seconds) and put them back in. And that is all! The motherboard will be reset and the network controller will come out of deep sleep mode!

Note: If this doesn’t work, leave the RAM out for good 10 minutes. Leaving the RAM out longer has worked for some people (see comments below).

Note 2: For laptops, removing the battery for 5-10 minutes has worked for a few.

Note 3: If nothing works, turn off the system and plug in a external hard drive (or a USB thumb drive) and then turn the computer on. Once on the desktop, Windows will try to install the external hardware. This, in some cases, has worked and wakes up the network controller.

Note 4: Some people have reported that “Loading Default Settings” in the BIOS solves the issue as well. You will need to go into the BIOS at start up by pressing the Delete key (can be F2 or some other, please check the message at the start of the screen). Once in BIOS, you can press F10 to “Load Default Settings” (If you don’t see that, look for a button saying that. It is usually around the “Save & Exit” Button). Once loaded, hit “Save & Exit”. This will restart your computer and some people have reported this fixes the issue.

Once you have it working, to make sure the network controller doesn’t go into sleep mode again, try this:

  1. Open Device Manager by:
    1. Go to Start
    2. Click Control Panel
    3. Choose System and Security
    4. Click Device Manager (under System)
  2. Open Network Controller properties by:
    1. Double-click Network adapters to expand it
    2. Double-click the Realtek Network Controller
  3. Turn off Deep Sleep mode by:
    1. Choose the Power Management tab
    2. Untick “Allow the computer to turn off this device to save power”

Doing this will make sure the network controller is not put in to sleep mode till someone fixes the issue!

Finally, if something does work you please post the Motherboard/Laptop model and the method that worked to help others!

Flattr this!

Google launches Rich Snippet Testing Tool

Now this is one feature (tool) that I’m really really excited about! Why? Because I suggested it this summer! And I have proof 😉

Posted on YouTube on 19 August 2009

Adeel from Manchester, UK asks:ac
“When do you recon Rich Snippets will be made widely available? Can I suggest a tool in Google Webmaster Tools that lets you view (or preview) Rich Snippets from your site?”

This video is part of a “Grab Bag” series in which Matt Cutts, head of Google’s Webspam team, answers questions from users.

At the time Matt Cutts played down saying: “[…] its a good suggestion […]” and recommend that we look at the current website using Rich Snippets and try to understand how they have implemented them.

And, to be honest, I was happy with the answer. But I was thrilled to see the notification in my Google Reader saying there is an update about Rich Snippets.

Rich Snippet Tool

Rich Snippet Tool

The tool is pretty good, all you have to do is enter a URL of a page that has microformats or RDFa format embedded in the HTML. When you hit the magic button, the tool displays an example of the Rich Snippet which includes the star rating and the extra information (in this case the price info).

What I really like about the tool is that it goes a step further and shows the extracted information. This is really helpful when debugging the formats. One other hidden gem is the rating calculation which clearly specified how the rating that is shown in the format of stars was achieved.

Finally, I want to tip my hat in thanks and recognition to the Google Webmaster Team and anyone involved in making this tool!

Flattr this!

No network adapter/controller found on waking up from Sleep Mode

UPDATE: I’ve made a separate post for people interested in quick fix: Realtek’s network controller deep sleep mode issue

Yes, you read the title right. It is my second day of Windows 7 and trust me it was a long one. Its 1 o’clock in the morning and I finally got my internet working (after I got my Network Controller to work). So, lets start from the top.

Windows 7 does not like waking up from sleep

As it seems, Windows 7 really doesn’t like waking up from “Sleep” mode, most of the times for me, it just crashes. When I say crashes, it means I get a message on my monitor screen saying “No video input”, and the system is frozen because pressing the Num Lock key does not make the light of Num Lock go off.

No internet connection

I restarted the system (something I hate to do as it is my fresh install!) and was greeted by the screen asking me if I wanted to do a clean start up or try to restore the sleep mode again (as if it was my fault!). I had some work to do, so I jumped to the clean start up option and went straight onto Windows 7 desktop. So far so good. But then I noticed, Windows was screaming at me that I had “No internet connection”!

Network Controller/Adapter Gone

I went through several steps and came to conclusion that my network adapter had ‘died’, ‘gone to sleep’, ‘cuckooed’! It seemed that Windows 7 just could not see my Network Controller/Adapter, as if it has disappeared or vanished or just didn’t exist! There wasn’t even a section for Network Adapters in Device Manager.

Network Controller in Deep Sleep Mode

I tried to install the drivers for my Network Adapter (RealTek by the way) but I got a really nice error message during the RealTek setup:

The RealTek Network Adapter/Controller was not found.
If Deep Sleep Mode enabled Please Plug the Cable

And that’s when I noticed something interesting, my network adapter wasn’t flashing. Just for curious minds, I own a SilverStone Raven (photo) in which the whole motherboard is turned 90° clockwise and the back-panel becomes the top-panel. This means, luckily, I could saw the problem.

Getting your Network Adapter/Controller Back

I instantly knew this isn’t a Windows 7 only issue. The first thing popped in my head I have to reset my motherboard. As I own a M4A79T Deluxe, resetting is as simple as sliding the RAM out and popping it back in (the normal way of resetting your motherboard by using BIOS/CMOS jumper).

And guess what, it did the job. I got my Network Controller/Adapter back!

Once I got my internet back, I tried to find out why does Windows 7 crash on trying to wake up from Sleep mode, I believe it has something to do with the S1 and S3 settings in the BIOS. I will investigate and report back here soon. But for people having trouble getting the Network Controller working, I hope this helps.

Flattr this!