Cover photo
David Ratnasabapathy
Lives in Sri Lanka
1,092 followers|193,292 views


David Ratnasabapathy

Shared publicly  - 
Google search operators help find your missing mail

If you, like me, are a packrat who hates deleting mails (you might really need it some day!) you have a massive yet poorly organized inbox and outbox.

And comes the day when indeed you must find a particular message you sent a friend -- how do you find it, when you have literally hundreds of mails to search, and no good idea what you said?

Well if you, like me, know roughly when you wrote the message you're looking for, be flummoxed no further.  gmail's search bar will find it for you.  Type this:

to: after:2008/04/01 before:2008/04/30

Presto, just a few messages to sift through!

Gmail's search operators are varied and powerful.  Check the link above!
Advanced search operators are query words or symbols that perform special actions in Gmail search. These operators allow you to find what you're looking for quickly and accurately. They can also be used to set up filters so you can organize your inbox automatically.
Add a comment...

David Ratnasabapathy

Shared publicly  - 
How to enter a frequency distribution into R
R is an incredibly sophisticated piece of statistical analysis software.  It's free too.  Runs on everything --- Windows, Mac, Linux.

Me, I'm a novice.  Given a set of data, I just want R to tell me its sum and its sum of squares.  When the data's in a list, like this ---
x : 1  1  1  3  3  3  3  4  4
It's easy.  Issuing the command
>   x <- c(1, 1, 1, 3, 3, 3, 3, 4, 4)
Will store the data inside the vector x.  The commands
>  sum(x)
>  sum(x^2)
Will return the sum of data values and the sum of squared data values respectively. 

Trouble starts when the data's given in the form of a frequency distribution.  The data above is as easily (and more legibly) described by the frequency distribution
x :  1  3  4
f :   3  4  2
Now the 'x' row lists the distinct values we observe; the 'f' row shows their frequencies --- how often each value occurs.  So data value 1 has frequency 3, telling us that 1 appears three times in the list of data; data value 3 appears four times, and data value 4 appears twice.  How do we get the sum and sum of squares now?  One way is by brute force. For the sum, do
>  sum(f * x)
And for the sum of squares
>  sum(f * x^2)

But that's inefficient.  Instead of letting R's statistical functions extract information for us, we're just using R as a primitive handheld calculator.  Is there no better way?  If only there were some way to efficiently extract the data set {1, 1, 1, 3, 3, 3, 3, 4, 4} defined by that frequency distribution above!

And what do you know, there is.  The `rep' command, which repeats vectors in various complicated ways, will do that for us!

First store the frequency distribution in R.
>  x <- c(1, 3, 4)
>  f  <- c(3, 4, 2)
The vector x now contains the list of values and the vector f contains their corresponding frequencies.  Use the rep command to repeat the x values as specified by f.  Do
>  y  <- rep(x, times=f)
And that's it!  The data's been extracted and stored in vector y!
>  sum(y)
>  sum(y^2)
Will return the sum and sum of squares.

#math #statistics #R  
Add a comment...

David Ratnasabapathy

Shared publicly  - 
What a six-figure advance _really_means
Charles Stross explains the sad truth.  Yes, popular authors are offered vast sums by publishers for their books.  But those vast sums are spread out over years.  And they require a continuous output of books --- you know, work.

It sounds great, but when you break it down and look at the small print, it was £1M for ten books, delivered at a rate of one a year. Minus a 15% cut for his agent. With joint accounting and world English language rights (at least) thrown in. And payable in small pieces. Upshot: a £85,000 a year salary for ten years (and you can be damned sure Gollancz inserted some termination clauses in the contract in case things didn't go according to plan).

And that's the successful ones!  If you're planning on writing for money,

1.  John Scalzi's book, You're Not Fooling Anyone When You Take Your Laptop To A Coffeeshop, is an excellent introduction how to.

2.  Don't give up your day job.
Gillian Andrews's profile photo
Add a comment...

David Ratnasabapathy

Shared publicly  - 
This is fascinating, because it takes something so commonplace that we barely notice it, and explains how it came to be.  I love articles like this.
Forever in blue jeans...

 • Blue denim jeans are worn and loved the world over by many people. Worn by Presidents, celebrities, farmers, housewives, college kids - they are comfortable, durable, cool and sexy.

• As described in the book 'Denim: from cowboys to catwalks - a visual history of the world's most legendary fabric' by Graham Marsh and Paul Trynka, "Denim links dustbowl cowboys and high fashion models. It is both a symbol of the counterculture and the generator of huge amounts of money. It is a simple fabric, dating back to 18th-century France, which has become a symbol of street credibility and sex appeal.The book describes the evolution of the denim business, from pioneering brands like Levi's, Lee and Wrangler to its use by high fashion houses such as Alexander McQueen, Vivienne Westwood, Ralph Lauren and Calvin Klein.

·• Blue denim jeans
Ever wondered where the blue colour of blue jeans comes from, and why denim cloth is different to other fabrics?
The blue dye is Indigo which is a natural dye extracted from the plant Indigofera tinctoria, It is an organic compound with a distinctive blue colour, primarily used to dye cotton yarn which is used in the production of denim cloth.On average a pair of  jeans needs 3 - 12 g of dye.The denim fabric is woven in a special way so that the blue is visible on the outside of the garment while the inside remains white.

Obtaining the blue dye from the plant
The plant Indigofera tinctoria contains 0-2 - 0-8% of a compound called 'indican' which is the precursor to the blue dye indigo.
Indican is a colorless water soluble substance which readily hydrolyses to form 'indoxyl', which in turn gets oxidised to indigo on exposure to air. Indican was obtained from the leaves of the plant by soaking them in water and fermenting to produce the blue dye. Different shades of blue and purple were produced from the precipitate of the fermented leaf solution.

Synthetic dye
The indigo dye used today, to produce denim cloth is synthetic. Indigo has been prepared by many methods, as far back as 1882 by the  Baeyer-Drewson indigo synthesis. However, the first practical synthesis is due to Pfleger in 1901. In this process, N-phenylglycine is treated with a molten mixture of sodium hydroxide, potassium hydroxide, and sodamide.

How denim cloth is woven
Denim cloth is woven with two yarns - one dyed indigo, the other undyed. Indigo yarn is most visible on the outside, undyed yarn on the inside
It is described as a 'rugged cotton twill textile', in which the weft passes under two or more warp threads, called the 'twill' weaving which produces the familiar diagonal ribbing of the fabric.
It is characteristic of any indigo denim that only the warp threads are dyed, whereas the weft threads remain plain white. As a result, one side of the fabric shows the blue warp threads, the other side shows the white weft threads. This is what makes the fading characteristics of denim jeans so unique compared to other fabrics.

Blue denim jeans will live forever...
(image credit:
For +ScienceSunday curated by +Allison Sekuler +Robby Bowles +Rajini Rao +Chad Haney +Buddhini Samarasinghe 
Add a comment...

David Ratnasabapathy

Shared publicly  - 
Kee Hinckley's profile photo
I introduced them when my ex and I used to get in stupid arguments. Good for when you realize you really ought to just backdown/give up but you're too angry to apologize right then.
Add a comment...

David Ratnasabapathy

Shared publicly  - 
Medical Daily shows how not to do science journalism
Genetics was so simple 20 years ago.  DNA is transcribed into messenger RNA.  Messenger RNA drifts out of the cellular nucleus and makes proteins.  Proteins build bodies.  Ta daah!  Changes in DNA cause changes in messenger RNA which cause changes in proteins which cause changes in bodies; and those, if selected for, cause evolution.

DNA -->  messenger RNA -->  protein -->  a body

Now microRNA shows up and complicates things!

Not really.  microRNAs are in fact amazing.  They show us DNA controlling itself as it makes messenger RNA!  microRNAs are fascinating to anyone interested in evolution.

DNA, it turns out, doesn't just make messenger RNA.  Some stretches of DNA --- teeny stretches of it --- make microRNA.  microRNAs are small molecules of RNA.  They help determine if, and to what extent, proteins are made.  They do so by attacking and destroying messenger RNA before it can escape the nucleus to make proteins.

DNA --> (messenger RNA and microRNA) --> (microRNA attacks messenger RNA) --> (surviving messenger RNA) --> protein --> a body.

Yes, it looks bizarre to me too.

Be that as it may, a microRNA can stop production of a particular protein by destroying its associated messenger RNA; and if it can't destroy all the messenger RNA, it can at least reduce the production of that protein.  Which influences the reactions involving that protein.  Which, in turn, summed over many microRNAs and many proteins (a body is complicated), may alter slightly the design or functioning of a body.  One way in which evolution can happen, then, is by changes in the DNA that makes microRNAs.  At least some of the differences between us and the other apes, surely, are due to changes in the microRNA producing regions of our DNA.

Enter Hu, H. Y. et al. 2012.  That's a paper in Nature Communications.  It describes the discovery of a microRNA, miR-941, that is unique to humans!  It evolved in our lineage some time after we split from Chimpanzees. Even better, the proteins regulated by this microRNA play some role in the functioning of our brains!

It is a fascinating discovery.  It's the first step on the long road of discovery and deduction that, possibly only a few decades from now, will elucidate the 6-million-year-long origin of our species.  

What miR-941 isn't is the "Single Gene" that is the "Difference between humans and apes".  There is no such thing for starters, not the way natural selection builds species.  Yet that is precisely what Medical Daily is claiming.  It's sad.  They take a delightful and intriguing discovery and, in loudly caricaturing it as an earth-shattering breakthrough, obnubilate its context and meaning.  Jerry Coyne at Why Evolution is True has the details.
Add a comment...

David Ratnasabapathy

Shared publicly  - 
How to remember the difference between Mitosis and Meiosis
Forgive me, I keep forgetting!  Mitosis describes the process through which a cell makes an exact copy of itself. Mitosis is how a fertilized egg cell divides and divides to make you. In Meiosis a cell makes two divides into daughters, each of whom have exactly half the chromosomes of their mother. Meiosis is how we make the sperm and eggs that merge to make that fertilized egg cell.  The problem is that I can never remember which is which.

Here +Rajini Rao shares a most well-crafted poem, the solution to this problem.  Enjoy!
Ode to Mitosis

Mitosis is a process
For One cell to become Two
There are Four distinct phases
Happening within You

First comes Prophase
The Chromatin strands condense
They now become visible
Through a microscope lens

Next comes Metaphase
The important Stage Two
Chromosomes attach to Spindle Fiber
Using Molecular Glue

Then comes Anaphase
It's really quite sad
Sister Chromatids separate
To opposite poles- too bad :(

Finally, it's Telophase
Nuclear membranes reform
Spindle fibers disperse
And Two new cells are born.

Poem: Playfully plagiarized, willfully altered and spell-checked from the original "reallygoodpoetry" at

Images: Gifs from
Watch original movie here:

Add a comment...

David Ratnasabapathy

Shared publicly  - 
The Google Doodle celebrates Sri Lanka's Independence Day

I suspect this appears only for people browsing from Sri Lanka, but it's sweet nevertheless.  The colours of the doodle echo the colours of the Sri Lankan flag; the Lion is the symbol on that flag.

It has to be said, our successive governments' commitment to Liberty, Equality and Justice haven't been, ah, ideal; but no horror they have ever perpetrated could match the nightmare of centuries of foreign tyranny.  Good riddance.
Kee Hinckley's profile photoBuddhini Samarasinghe's profile photo
Thanks for the tag +Kee Hinckley :) Can't see it on, but I do see it on
Add a comment...

David Ratnasabapathy

Shared publicly  - 
The Y chromosome is not decreasing in size
One downside of this getting older business is that some of the stuff you learned turns out not to be true.  Take the Y-chromosome.  it's not the smallest chromosome (Chromosome 21 is) but it's still tiny.  And that makes sense: we expect it to disintegrate over millions of years.  Because it's the one chromosome that doesn't exist as a pair.  Mutations on the Y can't be corrected or ameliorated by an undamaged partner.  It's reasonable that mutations that shift genes off the Y onto other chromosomes would be selected for.

But "it makes sense" and "it's reasonable" must meet the test of science.  They did.  They failed.  The Y chromosome is stable!

h/t: +Rajini Rao 
Add a comment...

David Ratnasabapathy

Shared publicly  - 
xkcd on living with cancer

...the panel with the whale brought a tear to the eye.
Add a comment...

David Ratnasabapathy

Shared publicly  - 
Holy Moses the pain women willingly go through!
Lousy Canuck describes her experience getting fitted with an IUD.  Bear in mind that she went through this of her own free will.

Then the IUD went it and it was like getting stabbed in the belly three times, one more painful than the last. ... Then the cramping began.

I laid on the bed for a long time as my body effectively screamed “GET OUT GET OUT GET OUT”. I was told the cramping should subside in about 20 minutes but that is not what happened...

Add a comment...

David Ratnasabapathy

Shared publicly  - 
A heartwarming letter about a dying dog
The singer Fiona Apple was scheduled to tour South America.  She cancelled to be with her dog companion, in the last days of their 14 years together.  Here she writes to her fans explaining her decision.

I will not be the woman who puts her career ahead of love and friendship. I am the woman who stays home and bakes Tilapia for my dearest, oldest friend. ...

...So I am staying home, and I am listening to her snore and wheeze, and reveling in the swampiest, most awful breath that ever emanated from an angel.
Add a comment...
I read a lot and I teach Math.
Map of the places this user has livedMap of the places this user has livedMap of the places this user has lived
Sri Lanka
Basic Information