Monday, October 17, 2011

Ability vs Morality


Recently, I was in to some arguments with Apple/Microsoft fanboys. As usual, a lone Linux defender, I was made to fight my own way out. But just one simple argument brought them down. So, I feel, this argument is worth sharing so that similarly trapped open-freaks can use it... No copyrights!!! ;-)

The points put forward by Apple/Microsoft fanboys include, ease of use, eye-candy, availability of third party apps, more choices of games, media, powerful hardware and GUI based tools etc.

Though we can counter the arguments in every front, there is no much room in such arguments when the opposition is deaf to whatever you claim. For example, I quoted that top ten of TOP500 run Linux (ref: http://en.wikipedia.org/wiki/TOP500). But the problem is they are not aware of TOP500! Likewise, they have many misconceptions like Linux = bash. They never heard about Gnome, KDE etc. So let us waste no time in explaining them the more technical aspects of our choice for Linux. Let us attack them using the openness of Linux (i.e. the cornerstone of the entire GNU/Linux/Open Source movement).

Consider this example. Once there lived two archers. One of them is better at shooting arrows than the another. But the better one worked for gang of robbers while the other chose to work for the local scout troop. One day the situation made both of them face each other. The one that was better skilled killed 3 of the men in scout troop, including the lesser skilled archer. But at last, few other men from the scout troop managed to thwart the robbery and killed/chased the gang members. Ultimately, the 3 who sacrificed their life for the public good are real heroes, not the one who was able to kill 3 of the opponents within seconds.

Yes! It is more paying to be in the gang of robbers. And there are some cult like following for evil people like Hitler or Osama, while good people who dared to sacrifice their life for sake of others left unnoticed. How many of you can tell the name of American soldier who shot Osama without Googling? Strictly speaking the one who had more talent ended up in the apt place where his skills are valued, recognized and can be materialized as monetary gains. Survival of the fittest, right? WRONG! This type of silly arguments can be used to justify anything from  petty theft to inhumane crimes like rape or murder. Imagine this "I can beat and tie you up and rape your wife! Survival of the fittest!!" Is that acceptable?

Similarly, technical people should also have some sort of ethics and responsibility towards the tech-community at worst and public at best. It is out of moral responsibility that we should be supporting Free software/Open source. We should choose to be a scout even if we get paid lesser and get lesser visibility. If a doctor claims to have invented cure for cancer by mixing existing pain killer and vitamins (neither of them is invented by him), but patents the same that, anyone who produces or uses the medicine should lick his boots, won't you protest? The same is happening everywhere in the so called "tech giants". That is the exact same reason why death of Dennis Ritchie, who made C and co-invented Unix, is ignored entirely while Steve Jobs, who cheated his friend and his own child, is canonized as patron saint of Technology!

So, it is very bad to just consider the mere outcome, while ignoring the impact in entirety. The locked nature of Microsoft and Apple is causing more harm than good. How much money is wasted in buying laptops where you are forced to pay for a licence of Windows even if you are NEVER going to use it? What about your inability to replace a battery in iPhone? You can't install what you want even after "buying" both the hardware and software?!? Even if you are selling your freedom, they should be paying you! But where in the world and what type of fool will pay for selling his own freedom! If you don't realize what you are missing in Apple/Microsoft products but you can quickly point out that there is something missing here and there in GNU/Linux or BSD, then you are just like saying "I am content with this prison. It is more safe, guarded by police, and I get food on time without doing any hard labor and the cell is painted in the way I wanted"

Monday, July 11, 2011

CYYMMDD (Integer) to DATE in DB2 for iSeries

There is a date format in DB2 for iSeries, CYYMMDD. Technically it is an integer and hence comparison of dates becomes easier and faster job for the machine. The aim of this post is to demonstrate how to convert this CYYMMDD date into a SQL date. This is to ensure that the date is presented to the user in an understandable format and avoid type mismatches while dealing with languages like Java (java.sql.Date).

First, let us understand the format. C YY MM DD. We all can easily get that YY is the last two digits of year, MM is the month and DD is the date. What is that 'C'? As some of you had rightly guessed, it is century. But what century? It is century counted from 1900. So 1900-1999 is 0th century, 2000-2099 is 1st and so on. So, for example, 31st December of 1991 will be written as '0911231'. Likewise 1st of January 2003 will be written as '1030101'. 

So the first three digits from left, added with 1900 will give you the year (1900+103 = 2003)
Next two digits gives you the month
Last two digits gives you the date

One simple approach to this problem is to do substring of the incoming 7 character long string and do the necessary type casting before adding the century-year with 1900, then inserting hyphen (-) at appropriate places, before typecasting the entire thing into SQL DATE format.

Note: SQL DATE typecasting can be done by passing date string in YYYY-MM-DD format to the DATE() function.

But there is a catch here. As the value stored in the database is integer, it needs a pre-typecasting to string before we do the substring operations. OK, let us assume we typecast the integer from a query/parameter in to string and then do substring. Will it work for all cases? Because, preceding zeros are omitted while saving/processing the data as integer and '0911231' will come as a six digit '911231'. Here we can avoid the problem by checking the digits. If it is 7, then do the substring for digits (1,3), (3,5), (5,7). Else do substring for digits (1,2), (2,4), (2,6). Problem solved? The answer is NO!

What about 23rd of February1909? It will come as '90223' a five digit number. Another "else if"? NAH!!! If you are a programmer, please don't consider individual cases and write any code. First understand what is expected and what are all possible inputs we can expect. The best approach to start with is the boundary conditions approach.

As it was explained above, it is a 7 digit integer (positive numbers only). Century is counted from 1900. So dates lesser than 1900 can never come in to the picture and even if some dumbass pass negative values, they deserve to be thrown an incorrect result or error (whatever!). Least possible date is 1st January of 1900 that is '101' (note that it is only three digits, if you take up and proceed with earlier approach, you will end up if/else if/else for 7, 6, 5, 4 and 3 digits and if Linus Torvalds happens to see what you have done, your probability of entering heaven is "nolla".) Now the largest number possible is 31st of December 2899 (999+1900). As the format allows only 7 digits, no further dates can be represented in CYYMMDD format.

So, whatever the input (from 101 to 9991231) I need date. Fine, so I need the century year (that is anything that remains after removing last four digits). So just divide by 10000. Then add it with 1900.

In case of '101' it will be 0+1900=1900 and in case of '1010101' it will be 101+1900=2001. (Integer division NEVER produce decimal results!)

Fine, we got the year. Next let use go for the month. It is in middle (bit tricky here). I find that MOD function in DB2 is handy here. MOD(NUMBER, 10000) will give last four digits and a division by 100 give the first two of the last four digits. So, the formula for month is now MOD(NUMBER, 10000)/100

In case of '101', it will be MOD(101, 10000) = 101. Then 101/100 = 1. This your month. What about 9991231? MOD(9991231,10000) = 1231. Then 1231/100 = 12. This is your month. (again, integer division NEVER produce decimal results!)

So the last two digits, which are date alone remain to be handled now. Again we call upon our trustworthy ally MOD. MOD(NUMBER, 100) will give you the date, whatever may be the case. I think I can safely ignore providing examples on how MOD works with 100 on various digits.

Then we have to place hyphens in between year, month and date and construct a string that will be typecast to date. Did that work?


SELECT DATE(((NUMBER/10000)+1900)|| '-' ||(MOD(NUMBER,10000) /100)|| '-' ||MOD(NUMBER,100)) FROM SYSIBM.SYSDUMMY1;


Where NUMBER is your CYYMMDD integer.

Why don't you write your own custom function to return a DATE for any CYYMMDD date passed as integer?

Sunday, January 30, 2011

Nanganallur Bus Timings


This may be useful to someone... Last updated 30th January 2011.

Sunday, October 26, 2008

Rock On - Thum Ho Thoh


C C
Thum Ho Thoh… Gaata Hai Dil,

Dm G
Thum Nahi… Toh Geet Kaha…

C C
Thum Ho Thoh… Hai Sab Haasil,

Dm G
Thum Nahi… Toh Kya Hai Yaha…
Bb Am
Thum Ho Thoh Hai,

Bm Em
Sapno Ke Jaisa Hasin
F C
Ek Samaa…

G E7
Jo Thum Ho Thoh, Yeh Lagta Hai,

Am F
Ke Mil Gayi, Har Khushi…

G E7
Jo Thum Na Ho, Yeh Lagta Hai,

Am F
Ke Har Khushi, Me Hai Kami…
G G
Thum Ko Hai Maangati…

C Am F C
Ye Jindagiiii iiiii iiii…
Gm A# C
Ooh ho… Ooh ho… Ooh ho Oh… ho ho…

C C
Thum Ho Thoh… Raahein Bhi Hai,

Dm G
Thum Nahi… Thoh Raste Kaha…

C C
Thum Ho Thoh… Yahaan Sab Hi Hai,

Dm G
Thum Nahi.. Thoh Kaun Yahaa…
Bb Am
Thum Ho Thoh Hai,

Bm Em
Har Ek Pal Meherban
F C
Ye Jahaaa…

G E7
Jo Thum Ho Thoh, Hawa Mein Bhi…

Am F
Mohabbato… Ka Rang Hai

G E7
Jo Thum Na Ho, Thoh Phir Koyi…

Am F
Na Josh Na… Umang Hai…
G G
Thum Mile Thoh Mili

C Am F C
Yeh Jindagiiii iiiii iiii…
Gm A# C
Ooh ho… Ooh ho… Ooh ho Oh… ho ho…

Thursday, October 9, 2008

New York - Kaadhal Konjam

Introduction:

"New York Nagaram" from "Jillunu Oru Kaadhal" and "Kaadhal Konjam" from "Patchai Killi Muthuch Charam". Both songs I love a lot. Both are guitar based melodies. But both have a different flavor and style. "New York" is a bit on melancholy side while "Kaadhal Konjam" sounds like refreshing. "New York" has female chorus parts which makes us fell like the lady is also in search of the man's love, while "Kaadhal Konjam" has a bright drums and male humming which gives us a mood to start with a new love.

Chords:

The Chords of both the songs are not same and but same in progression. It is repeatedly four chords throughout the song with no exception.
Am - 002210 --- A#m - 113321
F - 133211 --- F# - 244322
C - 032010 --- C# - 446664
G - 320003 --- G# - 466544
But be very careful. Hear the songs repeatedly and catch the rhythm. Both songs involve in fast rhythm which needs practice. One more thing "Kaadhal Konjam" has pitch change at the end. It goes up by one full step. That means you have to play Cm, G#, D#, F#. Sounds hell? It is fully barre chords and will give your left hand a lot of exercise.

Thursday, July 26, 2007

Layla - Chords











{Intro}

Dm.......Bb.......C.......Dm.........Bb..........C........A.........C......

{Verse 1}

C#m7.................................G#7..
What'll you do when you get lonely?
C#m7..C.....D.....................E7..
And nobody's waiting by your side
F#......B.................E...........A............
You've been running and hiding much too long
F#........B..............E....................A.......
You know it's just your foolish pride Layla

{CHORUS}[Same as Intro]

You've got me on my knees
Layla
I'm begging darling please
Layla
Darling won't you ease my worried mind

{Same as verse 1}

I tried to give you consolation
When your old man had let you down
Like a fool I fell in love with you
You turned my whole world upside down Layla

CHORUS

{Same as verse 1}

Let's make the best of the situation
Before I finally go insane
Please don't say we'll never find a way
And tell me all my love's in vain

CHORUS 2x

Wednesday, June 27, 2007

Truly Madly Deeply - Chords


Introduction:

This is the first song I played on college stage. A total failiure due to mic problem. But it's one among  my all time favourites. Here are the Chords. Very easy!!!

Song: Truly Madly Deeply
Artist: Savage Garden
Genere: Slow Rock

[intro:]
C G F G
[verse:]
C.....................
I'll be your dream
.........................G.....................
I'll be your wish I'll be your fantasy
F...........................................
I'll be your hope I'll be your love
G.....................................
Be everything that you need
C.......................................G.......
I'll love you more with every breath
.................................
Truly, madly, deeply do
F........................................
I will be strong I will be faithful
G...........................
'cause I'm counting on
Am.................
A new beginning
G......................
A reason for living
F.......................G......
A deeper meaning, yeah

[chorus:]
.............C...........................G...........
I want to stand with you on a mountain
.............F...........................G....
I want to bathe with you in the sea
.............C.................G......
I want to lay like this forever
.............F.....................G....
Until the sky falls down on me

[verse:]
And when the stars are shining
brightly in the velvet sky,
I'll make a wish send it to heaven
Then make you want to cry
The tears of joy for all the
pleasure in the certainty
That we're surrounded by the
comfort and protection of
The highest powers
In lonely hours
The tears devour you

[chorus]
Am..........................
Oh can you see it baby?
C..........................................
You don't have to close your eyes
.................................................
'Cause it's standing right before you
Am...................................C....
All that you need will surely come

[verse:]
I'll be your dream I'll be your wish
I'll be your fantasy
I'll be your hope I'll be your love
Be everything that you need
I'll love you more with every breath
Truly, madly, deeply do

[chorus:]
I want to stand with you on a mountain
I want to bathe with you in the sea
I want to live like this forever
Until the sky falls down on me

Copyright:
```````````
The lyrics provided are only for private use. Please support the artists by buying their music.