Somethings in the world are not expected to work seamlessly and needs a blog post tutorial. Installing RSA SecureID key into your iPhone is one of them…

RSA has this app for iPhone to generate keys that is needed to login to corporate VPNs enabled through RSA. Installing it is easy. But, getting the key into it is not very straightforward. Well, No more… because you folks have this tutorial ;)

Install the RSA app (linked above) into iPhone and get your RSA login key .sdtid file before doing the instructions below…

  1. Download the RSA’s TokenConverter tool (It will ask you for a valid email id and accept license agreement terms)
  2. Open your command prompt and run the following command from the folder where you have extracted TokenConverter tool
    TokenConverter <.sdtid file path> -mobile -p <password if any>
    some corporations will create your .sdtid file with a unique password. Type it in if you got your .sdtid file with a password 
  3. The above command when executed successfully should print a generated ctf string in the console. Copy it. It will look something like
    com.rsa.securid://ctf?ctfData=2000119722625607285525965262252517630605010534242616025667355410
  4. Compose a mail with a hyperlink pointing to the above copied url and send it to an account accessible from your iPhone. Sample:
    <a href=”com.rsa.securid://ctf?ctfData=2000119722625607285525965262252517630605010534242616025667355410″> Click here to install the key</a>
  5. Open this mail in your iPhone and click on the link to automatically load RSA SecurID application. It will start installing the token.
  6. Goyala!!! It is done! You should be able to generate login tokens on the move from now.

Indian Festivals 2011

Posted: January 26, 2011 in Social

Want to know all the possible Indian festivals of 2011? Just download India Festivals.ics file and open it any supported phone (Android, iPhone)/PC (Mac, Linux or Windows) to add it into your calendar.

Note: I tried by best to add all the possible festivals into it (as far as I could google). So, Beware and don’t hold me responsible for your god’s fury! :-)

As you might have heard Zylog Wi5 is a wireless broadband service available in many Indian cities. Even though it is wireless, they will install a small signal receiver (modem+router) in the home roof tops for better signal reception. If you already have a home router to connect all your internet hungry devices, you might be perplexed as how to make them work together. Here is how the situation looks…

Wi5 to local router connection

The following instructions will help you to make it happen. What we are trying to do is connecting a router to another router…

Wi5 WLAN Router:

  1. Make sure you are able to connect to the internet directly without your router in the picture
  2. Open the Wi5 router’s admin page (192.168.1.254 by default)
  3. Go to the LAN Interface under TCP/IP settings and make sure DHCP server is set in server mode
  4. Updated DHCP client range wide enough based on how many devices you want to connect to your home router

Home Wireless Router:

Almost all the routers will have atleast 4 LAN ports to connect other devices to the network and a separate LAN port for connecting the ISP’s modem. Since Wi5 does not actually have a separate modem but instead is a modem+router, how you connect the both is bit different…

  1. Connect the Wi5 router to your home router in one of the 4 LAN sockets
  2. Login to your home router and disable its DHCP server. There can be only one DHCP server in a network and since we have enabled Wi5 router’s DHCP server, this is not needed.
  3. Restart the router if needed/prompted

This should do.

eval() in java?

Posted: November 3, 2010 in Programming
Tags: , , ,

Here is the question from my friend (ex-colleague):

“I have a mathematical expression say (45 + ((4 – 25) + 2)) as a string. How can you evaluate it to find the result using JAVA programming language?”

Well, this is very easy with javascript as it has the powerful eval() function. But java is static, strongly typed, not-that-fexible language. So, this cannot be provided as a language feature which leads me to either search for some available libraries or, write my won little library. If you are reading this post, you know by now what my decision was:) Come on, what’s fun in searching for someone’s work ;) (Well, not always)

So, here it is… This would have been much simpler with dynamic language like Groovy… But, the requirement clearly said JAVA :(

Logic is quite simple. The given input is an infix expression. Use stack and keep pushing all the elements (including braces) till you encounter a closed brace. Now, popping from the stack till you encounter an open brace will get you an operator and 2 operands. Evaluate it and push back the result to continue the same logic till the end of the input string.

 1 package com.rs.utils;
 2
 3 import java.util.ArrayList;
 4 import java.util.Stack;
 5 import java.util.regex.Matcher;
 6 import java.util.regex.Pattern;
 7
 8 public class Evaluator {
 9
10 	public static int eval(String infixExpression) {
11 		Stack<String> stack = new Stack<String>();
12 		String trimmedExp = infixExpression.replaceAll(" ", "");
13 		for (String c : split(trimmedExp)) {
14 			if (")".equals(c)) {
15 				if (!"(".equals(stack.peek())) {
16 					String result = performOperation(stack.pop(), stack.pop(),
17 							stack.pop()) + "";
18 					stack.pop(); // remove also the open bracket
19 					stack.push(result);
20 				}
21 			} else {
22 				stack.push(c);
23 			}
24 		}
25 		return Integer.parseInt(stack.pop());
26 	}
27
28 	private static int performOperation(String operand2, String operator,
29 			String operand1) {
30 		int op1 = Integer.parseInt(operand1);
31 		int op2 = Integer.parseInt(operand2);
32 		switch (operator.toCharArray()[0]) {
33 			case '+': return op1 + op2;
34 			case '-': return op1 - op2;
35 			case '*': return op1 * op2;
36 			case '/': return op1 / op2;
37 			default: return 0;
38 		}
39 	}
40
41 	static String[] split(String exp) {
42 		ArrayList<String> parts = new ArrayList<String>();
43 		Pattern pat = Pattern.compile("\\d++|\\+|\\-|\\*|/|\\(|\\)");
44 		Matcher matcher = pat.matcher(exp);
45 		while (matcher.find()) {
46 			parts.add(matcher.group());
47 		}
48 		return parts.toArray(new String[0]);
49 	}
50 }
Thanks to code2HTML

LG TV… misleading…

Posted: October 17, 2010 in Gadgets

I recently brought this LG 42″ plasma tv which comes with an USB port. The product manual said it supports DivX format videos but only after getting it to home, I found it plays more formats than it advertises… :-S

It actually plays all DivX, Xvid & VOB files. But fails to recognize mp4 videos. Well, you might ask why should I be concerned if it plays more than it mentions right? If I had known this before, I might not have ordered AppleTV. :-) (Out of the box even it does not play all the formats but you can install Boxee into it)

I guess all the latest LG TVs does the same. Better check it in the store with a flash drive before buying… I got mine for 36,500Rs in Girias.

Spot Fine!!!

Posted: April 4, 2010 in Social

Next time you get caught for a traffic violation, use the below information to your advantage :)

Offence Code Name of the offence Penal Section Fine Amount
RR 01 Failue to renew registration U/s 177 Rs. 100
GP 02 Stop line violation U/s 177 Rs. 50
GP 03 Lane jumping U/s 177 Rs. 50
GP 04 Yellow line cutting U/s 177 Rs. 50
GP 05 No entry U/s 177 Rs. 50
GP 06 Signal violation U/s 177 Rs. 50
GP 07 No ‘U’ turn U/s 177 Rs. 50
GP 08 Closed to lorry traffic U/s 177 Rs. 50
GP 09 No parking U/s 177 Rs. 50
GP 10 Triple riding U/s 177 Rs. 50
GP 11 Improper uniform & other cases U/s 177 Rs. 50
GP 12 Refusal to ply U/s 177 Rs. 50
GP 13 Demanding excess fare U/s 177 Rs. 50
GP 14 Over height U/s 177 Rs. 50
GP 15 Two persons in drivers seat U/s 177 Rs. 50
GP 16 Tampered meter seal U/s 177 Rs. 50
GP 17 Protruding in front/rear of vehicle without red flag/light TNMV Rule 396 U/s 177 Rs. 50
GP 18 Dazzling head light U/s 177 Rs. 50
GP 19 Defective number plate U/s 177 Rs. 50
DO 20 Disobdience of orders-obstruction and refusal to give information U/s 179 Rs. 50
UP 21 Allowing unauthorized persons to drive U/s 180 Rs. 50
WL 22 Driving vehicle in contravention of Section 3 or 4 without D.L. or below the age of 18 U/s 181 Rs. 500
DP 23 Driving vehicle by a person who is disqualified U/s 182(1) Rs. 500
LO 24 Offense relating to licenses (Disqualified for holding or obtaining conductors license) U/s 183(2) Rs. 100
OS 25 Driving at Excessive speed limits U/s 183(1) Rs. 400
CE 26 Driving at excessive speeds etc U/s 183(2) Rs. 300
RD 27 Driving / Riding dangerously including talking on cell phone while on driving / riding U/s 184
U/s 177
Rs. 1000
Rs. 100
DD 28 Drunken Driving U/s 185 Court
UD 29 Driving when mentally or physically unfit to drive U/s 186 Rs. 200
RT 30 Racing and Trails of speed U/s 189 Rs. 500
EE 31 Emitting Excess Smoke U/s 190(2) Rs. 50
TS 32 Tampered Silencer U/s 190(2) Rs. 50
HC 33 Musical / Air Horn cases U/s 190(2) Rs. 50
WR 34 Using the vehicle without registration U/s 192 Rs. 500
WP 35 Using the vehicle without valid permit or permit violation U/s 192 Rs. 500
EW 36 Driving vehicle exceeding permissible weight U/s 194 Rs. 100
UI 37 Driving uninsured vehicle U/s 196 Rs. 1000
IV 38 Unauthorized interface with vehicle U/s 198 Rs. 100
OT 39 Obstruction U/s 201 Rs. 50
ID 40 Power of officer to impound document U/s 206
DV 41 Power of officer to detail vehicle U/s 297

Airtel Wireless USB with Mac OSX

Posted: November 25, 2009 in Gadgets

Even though Airtel website does not mention that Huawei Edge wireless usb modem plays well with Mac, it does! Well that is a great news for all the mac users in India… The only things that needs to be done is to manually set the wireless configuration… Also, the mac software “Mobile Partner” provided with the usb modem is nice…

Configuration you need to set in “Mobile Partner”

Settings

 

Welcome iPhone OS 3.0

Posted: June 21, 2009 in iPhone
Tags: , ,

Lately, upgrading unlocked iPhones firmware is not such a big deal as it used to be (thanks to iPhoneDevTeam)… I have upgraded my unlocked 2G iPhone (Yes I know how all you 3G/3GS owners feel… don’t get me started on that)… I just followed this iClarified link and all it took me was 20 minutes of time… (that too because of all the backups that I need to take)

To take backup of your iPhone…

Contacts : Use iTunes
SMS
: Copy the sms.db in /private/var/mobile/Library/SMS to local and restore it back after upgrade*
Notes
: Copy the notes.db in /private/var/mobile/Library/Notes to local and restore it back after upgrade*

* You should have installed OpenSSH in your iPhone through Cydia to remote login from a PC and copy these files

Struts & Springs in iPhone

Posted: February 15, 2009 in iPhone
Tags: , ,

I found the following image in one of the Apple’s Interface Builder tutorials for iPhone programming. I have this habit of skimming through the whole page before giving it a concentrated read and after seeing this image, thought “Wow… Something explained here in relation to two poular web frameworks “Struts” and “Springs”… But but, i am in Interface builder tutorial… What is happening here???… “

After reading what they are trying to say in that section, I realized they mean what plain english word means when you say “spring” and “strut”…

But, I felt this as a rare coincidence to see these words together in the least expected spot :)

Struts & Springs

Struts & Springs

Is it a rectangle?

Posted: November 2, 2008 in Programming

Couple of days back when I was travelling back to home from office, I overheard two fellow employees discussing over a programming problem… “If four points in a 2D plane (x,y) is given, how to find whether it forms a rectangle or not?”. Question sounds simple right? Well, how would you program this solution? what will be the algorithm? Just give it a shot.

Check out my implementation below… It did not look this small and simple when I started solving it. Tried calculating angles between edges, tried equating edge lengths, tried rotating the skewed rectangles (special case), tried getting B.Sc. Maths degree first… But, all of these are not really needed for the solution…  It is enough if you calculate the centroid and make sure all the 4 points are equi-distant from the centroid. Well, square also satisfies this logic and square is also a rectangle :)

I guess it is always hard to come up with a simple solution… You have to put lot of effort to think simple!

 1 public class RectangleValidator {
 2
 3 	public static boolean validate(Point p1, Point p2, Point p3, Point p4) {
 4 		// Find the centroid using Euclid's geometric principle
 5 		Point centroid = new Point();
 6 		centroid.x = (p1.x + p2.x + p3.x + p4.x) / 4;
 7 		centroid.y = (p1.y + p2.y + p3.y + p4.y) / 4;
 8
 9 		// Now check if the centroid is equi-distant from all the corners
10 		double dist1 = getLength(p1, centroid);
11 		double dist2 = getLength(p2, centroid);
12 		double dist3 = getLength(p3, centroid);
13 		double dist4 = getLength(p4, centroid);
14 		return (dist1 == dist2 && dist2 == dist3 && dist3 == dist4 && dist4 == dist1);
15 	}
16
17 	private static double getLength(Point p1, Point p2) {
18 		// Using pythogoras theorem
19 		double xDiff = Math.abs(p1.x - p2.x);
20 		double yDiff = Math.abs(p1.y - p2.y);
21 		return Math.sqrt((xDiff * xDiff) + (yDiff * yDiff));
22 	}
23
24 	public static class Point {
25 		Point() {
26 		}
27
28 		Point(double x, double y) {
29 			this.x = x;
30 			this.y = y;
31 		}
32
33 		double x;
34 		double y;
35 	}
36
37 }

Thanks to Code2HTML