Comments in the code explain “why,” the code itself shows “how”.
Wednesday, October 30, 2013
Friday, September 6, 2013
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”.
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.
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.
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 & Aortic 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 & Mitral 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
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
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,
- Comparing Wearables: Fitbit Flex vs. Jawbone Up and More : All Things D
- Comparison of Fuel, Up and Flex : The Verge
- How Accurate Are Fitness Trackers? : New York Time
Check back later for my review of Fitbit Flex and Aria.
Wednesday, June 26, 2013
The ratio of time spent reading (code) versus writing is well over 10 to 1 ... (therefore) making it easy to read makes it easier to write.
Thursday, June 13, 2013
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.
Let’s write a simple application that finds out total distance user has walked so far using RunKeeper’s API.
Accessing RunKeeper’s API involves couple of steps,
- Redirect user to RunKeeper’s authorization URL on a WebView.
- Get permission from user to access their data.
- Once they allow it, Run Keeper will redirect with an “Authorization Code”.
- With the Authorization Code make a Post request to get the access token.
- 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.
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”[https://api.runkeeper.com/user/] endpoint to get list of URLs available for you. If we query http://api.runkeeper.com/records 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.
Monday, June 10, 2013
A thing that fails to work properly or is otherwise unsatisfactory or worthless.
Friday, May 31, 2013
Thursday, May 30, 2013
Wednesday, May 22, 2013
Tuesday, May 21, 2013
Wednesday, May 15, 2013
Be the Change you wish to see in the World.
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.
Monday, May 13, 2013
Thursday, May 9, 2013
Wednesday, May 8, 2013
Saturday, May 4, 2013
Friday, May 3, 2013
- 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
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
Monday, April 29, 2013
Friday, April 26, 2013
Thursday, April 25, 2013
Thursday, April 11, 2013
Whether the rice you buy is imported or not, they pose some series health problems.
- Rice that is produced in US has high levels of arsenic. - FDA & Consumer Reports
- Imported rice has lead that is 10 times more than recommended level. See these links. American Chemical Society & BBC
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.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.
- Arsenic in your food by Consumer Reports
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,
- Diversify your diet. Consume other types of grains too.
- 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 .
- Basmati rice has lower levels of arsenic than other kind. Arsenic in Rice – FDA.
- Limit brown rice consumption.
- Chicago Tribune suggests several easy things like rinse the rice before cooking, cook and drain your rice. Bad news for you pressure cooker.
Monday, March 25, 2013
Thursday, March 7, 2013
Monday, March 4, 2013
Tuesday, January 29, 2013
Thursday, January 24, 2013
In DOS, it is always easy to find only directories or only files,
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
- 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.
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
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 version.properties 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,