Categories
MySQL PHP Tips

A PHPMyAdmin alternate with a user friendly interface

Almost all LAMP Developers start their careers with the use of PHPMyAdmin which is a reasonable MySQL client to begin with but I think PHPMyAdmin hasn’t evolved with the same pace as rest of the Web Development tools have.

MyWebSQL on the other hand is as robust as PHPMyAdmin with a user friendly interface and almost everything a Web 2.0 Application needs. Moreover, its open source too, free to use with plenty of support for users from the development team.

Categories
Tips

Most common mistake many under grad students in Pakistan make

Pakistan has quite a noticeable share of its population as young students and professionals. Everyone in Pakistan is hoping this youth will bring a brighter and better future with them. Which I believe we can, we have done it in the past and we are still doing it. We are producing exceptional talent in almost every field with the minimum possible resources and dedication to groom these jewels.

I think the part above was enough for practicing my below average writing skills, I will get back to the point.

The most common mistake that I have noticed freshly graduated students do is using an improper + non-professional email address for job hunt and other professional activities.

I personally know many students who were not called for an interview just because of their email addresses. Come on guys, how much time does it take to create a simple email address having your first and last name in it. Why would you want to tell the employer how cool, hot, sexy, kid, champ etc you are.

People are even moving away from using yahoo.com and hotmail.com for their professional email addresses. An email address like one of the following will do it

Consider First to be the first name and Last to be the last name in these examples :

  • first.last@…
  • last.first@..
  • first.last1@..
  • first.last{any_number}@…     // use this if above are not available
  • firstl@…    //using the initial of last name or first name with the other name
  • lfirst@…

These are just general examples to give you an idea of how simple it is to create an email address which won’t make the other person laugh. This seems very obvious, and yet I have seen resumes with inappropriate email addresses.

A friend of mine, Umair Ali Rashid, gave a very good suggestion that Universities should provide every student with an email address from the beginning of their Degree Programs, which can then be used on their resumes as well. This practice is being followed in many Universities outside Pakistan, however there is no Pakistani University doing this in my knowledge. At least not my University.

Follow me on twitter – @umairr

Categories
Code How to Tips Wordpress

Template Path in WordPress Child Themes

WordPress Child themes are a great Idea to extend the theme a bit without getting your hands dirty with the big deal, but I encountered a problem with my child theme when I wanted to load some of my Javascript files which I kept with in the child theme so that the parent theme remains unchanged and all the development is also done in one directory.

When I tried loading the Javascript using the Template path obtained by

$template_path = get_bloginfo('template_url');

I got the path to the parent theme which of course is wrong in my case as my JS file was in child theme’s folder.

I had to make a custom function to get my child theme’s path. I am copying this function below for people who are facing the same issue. Feel free to copy this function into your functions.php file of your child theme. If you don’t have a functions.php in your child theme then create one


function get_childTheme_url() {
    return dirname( get_bloginfo('stylesheet_url') );
}

After copying this function in functions.php, call this function anywhere to get the path to your child theme; as shown below

$template_path = get_childTheme_url();

Share this article if it was of any help, that might help others as well.

Categories
How to Tips Virtualization

Sharing files with a linux guest on VirtualBox

One of my friends recently installed Ubuntu on a VirtualBox, and he had a really tough time sharing files between the Ubuntu guest and the Windows 7 host machine. In this article I will describe the two most common ways to share files between the host and a *nix guest os inside VirtualBox.

Some information in this article assumes you are fimilar with working on a linux command line. Even if you have not used the linux commandline before, fear not, as you can copy and run the commands without any modification on a Ubuntu guest machine. For other versions of linux, you might be required to make a few changes to the commands (mentioned wherever possible)

Let’s get started. Assuming you have already performed the following steps before we can enable file sharing between the host and guest machine.

1. Create a virutal machine for Ubuntu in VirtualBox.
2. Install Ubuntu (its free!)
3. From the machine settings, enable Network adapter (either bridged or host only adapter, host-only is recommended) and shared folders.
4. Login once onto the Ubuntu GUI with your userid and password.
5. Install Guest Additions on the Ubuntu machine from the VirtualBox GUI and restart the machine once.

Now we are ready to start sharing files between our host and guest os.

Sharing files over the Network

  • Right click the Network Icon on the top right corner of desktop and select ‘Edit  connections’.
  • Double click the ‘auto eth0’ entry and select the ‘IPv4 ettings’ tab on the dialog that just opened.
  • Depending on whether you selected briged network or host-only adapter for the virtual machine setting, configure the network. I usually prefer host-only network as it keeps the machine secure and the data transfer is pretty fast, not to mention hassle free configuration.
  • Once the network is configured, Open network browser using the Menu ‘Places -> Network’ on the top left of screen.

You should see ‘Windows Network’ as a folder in the explorer pane. Double click it and you should also see your host machine name displayed. Inside it you will see your folders listed that you shared over the network. Please note that you might be required to enter a valid Windows machine userid/password when you access the folder.

Configuring and using Shared Folders

  • In VirtualBox GUI, open virtual machine settings and select ‘shared folders’ tab.
  • Click the plus sign icon. In the dialog, enter the path to the folder on your host machine which you want to share, and also give it a name. For this example, I will name it ‘Shared’. Uncheck ‘Auto-mount’ option and check ‘Make Permanent’ option. This will make sure when the virtual machine restarts, the folder will still be accessible inside the machine.
  • Back to the virtual machine, if you are comfortable with text file editing in linux, add the following line to /etc/fstab file (you might need to use sudo)
    Shared /media/sf_Shared vboxsf defaults,rw,uid=1000,gid=1000 0 0
  • Alternatively, open a new Terminal from the Applications -> Acessories menu on top left of screen and run the following command inside the terminal.
echo "Shared /media/sf_Shared vboxsf defaults,rw,uid=1000,gid=1000 0 0" | sudo tee -a /etc/fstab

This will have the same effect as if you edited the file as described above.

  • Now run the following command inside the Terminal
sudo mount -a

If all went well, you can now use the shared folder inside your virtual machine. Open Places -> Computer from the top left menu. Open FileSystem and then double click the ‘media’ folder. You should see a folder called ‘sf_Shared’. This is the folder you just shared from your host machine. If you get ‘access denied’ error, you will need to do a bit extra to access the folder, which is also described at the end of this article.

Troubleshooting folder access problems

In some cases (usually when Ubuntu has more than one user accounts), you will get access denied errors when you try to access a shared folder. To fix this problem, try the following:
Open a Terminal window and type the command ‘id’ (without the quotes). The output will be something like this

uid=1005(samnan) gid=1005(samnan) groups………..

Note the uid and gid number from the command output. Now instead of the original command we used to enable shared folder inside the virutal machine terminal, type the following command, replacing <<uid>> and <<gid>> with the numbers you just picked from the ‘id’ command output.

echo "Shared /media/sf_Shared vboxsf defaults,rw,uid=<<uid>>,gid=<<gid>> 0 0" | sudo tee -a /etc/fstab

Follow the rest of the steps as usual and you should be able to access the folder without any problems.

Categories
How to Tips Virtualization

Cloning a Virtual Machine in VirtualBox

Update: As of version 4.1.0 and above, VirtualBox GUI has support for cloning a virtual machine. The following method still applies to older versions, however, you are encouraged to upgrade to the latest version for best experience.

VirtualBox has emerged as a viable free alternative to the popular vmware virtualization platform. While it contains less features than vmware, it still is very good at running virtual machines at fast speed without much problem, allowing you to test your software and perform lots of other useful experiments inside virtual machines without affecting your main system.

VMWare has a very nice feature that allows you to ‘clone’ a virtual machine easily from its main interface. It takes a few minutes depending on the size of harddisk, and gives you a copy of the machine at the end of the process. VirutalBox, while being pretty neat at doing other stuff, has no such option in its GUI. Here’s how you can clone a machine for VirtualBox with the minimal effort.

The cloning process involves these steps:

  1. Open a command prompt on your system.
  2. Navigate to the folder where the harddisk of the source vm resides
  3. Clone the virtual disk file into a new one
  4. Create a new machine with the new hard disk and same specs as the source machine

Open a command prompt and use the following commands to complete the second and third step.


cd E:\VM\VBOX\

set path=%path%;C:\Program files\Oracle\VirtualBox

vboxmanage clonehd MYXP.vdi MYXP_2.vdi

In the above, replace E:\VM\VBOX\ with the path where your virtual machines are stored. This can be found by going to VirtualBox preferences. The second line contains the installation path for VirtualBox (the one presented here is the default for VirtualBox 4.xx installation)

vboxmanage is the actual goodie that comes with VirtualBox and can be used for lots of neat stuff once you get hold of it. The last command creates a copy of the harddisk file as another virtual harddisk. This is MUST, because simply copying the hard disk file from explorer will not allow you to use that file as a valid hard disk.

Once you run the last command, it will show some progress and once complete, you will have a copy of the old hard disk file as a new one by the name MYXP_2.vdi

There is only one thing left to do now. Open Virtual box GUI and create a new virtual machine with the same specs as the one you created for the first machine (I am sorry, but at the moment this is the fastest and neatest way to do this step)
Select the hard disk you created by cloning earlier above and you will have a new machine with the same configuration and hard disk state as the previous one.

Categories
Facebook How to Tips

How to clear Facebook Share’s Cache

Facebook share is good, simple, lets us share almost everything on web in seconds. But Facebook caches already shared urls/pages for better performance. This causes issues at time when we update the title, picture being shared or the description of the page because Facebook still shows the older version of the page.

For modifying which image, title and description FB chooses, read this

I will discuss three simple ways to force facebook to go and fetch the latest stuff from the page being shared.

Method 1 :

Facebook treats each url as unique and caches the page based on that url, so if you want to share the latest url the simplest solution is to add a query string with the url being shared. In simple words just add ?v=1 at the end of the url. Any number can be used in place of 1,

This method is fairly simple but it doesn’t retain the share count for this page, as it treats this page as a different url hence the count for this url will be restarted from 0. Plus if someone else shares the original url without the querystring the information will still be the old one.

Method 2:

Using url shortner services like bit.ly. shorten your url form bit.ly and then use the new url for Facebook share. This too is a simple and quite popular method but has the same issues as the first one.

Method 3:

Facebook has a tool called Debugger (formerly known as URL Linter). This tool gives us an idea about how a url will be shared on Facebook, what content, which image will be fetched. Further details about this tool can be found here.

We can use this tool for any url and it fetches the latest title, description, excerpt and other stuff that will be shown while sharing the link. If you use an already shared URL with this tool then Facebook fetches the latest content, and also updates it cache with the latest content.

With this methos the url remains the same hence the share count will persist and the content will be updated. Someone else sharing the url will also see the latest content now. So this method is of course the best.

The Debugger tool can be accessed here.

Found this post helpful? Want to return the favor? Use the button below :)