Saturday, August 08, 2009

N81 Keypad Cleanup!

I got my Nokia N81 wet (only a bit though) and the keypad promptly went dysfunctional. I could attend calls by flipping the screen but was not able to get any keys to work. So I discharged it and let it dry for a couple of days and started working fine. But the problem started reoccurring when I accidentally let its charge drain completely.

I 'google'd the disassembly procedure and found this really great step by step disassembly guide.


So I followed it, opened up my phone and found a a few strands of hair and dirt beneath the mini keypad I cleaned the area and Presto! the phone started working again So this might actually be a quick fix if you really aren't interested in buying a new phone or paying to service it.


*** Warning***

The LCD display's cover (in picture 6 in the link) is actually held together by an adhesive, so fixing it back can get real messy and it keeps following off... so it would possibly be a good idea to glue it back (not with perm glue unless you want to break it open the next time).

Thursday, July 23, 2009

Some Java Programming Interview Questions

I am going to add some Java programming questions that I have come across in interviews recently. I have tried to provide solutions but of course there might be better ways to do them...

Check if given string contains a valid FID number. If it is not valid, return "invalid". If it is valid, convert the string to one of two formats depending on the input valid of EntityType:

i) If the EntityType value is P (Personal), convert the string to "XXX-XX-XXXX" format.
ii) If the EntityType value is B (Business), convert the string to "XX-XXXXXXX" format.

You can assume the EntityType is set correctly to either P or B.

Valid input formats when EntityType = P are: 123-44-9876, 123449876, 123 44 9876

If the user inputs any other format than the above 3, the program should return Invalid entry. For example, 123-44 9876 is invalid.

Valid input formats when EntityType = B are: 98-1234567, 981234567, 98 1234567, 981-23-4567


Examples
222-44-9876 and EntityType=P -> 222-44-9876
222-44-9876 and EntityType=B -> 22-2449876


package com.programming.interview;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class FIDChecker {

public static String checkFID(String strFID, String entityType ){

String returnFID = "INVALID FID/ENTITY TYPE";
entityType = ("P".equalsIgnoreCase(entityType)||"B".equalsIgnoreCase(entityType))? entityType:null;

if(null!=strFID && null!= entityType)
{
if (validateFID(strFID, entityType))
{
returnFID = reformatFID(strFID, entityType);
}
}
return returnFID;
}

private static boolean validateFID(String strFID, String entityType){
boolean isValidFID = false;
String validFormat1 = null;
String validFormat2 = null;

if ("P".equalsIgnoreCase(entityType))
{
validFormat1 = "\\d{3}-?\\d{2}-?\\d{4}";
validFormat2 = "\\d{3}\\s?\\d{2}\\s?\\d{4}";
}
else if ("B".equalsIgnoreCase(entityType))
{
validFormat1 = "\\d{2}-?\\d{7}";
validFormat2 = "\\d{2}\\s?\\d{7}";
}

Pattern matchingPattern1 = Pattern.compile(validFormat1);
Matcher patternMatcher1 = matchingPattern1.matcher(strFID);

Pattern matchingPattern2 = Pattern.compile(validFormat2);
Matcher patternMatcher2 = matchingPattern2.matcher(strFID);

if (patternMatcher1.matches() || patternMatcher2.matches())
{
isValidFID = true;
}
return isValidFID;
}

private static String reformatFID(String strFID, String entityType){

String plainFID = strFID.replaceAll("[-\\s]", "");

StringBuffer formattedFID = new StringBuffer();
if("P".equalsIgnoreCase(entityType))
{
formattedFID.append(plainFID.substring(0, 3));
formattedFID.append("-");
formattedFID.append(plainFID.substring(3, 5));
formattedFID.append("-");
formattedFID.append(plainFID.substring(5, 9));
}
else if ("B".equalsIgnoreCase(entityType))
{
formattedFID.append(plainFID.substring(0, 2));
formattedFID.append("-");
formattedFID.append(plainFID.substring(2, 9));
}

return formattedFID.toString();
}
}

Tuesday, March 10, 2009

Pencil...

I going to start trying out 'Pencil' an open source animation software.  I was looking at Adobe Flash CS software and was shocked at the prices.. Flash CS4 costs $999 :O. Pencil looks neat and impressive so far (interface has been done using Qt), will probably post an animation made with it shortly...

Tuesday, February 03, 2009

Windows Vista Service Pack 1

Windows Vista Service Pack 1 - seems to address the following issues that were frustrating me for quite some time.

i) Windows sidebar has not been working in my machuine for a long time. It would just crash at startup and also when I try opening it from the program menu. This has been corrected and seems to be working fine so far.
ii) McAfee antivirus 2009 was getting a 'MISP Shell Error (may not be the correct error description) when I tried to open the 'McAfee Security Center'. And the Registration Wizard kept erroring out (inspite of my efforts to try to runs using various XP compatibility settings), making my calls to customer care useless as they kept telling me everytime that they cannot help without product registration. This has also worked fine for me after the update.
iii) Yahoo messenger 9.x was also erroring on the programs start up. This issue also appears to have been rectified. I was using a patched up version of Ymess 8.x until now.

Thanks Microsoft!
For taking some to fix your bugs amist suing other smaller companies...

Saturday, January 24, 2009

Day 56 - of Log Late n' Lite

Err... it been a while since I started this dreary project. A lot has happened since then and I have not been able to work on this :(

I think it is time for me to call it quits and accept defeat. However last week I took a step towards it and installed JDK and the Netbeans IDE in my machine.

So I can console myself by saying ~ A single install for a man is a giant step for a lazy man.


Saturday, December 13, 2008

Day One - of Log Late n' Lite

I have been asked to develop asynchronous and lite logging for an application. Based on what I've googled so far, I am visualizing it using log4j + JMS (Active MQ or JBoss Messaging) .

I will be really glad if I could find an open source off-the-shelf asynchronous logging framework... huh

Wednesday, September 28, 2005

Tidbit

The @ symbol has to be used in the xpath query if you need to access an attribute field of an element.


Eg. < employee id="19090" >
< name/ >
< age/ >
< /employee >

the xpath to select the 'id' in an XSLT wud be '< xsl:value-of select="/employee/@id/text()" > '