12/08/2013

Get the latitude and longitude information from a place name in Android

Android provides Location API for us to get the place name from latitude and longitude information.  However, it does have a means to do the reverse. Here is a solution to do what you solve this issue.

Google provides RESTful API for most its services. Map is one of them. We can use following API to get a response in JSON format:

http://maps.googleapis.com/maps/api/geocode/json?address=CITY_NAME&sensor=false
 JSON-formatted reply:
{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Chiayi County",
               "short_name" : "Chiayi County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Taiwan",
               "short_name" : "TW",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Chiayi County, Taiwan",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 23.6359267,
                  "lng" : 120.9576494
               },
               "southwest" : {
                  "lat" : 23.2147999,
                  "lng" : 120.1174411
               }
            },
            "location" : {
               "lat" : 23.4588948,
               "lng" : 120.5739579
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 23.6359267,
                  "lng" : 120.9576494
               },
               "southwest" : {
                  "lat" : 23.2147999,
                  "lng" : 120.1174411
               }
            }
         },
         "types" : [ "administrative_area_level_2", "political" ]
      }
   ],
   "status" : "OK"
}
Simply parse the reply and we can get the latitude and longitude information.

REF: http://stackoverflow.com/questions/10008108/how-to-get-the-latitude-and-longitude-from-city-name-in-android

9/07/2013

Reference Monitroing

I keep forgetting the actual content of reference monitor, so I wrote a note here to remind myself.

  • Complete Mediation: The reference validation should always be involved.
  • The reference validation must be tamperproof.
  • The reference validation must be small enough to be completely reviewed, tested, and assured.
Reference: Wikipedia

8/21/2013

Booting from external drive in VMWare Fusion

I recently evacuated from my former research lab and therefore I don't have any machine to run ubuntu.  What I have now is a late-2012 macbook pro, so I plan to run my "old" dev env on it.  However, I still favor to use MacOS in most circumstances, and solely using ubuntu on my macbook therefore isn't an option.  My hard drive is a 256gb SSD, it's quite tight, so dual-os system isn't an option either.  I chose to clone everything on my office desktop disk to an external disk (an Seagate GoFlex 1TB USB3.0 external hard drive), and running my old dev env from VMWare Fusion in MacOSX.

The idea is simple, but how to achieve isn't.  The reason is because VMWare Fusion is not official support booting form external drive.  I mean, at least, you ain't able to find this option from its UI interface.  The idea is doable through VirtualBox so I think it should be also possible with a much powerful virtualization solution.  After I googled for a while, the answer is YES.  And here is a mini how-to.


  1. Create a virtual machine in VMWare Fusion.  You can only choose using virtual drive.  It is okay because we will not this virtual drive anyways. (We use "Ubuntu 64-bit" as the name of the virtual machine)
  2. Plug your external drive to your MAC.  Find out the disk number in "Disk Utility", say it's /dev/disk2.
  3. Create a "vmdk" to represent this disk: sudo ./vmware-rawdiskCreator create /dev/disk2 "fullDevice" ~/dev/ubuntu-usb ide
  4. Correct the permission of the newly created vmdk file (it is /dev/ubuntu-usb.vmdk in this example): chown ~/dev/ubuntu-usb.vmdk
  5. edit vmx file of the virtual machine (it should be "Ubuntu 64-bit.vmx" in ~/Document/Virtual Machines.localized/Ubuntu 64-bit.vmwarevm in this example): vim Ubuntu\ 64-bit.vmx
    1. remove lines with scsi0.*
    2. add lines:
      1. ide0:0.present = "TRUE"
      2. ide0:0.fileName = "~/dev/ubuntu-usb.vmdk"
  6. Launch the virtual machine, it should work.

5/30/2013

Migrating your hard drive on old mac to a new one.

I recently got my new Macbook Pro 13" (MacBookPro9,2, mid-2012) to replace my 5-year-old Macbook Aluminum Unibody (Macbook 5,1, late-2008).  Since I've upgrade my Macbook to latest 10.8.3, I was thinking whether it's feasible to move my old hard drive to my new Macbook Pro so that I don't need to re-setup my working environment.  I tried to google it.  So people said it just works but others reported they had some issues.  I thought, since I have everything backup in Time Machine, why don't I just give it a try.  Restoring from time machine won't take a very long time.  So I gave it a shot, and yes, it just simply worked.  I think OS will try to identify new hardware at first boot, but everything it just worked.  Thank God I don't need to waste some time to restore everything from my Time Machine.

CAUTION: Make sure your old mac has latest OSX installed, so that your old machine can have the latest drivers for the latest hardware.  Otherwise, it seems to be failed.

btw, after you move your old hard drive to the new Mac and you connect your Time Machine drive to your new Mac.  Time Machine will ask you whether you want to "inherit" to use Time Machine or to "start a new backup".  Inheriting existing Time Machine backup will change the data and the backup won't be able to store to the old Mac.  I chose "inherit" because I am going to sell my old Macbook.

5/24/2013

Something About Cloud ...

CIA is the term that you will meet all the time when you work in the area of security.  It can be related to all kinds of computer sciences aspects including recent buzz-work: cloud storage.  By design, most cloud storage systems (what I am talking about is consumer products such as Dropbox, SkyDrive .. etc) play as a centralized role, user doesn't need to worry about which server I should contact, which server I should place my file on.  These are quire non-brainer operations, and this is why they become so popular.  However, there are several studies popping up saying they are really worry about the situation we place all our sensitive data onto a (I don't know if I should trust) cloud provider.  The service provide might be down, my data might be corrupted, or even they will steal my (I don't know if that's important) private data.  And then, there are several different kinds of approaches proposed to fix these problems.  One interesting idea (which is used by several papers) I saw is to distributed your data to multiple service providers.  This reminds me the old research (Malugo, 2008): distributed all your data to a peer-to-peer network.  The interesting part is that, they are reusing those techniques (ideas) which has been used in the peer-to-peer network.  But couple years ago, people say, peer-to-peer storage doesn't have hope, they are too "distributed", people don't want to care where to place data (although there are bootstraps).  They see cloud storage, you just need to send all your data in a centralized server, and let the cloud worries the rest.  Now they are saying, no no no, the cloud is too centralized, we should distributed them.  And again, turn the cloud storage very distributed (by using some "out-dated" concepts that have been proposed in peer-to-peer network.  We just need to keep saying old things don't work then we can use some more even old technique to get some more new publications, isn't it? :p

3/04/2013

Why Qualcomm doesn't use big.LITTLE

I just read a discussion questioning why Qualcomm its own vSMP architecture rather than using ARM's latest big.LITTLE architecture.

The basic idea of ARM's big.LITTLE architecture is to fuse 4 Cortex-A7 cores and 4 Cortex-A15 cores onto the same CPU package.  When you are doing tasks that require much less CPU power (e.g., background music playback, internet surfing), it uses power-friendly Cortex-A7.  On contrary, when you doing some performance intensive tasks, it enables powerful Cortex-A15 and completely shut the Cortex-A7 cores down.  Cortex-A7/A15 share the same hardware architecture and therefore, should generate no problem when performing such switch.  Simple right?  Depends on what you want to do, enables the corresponding CPU cores to work with you.  However, there are some problems.  The first one is increased manufacturing cost.  This architecture also mean you put two sets of CPU on one chip.  Although it doesn't mean doubled cost, but increased cost is unavoidable.  Second, two sets of CPUs also increase die size which might require a better heat-sinking solution.

Qualcomm's solution, on the other hand, only dynamically enables partial or all CPU cores and adjusts CPU frequency to achieve power efficiency. Although theoretical power saving might not as much as big.LITTLE, Qualcomm claims they actually have better power-efficiency than big.LITTLE (thanks to more modern technology? :p).  They can also have less manufacturing cost than ARM's big.LITTLE.  Last, what Qualcomm licenses from ARM is ARMv7 architecture instead of Cortex-A family CPU design.  Qualcomm has designed their own CPU for years for better performance and adding more advanced features.  Adapting to big.LITTLE does not only mean they have to pay more to ARM but also means they have to drop their current achievement.  All these are reasons that Qualcomm doesn't adapt big.LITTLE architecture.

In sum, it's quite straight-forward that Qualcomm not choosing big.LITTLE architecture.  I also feel it's a weird design (although it's somehow straight-forward) because of the cost.  Another idea maybe ... can we just shut some components inside a CPU core down?  I don't know, I know almost nothing about CPU design ... orz