We were lucky to catch the occasion sanath rolled over for the first time. Sanjay is in bangalore, for his onam vacation. Arya as usual is in our room at night, trying out the dresses of Sanath. He was making efforts to roll over for the past 2 days, and I was shooting with veena's mobile. suddenly, he was successful.
Thursday, September 8, 2011
Wednesday, August 24, 2011
Account management script in Python for Android
for this script, you need to download sl4a. and also install python for android from the download page in this site.
import android, os , datetime
droid = android.Android()
docdir = "./"
loop = 1
file_name=""
def select_account ():
dirfile = os.listdir (docdir)
dirfiles =[]
for f in dirfile :
if f[-4:]==".acc":
dirfiles.append (f)
if len(dirfiles) == 0:
droid.makeToast('no accounts')
return
d=droid.dialogCreateAlert("select file")
droid.dialogSetSingleChoiceItems(dirfiles)
droid.dialogSetPositiveButtonText('ok')
droid.dialogSetNegativeButtonText('cancel')
droid.dialogShow()
r=droid.dialogGetResponse().result
if r['which']== "negative":
return (1)
result = droid.dialogGetSelectedItems().result[0]
global file_name
file_name = dirfiles [result]
return (0)
def add_dialogue():
if select_account () != 0:
return
f = open (docdir + file_name, "a")
droid.dialogCreateAlert(None, None)
droid.dialogSetSingleChoiceItems(["receipt", "payment"], 0)
droid.dialogSetPositiveButtonText('ok')
droid.dialogShow()
r = droid.dialogGetResponse().result
receipt = droid.dialogGetSelectedItems().result[0]
amount= droid.dialogGetInput("amount", None, None).result
try:
famount = float (amount)
if receipt == 1:famount = -famount
except:
return
head = droid.dialogGetInput("description", None, None).result
out_string = str(datetime.date.today()) + " :: " + head + " :: " + str(famount)
f.write (out_string +"\n")
droid.makeToast(out_string)
def show_dialogue():
if select_account () != 0:
return
f= open ( docdir+ file_name , "r")
lines = f.readlines ()
message = ""
total= 0
for line in lines:
values = line.split (" :: ")
message = '%+6.0f : %-8s : %s\n' % ( float ( values[2]), values[1][:8], values[0][5:]) + message
total += float (values[2])
message = "Total = " + str(total) + "\n\n" + message
droid.dialogCreateAlert(None, message)
droid.dialogShow()
droid.dialogGetResponse()
def create_account ():
f = droid.dialogGetInput('Account name', None, None).result
if f == None:
return
f = docdir + f +".acc"
file = open (f, "w")
file.close ()
droid.makeToast('created file: ' + f)
while loop:
droid.dialogCreateAlert(None, None)
droid.dialogSetSingleChoiceItems(["add transaction", "show accounts", "create account"], 0)
droid.dialogSetPositiveButtonText('ok')
droid.dialogSetNegativeButtonText('exit')
droid.dialogShow()
r=droid.dialogGetResponse().result
if r['which']== "negative":
os._exit (1)
result = droid.dialogGetSelectedItems().result[0]
if result == 0 :
add_dialogue()
elif result == 1:
show_dialogue()
else:
create_account ()
Tuesday, July 5, 2011
Why do we sleep
People think we sleep to take rest. But we can rest without sleeping. Not all of us rest while we sleep. Not surely the heart or respiratory muscles. And if your brain rested, we won't have any dreams.
The purpose of sleep always intrigued me. And I was not alone. At least a few other people were there too. I found these two sites (big think and physorg.com) where the neuroscientists' opinion about the matter is discussed. Basically they think the reason for sleep is either :
Evolutionarily it takes a lot to adapt to a particular environment. So all organisms, are adapted to one or the other kind of environment (called ecological niche). Then, at the same place, the environment changes vastly during the 24 hours a day. Animals behavior is expected to vary greatly during the day and night. For one animal, it may be difficult to be this versatile, so, nature makes it adapted to one of the time period in a day, and sleep during the other.
Pretty neat?
The purpose of sleep always intrigued me. And I was not alone. At least a few other people were there too. I found these two sites (big think and physorg.com) where the neuroscientists' opinion about the matter is discussed. Basically they think the reason for sleep is either :
- information processing theory - to sort out the informations that have come in during the day (brain defragmentation?)
- damage reversal theory - to remove free radicals and other noxious substances generated by 'heated thinking' during the day
- adaptive inactivity theory - by UCLA neuroscientist Jerome Siegel, which says that sleep optimizes the timing of our activity.
Evolutionarily it takes a lot to adapt to a particular environment. So all organisms, are adapted to one or the other kind of environment (called ecological niche). Then, at the same place, the environment changes vastly during the 24 hours a day. Animals behavior is expected to vary greatly during the day and night. For one animal, it may be difficult to be this versatile, so, nature makes it adapted to one of the time period in a day, and sleep during the other.
Pretty neat?
Sunday, July 3, 2011
android scripting using python
Android has a beautiful scripting platform 'sl4a'. You can script using lot of languages perl, python, shell etc in it. It has a good API for system calls like sending sms, making calls etc.
I've written a small script in python to send a group sms with individualised content.
import android, os, re
droid = android.Android()
docdir = "/mnt/sdcard/document"
Android calls are in android module. other modules like sys, os, re are available.
message =droid.dialogGetInput('message', ' extras: 0 name,1 mail', None).result
subject =droid.dialogGetInput('subject', '', None).result
message windows can be created using API calls.
dirfile = os.listdir (docdir)
dirfiles =[]
for f in dirfile :
if f[-4:]==".sms":
dirfiles.append (f)
d=droid.dialogCreateAlert("select file")
droid.dialogSetSingleChoiceItems(dirfiles)
droid.dialogSetPositiveButtonText('ok')
droid.dialogSetNegativeButtonText('cancel')
droid.dialogShow()
r=droid.dialogGetResponse().result
if r['which']== "negative":
os._exit (1)
result = droid.dialogGetSelectedItems().result[0]
selfile = dirfiles [result]
All files in a directory ending with .sms is presented and the user is asked to select one of the files.
file = open (docdir + os.sep+ selfile, "r")
lines = file.readlines ()
contacts = []
numbers =[]
extras =[]
mail =""
for line in lines:
f = line.split (",")
if len (f[0])>0 :
numbers.append (f[0])
contacts.append (f[1])
extras.append (f[1:])
if len (f[1])>0 :
mail = mail + f[2].replace(" ","").replace ("\n","") + ","
The .sms file is a comma seperated file whose first field is the contact number, second contact name, third his email, and any optional field which can be referred as $n in the message.
d=droid.dialogCreateAlert("select contacts")
n = len (contacts)
droid.dialogSetMultiChoiceItems(contacts, range (n))
droid.dialogSetPositiveButtonText('ok')
droid.dialogSetNegativeButtonText('cancel')
droid.dialogShow()
r=droid.dialogGetResponse().result
if r['which']== "negative":
os._exit (1)
send_contacts= droid.dialogGetSelectedItems().result
for s in send_contacts :
m= message
for d in range(len(extras [s])):
m = m.replace ("$"+str(d), extras[s][d])
m=re.sub('\$\d','',m)
droid.smsSend(numbers [s], m)
print contacts[s] , m
droid.sendEmail(mail, subject, message, None)
The user is presented a list of contacts to select from, to whom to send the message. The script also sends an email with the same message (without personalisation)
I've written a small script in python to send a group sms with individualised content.
import android, os, re
droid = android.Android()
docdir = "/mnt/sdcard/document"
Android calls are in android module. other modules like sys, os, re are available.
message =droid.dialogGetInput('message', ' extras: 0 name,1 mail', None).result
subject =droid.dialogGetInput('subject', '', None).result
message windows can be created using API calls.
dirfile = os.listdir (docdir)
dirfiles =[]
for f in dirfile :
if f[-4:]==".sms":
dirfiles.append (f)
d=droid.dialogCreateAlert("select file")
droid.dialogSetSingleChoiceItems(dirfiles)
droid.dialogSetPositiveButtonText('ok')
droid.dialogSetNegativeButtonText('cancel')
droid.dialogShow()
r=droid.dialogGetResponse().result
if r['which']== "negative":
os._exit (1)
result = droid.dialogGetSelectedItems().result[0]
selfile = dirfiles [result]
All files in a directory ending with .sms is presented and the user is asked to select one of the files.
file = open (docdir + os.sep+ selfile, "r")
lines = file.readlines ()
contacts = []
numbers =[]
extras =[]
mail =""
for line in lines:
f = line.split (",")
if len (f[0])>0 :
numbers.append (f[0])
contacts.append (f[1])
extras.append (f[1:])
if len (f[1])>0 :
mail = mail + f[2].replace(" ","").replace ("\n","") + ","
The .sms file is a comma seperated file whose first field is the contact number, second contact name, third his email, and any optional field which can be referred as $n in the message.
d=droid.dialogCreateAlert("select contacts")
n = len (contacts)
droid.dialogSetMultiChoiceItems(contacts, range (n))
droid.dialogSetPositiveButtonText('ok')
droid.dialogSetNegativeButtonText('cancel')
droid.dialogShow()
r=droid.dialogGetResponse().result
if r['which']== "negative":
os._exit (1)
send_contacts= droid.dialogGetSelectedItems().result
for s in send_contacts :
m= message
for d in range(len(extras [s])):
m = m.replace ("$"+str(d), extras[s][d])
m=re.sub('\$\d','',m)
droid.smsSend(numbers [s], m)
print contacts[s] , m
droid.sendEmail(mail, subject, message, None)
The user is presented a list of contacts to select from, to whom to send the message. The script also sends an email with the same message (without personalisation)
Friday, June 3, 2011
Evolution of Sexes
Want to know why there are sexes at all?
Or Why there are two sexes?
Or why the sexes are different?
Read on
As you know, evolution shapes it all. We can refer to this non-existent ethereal concept as a person or object, because it works out things mathematically, and often we can 'predict' in biology with evolutionary theory. We can do some armchair theorizing also, with the help of TOE (Theory of evolution).
As you already know, at first there were asexual organisms and asexual reproduction. The progeny just resembled the parent, and the evolution and adaption to the environment was slow. When the gametes of two organisms exchange their genetic material, the offspring carries different combination of the species' genes, and thus, the population comprised individuals with different characters, which let the evolutionary force select the fitter ones. Thus when sexual reproduction appeared in the scene, it had advantage over the asexually reproducing ones, and they out-populated them soon. The advantage was worth the pain of evolving the complex mechanisms for this purpose, but as seen repeatedly, nature (or evolution) can go to any length, for a survival advantage.
The sexual reproduction only requires that the offsprings are produced by exchange of genetic material between different individuals. Not between two sexes.
Then why there are two sexes? Because there are different sex chromosomes? The sex chromosomes are different because, they are needed to produce the differences in male and female, not the other way.
In the beginning, indeed there was no different sexes. Any individual could exchange the genetic material with any other of the same species. (You can call all individuals were unisex or that all were true hermaphrodites. All chromosomes were same in all individuals. There were no sex chromosomes.
The advantage of different sexes was in the sea, where life was thriving then. The organisms used to move in the sea, either carried by the current or by swimming with own power. The chance of meeting another individual of same species, and then mating and passing one's genes to next generation before one's death was a big thing then. The organisms adopted all possible strategies to achieve this. One organism could increase it's chance mainly by two strategies. Either moving fast and far, or by becoming big and easily seen. So, different individuals of same species adopted these strategies, and both were mutually exclusive. To move fast, one has to be small, and to be easy target, one has to be big. There cant be intermediate organisms. So all species evolved their members into two distinct sets, one big and one small. They had to have distinct genetics, distinct genetic control mechanisms (steroid hormones control the expression of genes) etc. So, sexes evolved to evolve members of different characters, especially sizes. As the species evolved, and required different characters in different enviornments, the difference between sexes also kept varying, and adopting.
Our steroids make us different not only in sexual organs, but all over physically, on our muscles, shape, psyche etc. These differences are required for the differing needs of the different strategies of two sexes.
To this date, we have retained some of the original characters of sex differences, male gametes are small and fast and female ova are big and non-motile. Only that the original character has moved from the individual to it's gamete!
The individual itself also retains these original characters. The females are stationary, like to attract males, be the target. Males run around, eying any female at sight, and are involved in temporary relationships! We still carry the characters of those small insignificant creates in the sea!
Or Why there are two sexes?
Or why the sexes are different?
Read on
As you know, evolution shapes it all. We can refer to this non-existent ethereal concept as a person or object, because it works out things mathematically, and often we can 'predict' in biology with evolutionary theory. We can do some armchair theorizing also, with the help of TOE (Theory of evolution).
How sexes evolved
As you already know, at first there were asexual organisms and asexual reproduction. The progeny just resembled the parent, and the evolution and adaption to the environment was slow. When the gametes of two organisms exchange their genetic material, the offspring carries different combination of the species' genes, and thus, the population comprised individuals with different characters, which let the evolutionary force select the fitter ones. Thus when sexual reproduction appeared in the scene, it had advantage over the asexually reproducing ones, and they out-populated them soon. The advantage was worth the pain of evolving the complex mechanisms for this purpose, but as seen repeatedly, nature (or evolution) can go to any length, for a survival advantage.
Why sexes are different
The sexual reproduction only requires that the offsprings are produced by exchange of genetic material between different individuals. Not between two sexes.
Then why there are two sexes? Because there are different sex chromosomes? The sex chromosomes are different because, they are needed to produce the differences in male and female, not the other way.
In the beginning, indeed there was no different sexes. Any individual could exchange the genetic material with any other of the same species. (You can call all individuals were unisex or that all were true hermaphrodites. All chromosomes were same in all individuals. There were no sex chromosomes.
The advantage of different sexes was in the sea, where life was thriving then. The organisms used to move in the sea, either carried by the current or by swimming with own power. The chance of meeting another individual of same species, and then mating and passing one's genes to next generation before one's death was a big thing then. The organisms adopted all possible strategies to achieve this. One organism could increase it's chance mainly by two strategies. Either moving fast and far, or by becoming big and easily seen. So, different individuals of same species adopted these strategies, and both were mutually exclusive. To move fast, one has to be small, and to be easy target, one has to be big. There cant be intermediate organisms. So all species evolved their members into two distinct sets, one big and one small. They had to have distinct genetics, distinct genetic control mechanisms (steroid hormones control the expression of genes) etc. So, sexes evolved to evolve members of different characters, especially sizes. As the species evolved, and required different characters in different enviornments, the difference between sexes also kept varying, and adopting.
Why the sexes have different characters?
Our steroids make us different not only in sexual organs, but all over physically, on our muscles, shape, psyche etc. These differences are required for the differing needs of the different strategies of two sexes.
To this date, we have retained some of the original characters of sex differences, male gametes are small and fast and female ova are big and non-motile. Only that the original character has moved from the individual to it's gamete!
The individual itself also retains these original characters. The females are stationary, like to attract males, be the target. Males run around, eying any female at sight, and are involved in temporary relationships! We still carry the characters of those small insignificant creates in the sea!
Saturday, April 30, 2011
Does drinking cold water cause soar throat?
People got this wrong idea. Soar throat is an infection, and is not caused by a physical insult (that too just bit cold water). There are few references available. see the link below:
Read these references
Published with Blogger-droid v1.6.8
Read these references
Published with Blogger-droid v1.6.8
Friday, April 22, 2011
Subscribe to:
Posts (Atom)



