titbits from the world less travelled

Archive for July, 2009

Installing XEN 3.x on Ubuntu/Fedora

I found the below links to install Xen on both ubuntu and fedora

1) http://mediakey.dk/~cc/ubuntu-howto-install-xen/

2) http://sysdigg.blogspot.com/2008/01/how-to-install-xen-in-fedora-8.html

Also you can use yum install xen to faster installation

posted by admin in linux and have No Comments

Why whitebox testing is effective?

Let me guess, by now you must have heard that whitebox testing is all about looking into the code and plucking errors from them. But its not all easy, thought would give some live example, where it could be used and how you can make use of it catch some critical errors.

Imagine you are testing a program to get the time a machine has been updated, like a windows update. Think your program is getting it in the format YYYY/MM/DD.

Sample program:

getUpdateTime{

var time = <get the time in format YYYY/MM/DD>

set(YYYY)

set(MM)

set(DD)

}

Now this would work only if the user has set his local time also in the above format. Imagine the user is in some other country and his settings are MM/DD/YYYY. Now this would surely crash, since its not matching at all.

This can be easily caught by white box testing.

Also adding you can reduce your test cases, by testing it whitebox rather than having to do by running your program on different OS of different languages.

posted by admin in Testing and have No Comments

MySQLDB: Python: Inserting date, integer, float and other variables into MySQL

The best way to insert values into a database using MySQLDB would be to simply use ‘%s’. This placeholder does all the work on conversion into other data types. You dont need to worry about converting any values into their respective datatypes in mysql.

posted by admin in python and have No Comments

opera browser beta 10 rocks

I have always been interested in the browser wars. Way back it was netscape which really impressed me. But after that came internet explorer. I was quite used to this and liked it might be because there was no where else to go and I didnt have to install by downloading the new softwares. I was a bit lazy on my part.

All that changed when I started using firefox. It was fast and sturdy. I am really happy with the new firefox 3.5 although it crashes sometime.

My curiosity led me to install Opera 9. According to my observations Opera browsers have always had a edge in speed compared to firefox while loading pages and videos.

But I can guarantee you this if you have tried out the new Opera Beta 10. It rocks. I am quite a opera fan from the start. The Opera Beta 10 is lightweight which solves the problem of the browser loading initially taking up memory space unlike the previous opera versions,

Its got a new Tab UI, faster engine and dont forget Opera Unite(although I havent been that happy with its service). I think I am going to use only Firefox and Opera from now on.
I think you might want to try this.

posted by admin in Uncategorized and have No Comments

Hello ALL: Palm OS SDK (Mojo) has been released

Hello All!!! Got this exciting news: Palm SDK has been released. Cant wait to get my hands on it…

As an applicant for the Palm webOS Mojo SDK early access program, we wanted you to be among the first to know that the Mojo SDK is now publicly available. This is a very exciting and important stage for Palm webOS development, and we want you to be part of it. We’re opening the doors to the SDK by launching a new developer portal at http://developer.palm.com called webOSdev, where you can download the SDK and accompanying documentation, and join the public webOS community forums.

I want to thank you for your patience while we allowed a few developers to kick the tires on our APIs, tools and docs before we released them to the rest of the world. We’re working hard to ensure that Palm webOS becomes a world-class platform for application development, but we need to do so in a measured and focused way so we can be sure we’re providing a great development experience and attentive developer support.

We know that a thriving app marketplace and a vibrant developer ecosystem are critical to the success of Palm webOS, and that relies largely on you. We think we have something amazing here, and we’re inviting you to join the Palm webOS community and help us fulfill the potential of this compelling new platform.

Welcome!

Michael Abbott
Senior Vice President, Application Software and Services
Palm, Inc.

posted by admin in palm pre and have No Comments

how to find out the file properties in vc++

You can make use of the header file fileversioninfo.h

This has methods to find out if a directory exists or a file exists. Below is a small example I used in unit tests to find out if a directory actually exists in mozilla firefox.
typedef std::basic_string myType;
typeCharStr profileInf;
profileIn = <>
Append a directory to the main string
bool isDir = PathIsDirectory((profileInf.append(Lextensions)).c_str());
Call CPPUnit to check if that particular directory is present or not.
CPPUNIT_ASSERT_MESSAGE(Error getting firefox profile directory<>,isDir == true);
posted by admin in Uncategorized and have No Comments

MySQLDb inserting data into a MySQL table with variables

Of the many ways to inset values into a MySQL database, we could use the below also:

insert_query = “INSERT INTO %s(symbol,\
date,open,high,low,close,volume) \
VALUES( %s,%s, %s , %s , %s , %s, %s )”
insert_cursor.execute(insert_query
%(symbol_Nasdaq,
symbol_Nasdaq,
row_Nasdaq[0],
row_Nasdaq[1],
row_Nasdaq[2],
row_Nasdaq[3],
row_Nasdaq[4],
volume_fin))

The above query will most likely give you an error stating the MySQL statement was not able to find a column name.

What actually happens is it translates one of your variables into a column by mistake or I am not sure about how this happens, but anyways the below query would definitely work.

insert_query = “INSERT INTO %s(symbol,\
date,open,high,low,close,volume) \
VALUES( ‘%s’,'%s’,'%s’,'%s’,'%s’,'%s’,'%s’)”
insert_cursor.execute(insert_query
%(symbol_Nasdaq,
symbol_Nasdaq,
row_Nasdaq[0],
row_Nasdaq[1],
row_Nasdaq[2],
row_Nasdaq[3],
row_Nasdaq[4],
volume_fin))

I just added a apostrophe for each variable. This correctly entered the data into my tables.

Tags:
posted by admin in mysqldb, python and have No Comments

Logic errors when searching for a repeated element in a loop

More than once I seem to have done this mistake. The situation is like this. I was inserting some elements into a database at irregular intervals. I needed to know that I dont insert duplicate symbols. So I was wrote a small method to check this. The below code is not exactly the same method, but its enough to explain the errors:

def rejected_symbols(symbol):
rejected_list = ['TRUE','CAST','ELSE','LONG', 'LOOP','TO']
for val in rejected_list:

if val == symbol:

{

return 0
else:

return 1

}

The above is a python snippet but I put the braces for clarity. Now what happens is we dont loop through the entire list. As soon as we see a single element doesnt match we return OR vice versa. Hence we are returning the incorrect value.

The correct logic would be

def rejected_symbols(symbol):
rejected_list = ['TRUE','CAST','ELSE','LONG', 'LOOP','TO']
for val in rejected_list:

{

if val == symbol:

{

return 0

}

}

to return at the end of the looping of the list, in this way we dont return when we find a true value.

posted by admin in python and have No Comments

mysql error 11001 in mysqldb

when trying to run a query in mysqldb from python I was getting the error 11001.

the best option would be run the query as below:

conn = ms.connect(host=”localhost”,port=3307, user = “root”, passwd = “”, db = “xxx”)

This error would be seen because I changed the port when I was installing MySql. So when mysql runs it checks for the default port in most installations 3306 and you get the error such that a particular localhost doesn’t exists and among others.

posted by admin in python and have No Comments

Memory Leaks when using windows handles

We use handles in most cases when opening up a file, for eg:

void methodA()

{

int xHandle = 0;

xHandle = open(“c:\windows\sys.txt”, O_RDONLY);

}

If we do not close this handle, we are bound to get a memory leak everytime we call this method. You can verify this by opening up task manager and checking the handles this function opens.

The best way to handle this is by closing the handle using:

close(xHandle) method.

This handles the memory leaks.

An easy to use handle finder:

http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx

posted by admin in windows and have No Comments