Desi Habits

Got the following list as a forward. Being quite a typical desi, I do have to agree with quite a few of them 🙂

  • The only reason you go to a temple on festivals is because there is free food.
  • You keep comparing prices at electronics store for the phone you bought six months ago.
  • You bought a Toyota or Honda car only because it has better resale value.
  • You ask for a small drink at fast food restaurant because the refill is free.
  • You spent 2 days cleaning your apartment before leaving so you can get full security refund from your landlord.
  • You don’t know any American outside your work.
  • You try to ignore all other unknown desis around you.
  • You talk to Americans as if you represent your whole country.
  • You frequent to yard sales every week.
  • You use grocery bags as garbage bags.
  • Office supplies mysteriously find their way in your house.
  • You don’t want to buy a printer because you can always use the office printer.
  • You decide to marry a girl/guy that your parents fixed you up with.
  • You split the tax from your common grocery bill.
  • You know more than one plans offered by long distance companies.
  • You take plain water instead of Coke for lunch.
  • You take any drink with no ice because you can’t drink ice.
  • You ask before eating any meat “Is this beef?”
  • You know all the facilities available at public library.
  • You find taco bell sauce packets in your kitchen drawer.
  • You take off your shoes before stepping foot in your living room.
  • You like onion rings at Burger King.
  • You are looking for dual voltage appliances and GSM cellphones
  • The number of long distance calls is more than domestic calls.
  • Your first name ends with kumar, bhai or ben
  • You have at least one India made pressure cooker in your kitchen.
  • You know how much a 7 layer burrito costs at Taco Bell.
  • Put oil in your hair.
  • You have a picture of Indian Deity on the dashboard of your car.
  • This thought comes to you “Oh Shit I just saw another desis” when you are window shopping at a local mall.
  • You are compelled to visit every major city in U.S. just so as to say that “Yes, I have been there”.
  • You pay your bills the day they come in mail.
  • You buy rice in the 20lb bags or larger.
  • You have postponed buying answering machine because the phone you are planning to buy six months later has built-in answering machine.
  • You start spelling your name to the operator like A as in Apple, B as in boy, T as in train… well you get the idea.
  • You bring over the counter medicine like Iodex and Vicks from India
  • You know the current differential in gold prices between India and U.S.
  • Use the credit card with maximum cash back
  • You have collected enough frequent flier miles for an international trip.
  • You are saving more than 30% of your salary.

Remove menu icons in Mac

I had a lingering networking related icon in the menu bar that I could find a way to get rid of. I tried looking at all the settings I could find in System Preferences to get hide the icon, but was unsuccessfuly.

Finally after googling a bit, I came to know that it is infact very very simple to do this.

Hold down the command key and drag the icon out of the menu bar. Done.

Connect to MS SQL Server using JDBC

The following example shows a java class that can be used to verify if you connection to MS SQL Server using JDBC is working properly. The following code establishes a connection to MS SQL server and then executes a query to print system tables. You need to get Microsoft’s JDBC drivers or jTDS JDBC drivers.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class ConnectMSSQLServer
{
   public void dbConnect(String db_connect_string,
            String db_userid,
            String db_password)
   {
      try {
         Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
         Connection conn = DriverManager.getConnection(db_connect_string,
                  db_userid, db_password);
         System.out.println("connected");
         Statement statement = conn.createStatement();
         String queryString = "select * from sysobjects where type='u'";
         ResultSet rs = statement.executeQuery(queryString);
         while (rs.next()) {
            System.out.println(rs.getString(1));
         }
      } catch (Exception e) {
         e.printStackTrace();
      }
   }

   public static void main(String[] args)
   {
      ConnectMSSQLServer connServer = new ConnectMSSQLServer();
      connServer.dbConnect("jdbc:sqlserver://<hostname>", "<user>",
               "<password>");
   }
}

Change <hostname>, <user> and <password> to the correct values. Also, if you use the jTDS drivers, the driver class should be set to net.sourceforge.jtds.jdbc.Driver.

Removing tags from WordPress posts content

I have been using WordPress since version 1.x and back then there was no native support for tags in WordPress. Easiest thing to add tags to post was to use UTW or other plugins and because of my new found love for tags then, I started using WP-Tagerati and then moved on to Ultimate Tag Warrior. Using these plug-ins meant adding custom tags such as

<tags>foo, bar</tags>

or

[tags]foobar[/tags]

into each post. The plug-ins would parse the post for these custom tags and then tags could be displayed using some APIs provided by the plug-in.

Since v2.3, wordpress now comes with built in support for Tags. This has eliminated the need for using the above mentioned plugins. So, I decided to get rid of them. On disabling the plugins, I noticed that the custom tags along with the tagging information were appearing as post content. To fix this issue, I initially started using Embedded Tag Thing but finally decided to get rid of the tagging information from the posts altogether. Before you do get rid of the tags, do make sure that you import them into wordpress’s tag data, so that you don’t loose this information totally.

Considering that you have a standard installation of WP, fixing this problem is a breeze if you don’t mind playing a bit with phpMyAdmin. Just do the following:

0. Backup WordPress
Backup you WP database. Always, backup your database before going in for direct manipulation of WP data. You can get a whole lot of information by reading about it here.

1. Download Posts table using phpMyAdmin
Go to the phpMyAdmin URL for you WP installation’s database. You can do this by using the very useful WP-phpMyAdmin plugin. As shown in the following screenshot, select the wordpress database that you have configured from the dropdown menu. And then select the wp_posts table. This will refresh the frame on the right side to display the wp_posts table.

Now, we are going to export the posts table. To do this, select the Export tab –> check the Add DROP TABLE checkbox –> hit Go. See the screenshot below.

This will take you to a page that contains a textbox with an SQL script in it. Copy the contents of the textbox and save them in a file.

2. Edit the file
Open the file in your favorite editor. You will see the SQL Dump that contains a lot of queries. Now, run a regex replace query on the content using the regex

\[tags\].+?\[/tags\]

This should go though you posts and remove all strings of the type [tags]foobar[/tags]. Change the regex to suit the way you have declared tags in your posts.

3. Import the file contents into wp_posts table
Go to phpMyAdmin and click on the import tab. See the screenshot for reference. Browse to the path where the modified file is located and just hit Go.

This should upload the file contents and execute the SQL queries in the file. If it fails and you see an error complaining about SQL_MODE being set to NO_AUTO_VALUE_ON_ZERO, just add a “” in front of the statement

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

to comment it out and then try to upload the file again. If things work out fine, you will see a message that says something like “X queries were successfully executed“.

There you go, you are done, If you check the posts contents now, you will not see the tags information. And no need to use any plugins to explicitly manage these tags anymore. Though I do suggest using Simple Tags to gain more control over your tag management.

VMware Player and Ubuntu 8.10 keyboard mapping issues

Yesterday I installed VMware Workstation 6.5 on my fresh install of Ubuntu 8.10. After powering on a Windows XP vm, I realized that I could not use the arrow keys properly. On hitting the left arrow key, start menu was being displayed and other arrow keys had similar issues. Also, using VMware player was completely impossible as ctrl-alt-del wasn’t working.

After searching around a bit I found that many others had faced similar issue. Apparently it is not a bug with VMware Workstation. Due to some updates to Ubuntu 8.10, the keyboard mappings were screwed up. I found good amount of information in the VMware communities forum.

To fix this issue, you simply need to run the following command,

echo 'xkeymap.nokeycodeMap = true' > ~/.vmware/config

and if VMware Player/Server/Workstation was running, just restart it.

You should then be good to go…