Friday, September 6, 2013

Know your heart


Heart is an amazing organ, very little in size buy very big and important when it comes to the functions. Khan academy has bunch of videos about heart titled Meet the Heart. I highly recommend it. Our body has lot of pairs like left & right hands, eyes, ears & so on. It gets confusing when we start naming them in Latin. Here are some tricks to remember them.

Systole & Diastole

Systole: Wikipedia defines it as “contraction of the heart”.

Diastole: Wikipedia defines it as “is the period of time when the heart refills with blood after systole”.

How to remember it? These two words represent contraction and expansion of the heart in a heartbeat. Remember the word dilation[expansion] when you hear diastole.

Systole: Contraction

Diastole: Dilation

Artery & Vein

The other two confusing pair. Vein takes the blood to heart & Artery takes the blood away from heart.

Vein: In, Brings in blood to the heart.

Artery: Away. Takes blood away from the heart.

Atrium & Ventricle

Heart has four chambers, they can be referred as upper & lower chambers or right and left chambers.

Righty tighty, lefty loosey

Right side chambers collects impure blood and left side chambers pumps away the pure blood. Remember the phrase, Righty tighty, lefty loosey.

Right side collects the impure blood

Left side drains the blood.

Up & down

Upper two chamber are called atriums and lower chambers are called ventricles. Upper chambers usually collects the blood or blood flows into upper chambers. Lower chambers flushes blood away from heart.

Atrium is the word that refers a larger open space within a building usually with a glass roof according to Wiki.

Venter is the origin word for ventricle which means belly. Chambers that are closer to belly are ventricles.

Atrium: Upper two chambers.

Ventricle: Lower two chambers or chambers by belly[venter].

Pulmonic[3] & Aortic[3] valves

These two valves are lower chamber or ventricle valves. They two control the outflow of blood from heart. Pulmo or pulmon is the root word for pulmonic which means lung. It controls the flow of the blood from right ventricle to lungs. That’s why its called Pulmonic Valve. Aortic Valve controls the flow of oxygenated/pure blood to the rest of body through “Aorta”.

Tricuspid[3] & Mitral[2] Valve

These two valves are upper chamber valves and they control the inflow of blood to heart. Among all the four valves, Mitral valve is the only valve that has two cusps. It is also called bicuspid valve.

Thursday, July 25, 2013

GifCam + Genymotion = True Awesomeness


Lately I have been playing with Android animations. Animations are not easy thing to share. There are few options to show off the animation, Video or GIFs. For a few seconds animation Videos feel like heavy duty tool. GIFs are near perfect tool for the job.

GifCam is a free Windows tool that captures any part of your screen, in any size and saves as GIF file. It is no nonsense tool. Single executable file. No installation. Just copy it and it just works. Sadly this is just on Windows. No apps or no cameras.

If you want to capture something  and express it as GIF, there are several apps out there. They use phone’s camera or existing pictures and make GIF out of it. This method is as good as your stable hands.

If you want to capture something in Android and don’t want to use an GIF maker app, then you should check out Genymotion. Genymotion is an Android Virtual Machine unlike Android Emulator, it is pretty fast, runs well & free. If you are an Android developer, dump the emulator and switch to Genymotion. It is freaking fast. 

After downloading the Genymotion, download a prebuilt virtual machine and start it. Bring up the GifCam on top of the Virtual Machine window, record & save. That simple. Here is a sample I made.


Tuesday, July 23, 2013

On Wearable Computing wagon


Few decades ago, humans were walking inside of computers, now we are carrying them with us in our packets. In the near future, they will be inside our body and will be doing what we did to them few decades ago. Monitoring our vital signs and fixing broken parts in our body. One step towards that future is “Activity Trackers”. Activity trackers track your physical activities such as walking and climbing stairs and how well you sleep.

There are several companies selling trackers. Nike sells Fuel, Jawbone sells UP, Fitbit sells Flex and One, Withings sells Pulse, BodyMedia has Wireless LINK Armband and iHealth has Wireless Activity and Sleep Tracker.

Broadly you can classify them into two different categories,

  • Wrist/arm band. They look like watches and have some or no display.
  • Hip tracker. These devices look very similar to a USB memory stick. Most of them can be converted into wristbands at nighttime to track sleep. They usually have better display than wrist/arm band trackers.

I have to pick one, Who said more choices are better? Here is how I narrowed it down.

  • Design & Usability: Whether I am going to wear it on my wrist/arm, or keep it on my packet and not visible to others, I wanted something that feels well designed and sleek. This eliminated BodyMedia and iHealth because both of them are bulky even though BodyMedia claims it is clinically proven. I want apps that perform well and looks clean and easy to use.
  • One App: I wanted a wireless scale and activity tracker. Fitbit, Withings and iHealth are the three companies that sell tracker and scale. I could have used apps like RunKeeper or My Fitness Pal to combine scale and activity tracking, it didn’t feel native or natural to me.
  • Connectivity: These devices had minimal display or no display at all. You have to consume the information and analysis somewhere else like mobile phone, tablets or computers. I didn’t want to be responsible for transferring data for obvious reason. Jawbone Up has no wireless connectivity, you have to plug it into audio jack to transfer data. Fitbit Flex has BLE[Bluetooth Low Energy] connectivity. Only few mobile phones and tables supports this. Go here to see for the full list of Fitbit supported devices. Withings Pulse seems like it can connect to most of the moderns devices with Bluetooth 2.0.
  • Display: I want some feedback if I am going to use this for the whole day. Nike Fuel and Withings Pulse and Fitbit One has some nicer displays. Both Withings Pulse and Fitbit One can display number of steps taken and stairs climbed. When it comes to wrist band trackers, Nike Fuel has better display than Fitbit Flex and Jawbone UP. Fuel can display time and steps count, Flex has 5 lights and UP has no display at all.

For me it came down to Fitbit Flex, One or Withings Pulse. Withings Pulse wasn’t available couple of weeks ago. So it was Flex or One. Fitbit One has several advantages, superior display, can count number of stairs climbed and belief is that hip trackers like Fitbit One are more accurate because they sit in your hip not on your wrist which can have some false positives. I chose Fitbit Flex for these two reasons,

  • Flex is all in one device for activity tracking and sleep tracking. Fitbit One needs a separate band for sleep tracking. Flex offered less friction and less work.
  • Searching misplaced stuff is part of my day and I didn’t want one more thing to search. Flex can stay with my wrist day or night. Only time I take off is when I get into shower.

Links that helped me,

Check back later for my review of Fitbit Flex and Aria.

Wednesday, June 26, 2013

Thursday, June 13, 2013

How to access RunKeeper API in Android?


To access RunKeeper API, you need to do few things first.

  • Create an application in their Application Portal
  • Creating application will get you Client ID, Client Secret and URLs to authenticate. If you are unlucky like me and don’t see client secret, go and post a message in their support Google group. They are good at resolving immediately.

If you want to test your credentials, head to their RunKeeper’s Developer's Console or use tool like Postman. If you want to use Android to test it, read further.

Let’s write a simple application that finds out total distance user has walked so far using RunKeeper’s API.

image image image image

Accessing RunKeeper’s API involves couple of steps,

  1. Redirect user to RunKeeper’s authorization URL on a WebView.
  2. Get permission from user to access their data.
  3. Once they allow it, Run Keeper will redirect with an “Authorization Code”.
  4. With the Authorization Code make a Post request to get the access token.
  5. Securely save the access token for reuse. This is long lived key. It works even after users change their password. So keep it safe.

Let’s create a simple Android project with a simple activity that has a Button and WebView.

Let’s first create some constants with your Client ID, Client Secret. You can get this from RunKeeper’s Application Portal after creating your app. In onCreate method, setup controls and make sure you enable JavaScript on the WebView.

On button click, hide the Button and bring the WebView to foreground.

Embed client_id, response_type=code, redirect_uri in Authorization URL and load this URL on the WebView control. After user grants/denies permission, it will be redirected to the redirect_uri you have provided. Override shouldOverrideUrlLoading on WebViewClient to you can detect when it is redirected.

After extracting Authorization Code from the redirected URL, get access token by making a POST request. Note few interesting things, You can’t make network requests on UI thread so create a separate thread. This will return a JSON response. Extract access token from the response.

Now we have the access token, let’s go ahead and query RunKeeper’s API.To keep it simple for this example, I just hard coded the URL. But you should query “user”[] endpoint to get list of URLs available for you. If we query endpoint it returns list of statistics for each activity type available in RunKeeper. 

Note that we didn’t create a separate thread for this call since this method gets called in a non UI thread we created earlier. If you are calling this method from UI thread, create a separate thread.

After getting response from “records” endpoint, we have to traverse it to the walking activity type and extract overall walking distance. Parsing JSON with out dedicated parser like Gson is a real mess. To keep the example simple and friction less, I just used built in JSONObject.

RunKeeper returns total distance in meters and convert it to miles and display it on a Toast message. Note we are not on UI thread, we have to call runOnUiThread to display the Toast message. Some less interesting helper methods,

One last important thing, add android.permission.INTERNET to AndroidManifest.xml file so that our app can access internet.

Here is the link to AndroidManifest.xml and in GitHub.

Friday, May 31, 2013

Thursday, May 30, 2013

Tuesday, May 21, 2013

Cognitive Science and Design


This is one of the best sessions I have attended in this year Google I/O. Very interesting talk about human perception and how amazing our mind is when it comes processing text, image and life threatening animals.

Cognitive Science and Design

Wednesday, May 15, 2013

Quote of the day


Be the Change you wish to see in the World.

~Gandhi ~Somebody

Once what ever printed was right and noble, today what ever shared in Facebook is right and noble. This is very true to many quotes shared in internet. Always interesting to see how a quote is misquoted.

According to NY times, this is the closest by Gandhi,

If we could change ourselves, the tendencies in the world would also change. As a man changes his own nature, so does the attitude of the world change towards him. ... We need not wait to see what others do.

~ Gandhi

Via Falser Words Were Never Spoken, NY Times



The part of the (human) body from the neck to the groin, that is, the body excluding the head and limbs.


Monday, May 13, 2013

Thrift Shop


a shop that sells secondhand articles and especially clothes and is often run for charitable purposes

Merriam Webster

Wednesday, May 8, 2013

Unplug and reflect

In the age of information, we have access to the information 24x7 but can you keep on consuming the information?

Saturday, May 4, 2013



A spire is a tapering conical or pyramidal structure on the top of a building, particularly a church tower. Etymologically, the word is derived from the Old English word spir, meaning a sprout, shoot, or stalk of grass.


Friday, May 3, 2013


Did you know? In 1950s, American household spent 17% of their income on clothing but today they spend less than 2% of their income on cloths even though they own more cloths and accessories.
Overdressed: The Shockingly High Cost of Cheap Fashion

Thanks to all the people who spends their life in miserable working conditions for a better life.

Via Ethical Fashion: Is The Tragedy In Bangladesh A Final Straw?

Thursday, May 2, 2013

Turkish I problem.


Interesting localization behavior for Turkish locale,

"INTEGER".ToLower() //returns "ınteger"
"integer".ToUpper() //returns "İNTEGER"

Note the “.” on top of the capital letter I.


Tuesday, April 30, 2013

Alias for local machine when you login


When you login to a computer, If you are doing this,

ComputerName\username or username@ComputerName

You can do this,


“.” is an alias for the local machine.


Monday, April 29, 2013



An icicle is a spike of ice formed when water dripping or falling from an object freezes. -Wiki

See also Popsicle

Thursday, April 25, 2013

I'm your huckleberry


"I'm your huckleberry" is a way of saying that one is just the right person for a given job.


Thursday, April 11, 2013

Arsenic and lead in US rice imports

If you live in US [may be Canada too, what is the difference yeah?]  and consume lot of rice, you may want to read this. When it comes to buying rice, you can buy either rice produced in US or imported from some other part of the world. US imports only 7% its rice from Asia, Europe and South America, remaining is produced in several parts of US including Louisiana, Texas and California.
Whether the rice you buy is imported or not, they pose some series health problems.
  1. Rice that is produced in US has high levels of arsenic. - FDA & Consumer Reports
  2. Imported rice has lead that is 10 times more than recommended level. See these links. American Chemical Society & BBC
FDA classifies arsenic into two different categories, organic and inorganic and also states that arsenic is a naturally occurring element in soil and water. ““natural” does not equal safe”. Its still cancer causing group 1 carcinogen. Read this report from Consumer Reports.
But “natural” does not equal safe. Inorganic arsenic, the predominant form of arsenic in most of the 65 rice products we analyzed, is ranked by the International Agency for Research on Cancer (IARC) as one of more than 100 substances that are Group 1 carcinogens. It is known to cause bladder, lung, and skin cancer in humans, with the liver, kidney, and prostate now considered potential targets of arsenic-induced cancers.
Arsenic in your food by Consumer Reports
Lead is bigger evil than arsenic particularly for babies and kids. It affects central nervous system along with other organs. When you buy a home that is built before 80’s, lead test is recommended. Back then paint were made with lead and lead was used in plumbing in homes. So lead is a bad news in any form.
It seems rice is more susceptible to these kind of contaminations because it needs lot of water and ironically brown rice is more contaminated than white rice. So in a way, brown rice is bad for you than white rice. Feels wired to write it.
Rice is a staple food among Asian and Latino communities in US. So can we do anything to not to poison ourselves and our babies.
There are several suggestions,
  1. Diversify your diet. Consume other types of grains too.
  2. Try to buy rice that is produced in US and particularly from California and other than “southern states”. It may also help California come out of their debts Smile.
  3. Basmati rice has lower levels of arsenic than other kind. Arsenic in Rice – FDA.
  4. Limit brown rice consumption.
  5. Chicago Tribune suggests several easy things like rinse the rice before cooking, cook and drain your rice. Bad news for you pressure cooker.
Wired thing is my grandma and mom used rinse and drain the rice they cooked. They didn’t need a FDA report to tell them. Not that I am claiming they knew about arsenic and lead poisoning.  Too bad we are too busy to be mindful, healthy and happy.

Monday, March 25, 2013

Thursday, March 7, 2013

Trip Ideas in Wisconsin


Summer is almost here in Wisconsin. Few ideas to spend your summer in Wisconsin.

  1. Menominee River Whitewater Rafting
  2. Apostle Islands National Lakeshore. Wiki, Trip Ideas, Kayaking
  3. Copper Falls State Park. Wiki, Trip Advisor

Tuesday, January 29, 2013

சிறு மகிழ்சி, சிறு நம்பிக்கை

பனி காலத்தின் நடுவே
ஒரு வசந்த நாள்,
தேர்வு நாளன்று 
யாரோ இறந்ததால் கிடைத்த 
கல்லுரி விடுமுறை.

Thursday, January 24, 2013

PowerShell: Listing files/directories only


In DOS, it is always easy to find only directories or only files,

For example,

will display only directories. If you want to display just files, you can do this,

Ironically, PowerShell which is more powerful and modern than DOS, it is not very straightforward to do this.

In PowerShell 2.0 you have couple of not very straightforward options,

Do this no more, PowerShell 3.0 is here with the fix, Now it has two new switches –File,–Directory

PowerShell 3.0 also comes with –Attribute switch to do make it even more powerful.

Tuesday, January 22, 2013

Some “fun” hacks with batch script

  1. Always quote variable or value in “IF” statements.

    This script will return expected results if both var1 and var2 has some value and don't have any spaces in the value

    So, what is the fix here. You can either put quote around the value or variable. If you are checking an environment variable that holds file path like JAVA_HOME, you may not able to put quote around the value. You have to follow the later approach.

  2. Inside an “IF” block, if you want to set some value to a variable and that value contains parentheses, quote the SET statement like below.

    Following script will fail, because it has parentheses and it gets mixed up with IF statement syntax.

    If you can put quote around the value, wrap the value with quotes.

    If you can't put quote around the value, put quote around entire statement excluding SET

Monday, January 7, 2013

Android: How to version command line build?


Philosophy behind Continues Integration is, integrate often, build often, run often and test often. This post is about “build often” part. To build often, you need to have a slick build process. If you have one simple command line to build your entire project that may encourage you and also other developers in your team to build often.

If you are building android project in command line and not sure how to update the version code and version name attributes in AndroidManifest.xml file, this might help.

In your build.xml file, you should see this line.

This custom_rules.xml, helps you to keep your customization in a separate place so when build.xml file is changed by Android Team, you don’t have to worry about merging. If you already have one in place you are good to go, if not create it.

Initially your custom_rules.xml should look like this,

You can pass version info in two ways,

  • Using a property file
  • Using command line arguments

To pass version info using property file,

Create this target in custom_rules.xml file,

And create this file,

To pass version info using command line arguments,

Create this target in custom_rules.xml file,

In the above target, we are using variable Version.Code and Version.Name. Lets pass these variables from command line,

Now we have the targets to update the version info. This targets needs to be called from somewhere. You could do this in several ways. 1. custom_rules.xml has several hooks such as pre-build, post-build. We can call our desired target in pre-build, so that version info gets updated every time we build it. 2. You can call the target from command line right before you build your app like the code below.

Complete custom_rules.xml file,