Monday, January 24, 2011

Setting up LG-Optimus One for development

I have been writing android-apps for over more than 8 months now. Finally, I got hold of my first android smart-phone, LG-Optimus One (Model name P500). The following were the steps I had to perform in order to get this phone ready for Android development.

Installing USB driver:
By default, this phone will not be detected over USB, as windows (Win7 32b) failed to find the USB driver for this device. Google search suggested that P500 USB driver needs to be manually installed. To do that, just go to the following link: http://www.lgforum.com/resources/ and select the 'LGAndroidDriver_Ver_1.0_All.exe' executable (about 9.4MB). Then run this exe in order to install the USB driver. Wallah! You're done!

Enabling USB debugging:
Again, by default, USB debugging will be disabled on this phone. (Makes perfect sense as this feature is for development only) In order to enable just select the Settings -> Applications -> Development -> USB debugging check-box. Now connect the USB cable. After this, open a command-prompt and then type adb devices. You'll see something like this:
> adb devices
List of devices attached
******************      device
 You're done! Now, you should be able to run an application (assuming android:debuggable is set true in the app's AndroidManifest.xml) and see the log messages through 'ddms'.

Happy coding!

Thursday, January 20, 2011

traceview fails to find the trace file (on windows)

You have the trace file 'my-trace.trace' present in the current working directory. However, when you type traceview my-trace, you would get the error message: "trace file 'my-trace' not found". Even if you append the trace file with the '.trace' extension, you would get the same error message.
Somehow, the traceview cannot recognize relative paths. So, the solution is to pass the absolute path of the trace file as input to the traceview.
EG: traceview C:\path\to\file\my-trace

(PS: It's been assumed here that the android-tools folder is in your PATH env-variable.)

Sunday, January 2, 2011

Kaprekar-Numbers

Kaprekar-numbers are interesting. For eg.: 703 is a kaprekar-number. Reason: 7032 = 494209 and 494 + 209 = 703. It's also been proven that one can get all the Kaprekar-numbers by prime factorization of 10n-1. However, I wanted to list all the Kaprekar-numbers by solving it in its pure form! A number 'k' (in base 10) is called as Kaprekar-number if it can be expressed in the form:
k = q + r   and   k2 = q * 10n + r
Where, q >= 1, 0 < r < 10n
I've hosted this program on github at the following location (read-only): git://github.com/teju85/Kaprekar-Numbers.git. If you are interested in this, please download the program and follow the instructions inside the 'README'.
I profiled this program and here are the results:
$ make profile
printCpuInfo.sh
Processor Information:
processor       : 0
vendor_id       : GenuineIntel
model name      : Intel(R) Xeon(R) CPU           X5355  @ 2.66GHz

kaprekarnumber -nooutput -profile -limit 10000
Found 17 kaprekar-numbers among first '10000' integers.
Took 0.001309 seconds to search for self-numbers among these integers.

kaprekarnumber -nooutput -profile -limit 100000
Found 24 kaprekar-numbers among first '100000' integers.
Took 0.014230 seconds to search for self-numbers among these integers.

kaprekarnumber -nooutput -profile -limit 1000000
Found 54 kaprekar-numbers among first '1000000' integers.
Took 0.188414 seconds to search for self-numbers among these integers.

kaprekarnumber -nooutput -profile -limit 10000000
Found 62 kaprekar-numbers among first '10000000' integers.
Took 1.616492 seconds to search for self-numbers among these integers.

Not sure whether the timings are 'optimal' or not. Still looking for possible optimizations...

Saturday, January 1, 2011

Removing password from pdf files

We frequently come across a lot of password-protected pdf's in our daily lives, be it our internet/credit-card bills. Problems come when we want to share these kind of files with others. We obviously don't want to share the password as well! There are a lot of (commercial!?) tools out there which claim to remove password from pdf files. However, we all know that ghostscript already provides an option of reading password-protected pdf files and then storing them back to hard-disk. So, wrote a wrapper-tool for myself in order to do this process for me. I've created a repo for this tool and is publicly available (for free, ofcourse!). If you want to use this tool, please download all the files from this repo: git://github.com/teju85/No-Pass.git.

Happy new year fellas!