27 December, 2012

You Should Know, Java XML Parsing

As Java developer you should know that:

JAXP, Java API for XML Processing, lets you use any conforming parser implementation in a standard way. The code should be much more portable, and when you realise that a specific parser has grown too old, you can replace it with another without changing a line of your code (if you do it correctly).

    Basically there are three ways of handling XML in a standard way:
  1. SAX This is the simplest API. You read/modify the XML by defining a Handler class that receives the data inside elements/attributtes when the XML gets processed in a serial way. It is faster and simpler if you only plan to read some attributes/elements and/or write some values back (your case).
  2. DOM This method creates an object tree which lets you modify/access it randomly so it is better for complex XML manipulation and handling.
  3. StAX This is in the middle of the path between SAX and DOM. You just write code to pull the data from the parser you are interested in when it is processed.

Forget about propietary APIs such as Jdom or Apache ones (i.e. Apache Xerces XMLSerializer) because will tie you to a specific implementation that can evolve in time or lose backwards compatibility, which will make you change your code in the future when you want to upgrade to a new version of Jdom or whatever parser you use. If you stick to Java standard API (using factories and interfaces) your code will be much more modular and maintenable.

    Code samples
  1. XML parsing using SaxParser with complete code

Galaxy Note 2, Quick root & flash guide

Thanks to my wife I just got one new Galaxy Note 2 as Xmas gift. It's one awesome gadget, it came with Android 4.1.1 pre-installed and it has some ugly vendor animations on it that I wanna get rid off so I'm going to root and re-frash it with a custom room (new version 4.2.1, Jelly Bean).

What is root? On many computer operating systems including Unix, Linux and Android, the root account, is a special user with complete access to all files and commands. Various names for this type of account might include, administrator, superuser, or supervisor.

In the context of Android, root access allows the user to have complete control over their device. Root access is commonly granted for developers allowing them access to all files and commands on the device.

With full root access to a device, there is potential for damage. Any user with root access is strongly cautioned to be very careful.

My previous experience with my old and rusty HTC desire tells me that xdev and android geek is the right place to go in order to find the firmware and instructions to do it without bricking my "phablet"...

How to Root Samsung Galaxy Note 2 N7100 with Odin

Rooting the device

    Required files and tools:
  1. The root & recovey package
  2. Odin

This installation has done on a clean PC - no android ADK or samsung drivers were installed before it

    The rooting process:
  1. The first thing to do is to download the root & recovery package from here.
  2. Save the file on your computer.
  3. On the same PC download Odin.
  4. Extract and install the tool.
  5. On the computer open Odin.
  6. Next, turn off the device as it must be entered in download mode.
  7. For download mode press and hold Volume Down, Center Home, and Power buttons together.
  8. When the download mode is reached, connect the Note with the computer by using its USB cable.
  9. Press Volume Up to continue and then windows will install all required drivers (SAMSUNG Mobile USB CDC Composite Device and SAMSUNG Mobile USB Modem).
  10. Once windows finishes the driver installation the “added” message should be displayed at Odin.
  11. Also, the ID:COM section should be yellow.
  12. If not, install the drivers again and then redo the above steps.
  13. Up next, on Odin, select “PDA”.
  14. Pick the unzipped downloaded file (cwm6-root-n7100.tar).
  15. Don’t make any other changes, just click on “Start”.
  16. The root process will now begin.
  17. Wait until it’s over and in the end unplug the USB cord and reboot the Note2.
  18. If the device does not boot don't panic, you will have to start the CWM, for that remove the baterry, put it back and then press and hold Volume Up, Center Home, and Power buttons together until the SAMSUNG Logo disappears.

You don't need to download and install Rom Manager into the device. You will not see the recovery image for this device into CWM because there is no official support yet. Next time you will only need to flash the recovery image (without root).

    THE Backup!!!
  1. Start the Rom Manager App then select "boot into recovery mode".
  2. Select backup, etc.
  3. reboot the device.
  4. Connect the USB cable, open the device and then copy the content of the folder clockworkmod\backup into your computer ...

Last, fixing permissions ...

    A few usefull links:
  1. Android USB Drivers For Windows OS
  2. How To Carrier Unlock Samsung Galaxy Note 2 Permanently

13 December, 2012

You should know

As architect you should know that:

CPU Bound means the rate at which process progresses is limited by the speed of the CPU. A task that performs calculations on a small set of numbers, for example multiplying small matrices, is likely to be CPU bound.

I/O Bound means the rate at which a process progresses is limited by the speed of the I/O subsystem. A task that processes data from disk, for example, counting the number of lines in a file is likely to be I/O bound.

Memory bound means the rate at which a process progresses is limited by the amount memory available and the speed of that memory access. A task that processes large amounts of in memory data, for example multiplying large matrices, is likely to be Memory Bound.

"Cache bound" means the rate at which a process progress is limited by the amount and speed of the cache available. A task that simply processes more data than fits in the cache will be cache bound.

I/O Bound would be slower than Memory Bound would be slower than Cache Bound would be slower than CPU Bound.

The solution to being I/O bound isn't necessarily to get more Memory. In some situations, the access algorithm could be designed around the I/O, Memory or Cache limitations. See Cache Oblivious Algorithms.

The Amdahl's law states that "The speedup of a program using multiple processors in parallel computing is limited by the time needed for the sequential fraction of the program."