Saturday, November 23, 2013

Google charts

I finally had some time to dabble with the Google charts API. Its really cool .
Here is a sample chart I prototyped using the Yahoo finance api (YQL).

Sunday, August 11, 2013

Interesting Quote

Crave for a thing, you will get it. Renounce the craving, the object will follow you by itself.
-Swami Sivananda This quote holds soo true to me

Tuesday, July 2, 2013

Highcharts

I was dabbling with this new chart library called Highchart . This is a simple prototype that plots RBA gold prices in USD currently statically ..

Thursday, July 28, 2011

Android Aync task

I am working on some android applications and thought I'd share how Async task works with a simple example.

Android applications are designed to be responsive. When unresponsive the android OS uses the tough love approach and offloads the app i.e the ANR(App not responding exception). When we do network calls off the mainthread these will block since network connections are relatively slow . To avoid this problem we will need to offload this network call to another worker thread.
This can be achieved using the AsyncTask

Methods we care about in AsyncTask
*onPreExecute()-
Runs on UI Thread before handing over to worker thread

*doInBackground()
Workhorse runs in background
*publishProgress()
inform UI about progrèss called from doInBackground()
*onProgressUpdate()
runs on UI thread and updates progressBar
*onPostExecute
runs in UI thread once worker thread is done

ProgressActivity has a button which will update a progress bar when hit.


package com.foo;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.Toast;

public class ProgressBarActivity extends Activity implements OnClickListener {
private ProgressBar progressBar;
private Button start;

public class BackgroundAsyncTask extends AsyncTask {

int myProgress;

@Override
protected void onPostExecute(Void result) {
Toast.makeText(ProgressBarActivity.this, "onPostExecute all done back in UI",
Toast.LENGTH_LONG).show();
}

@Override
protected void onPreExecute() {
Toast.makeText(ProgressBarActivity.this,
"preexecute -before back ground processing starts",
Toast.LENGTH_LONG).show();
myProgress = 0;
}

@Override
protected Void doInBackground(Void... params) {

while (myProgress < 100) {
myProgress++;
publishProgress(myProgress);
SystemClock.sleep(20);
}
return null;
}

@Override
protected void onProgressUpdate(Integer... values) {

progressBar.setProgress(values[0]);// called by the publishProgress
// method to update progress bar
}

}

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

start = (Button) findViewById(R.id.startprogress);
progressBar = (ProgressBar) findViewById(R.id.progressbar_Horizontal);
progressBar.setProgress(0);

start.setOnClickListener(this);

}

@Override
public void onClick(View v) {
new BackgroundAsyncTask().execute();

}
}

Friday, March 25, 2011

Zuccini and Potato soup

I have become a big soup freak . Its been one of the fads thats infected me for the last year
This is a really easy recipe for all you folks who arent fussed about sitting by the stove all day and comes out pretty darn nice
Take a couple of potatoes cube em
Zuccini *2 remove skin and cut coarsely
onions *1 slize
garlic *2 slice

Procedure
1)roast onions and garlic
2)put zucinni onions potatoes and garlic in some vegetable stock
3)cook till tender
4)then out comes the trustee hand blender
5)blend away add some pepper and salt
6)bring to boil
7)fry some sage with butter and add on top

serve with crusty bread

How to detect language of a document

Recently I wrote a program to detect the human language of a given text . I was asked to do this task in 24 hours .After a lil googling I finally found this paper for N-Gram-Based Text Categorization by these two guys
William B. Cavnar and John M. Trenkle from Michigan AnnHarbour
Defn Worth a read...

Firstly what is a ngram ?
An Ngram is an n character slice of a string(From the paper verbatim)
so for APPLE you will have ngrams _,A,P,L,E then _A,AP,PL,LE,_AP,PLE etc

The basic algorithim if you dont have the patience to read this paper is

1)Create a ngram based profile for a document i.e this is basically finding the frequency of occurances of all the NGrams in your language document
2)Sort this ngram based profile with the highest frequency on top this would tell you the most occuring ngrams.
3)Now if you were to find the language of origin of a document then you will need to find its profile and then sort it by highest frequency
4)Now find a minimum distance between these documents i.e if the document is like the language this should be very small so the frequency of occurance of the words/syllables in the document and language would be similar .

Thursday, August 26, 2010

raagi(Finger millet) porridge for babies

I have started ragi koozhu(porridge) for my baby.Its pretty good . Ragi is very nutritious and is very good for adults also .I found this really interesting link on Ragi's nutritive value http://vegweightlossdiets.com/ragi-nutrition/

Ragi is very high in calcium and iron . In many parts of south India babies are given ragi as a first food .Sprouted ragi powder for the baby is pretty easy to make.When stored well it keeps as well though I make it once a month .

Ragi(Finger MIllet) is available in some Indian grocers I buy it from Udaya Spices at Station Street in WentworthVille.

First wash the Ragi and immerse it in water for 2 -3 hours then allow it to sprout I put the ragi in a muslin cloth and put it into my oven (any warm place should do).It takes 7-8 hours to sprout but this will vary depending on the season.
Once its sprouted the ragi is to be dried fully .I put the ragi into my oven and put the oven on fan heat for 15-20 mins .

This porridge also uses wheat and chatni chana. I buy whole wheat grains from Udaya spices wash the whole wheat and dry it in the oven for 15-20mins .I only toast the chatni chana .

The ratio I use for this porridge is ragi:wheat:chatnichana is 2:1:1 .The porridge powder can vary slightly so I Just eyeball the ratios . Now grind the roasted ragi,wheat and chatni chana till it becomes a fine powder I then run this into a seive and then store the powder in an airtight container.

To prepare the porridge I mix one spoon of the porridge powder with water and cook it .
To this I add cooked banana or pumpkin or cooked apple ,pears etc .In India I am told that its customary to use milk to cook the porridge or if cooked in water ghee is added finally. I have refrained from doing this as of now since I would like to wait before I introduce milk to the baby.