Friday, November 9, 2012

How to repeat tracks in SoundCloud.com

Ever since A.R.Rahman performed his new composition for the movie Kadal (a Tamizh movie directed by Maniratnam sir) for the song titled "Nenjukulle" on MTV Unplugged, people, I am sure, have been playing it in loop. For those who want to play the sound track repeatedly in youtube, we have youtube repeater service that is freely available. Details can be found here About Youtube Repeater

But, for those who prefer to use Soundcloud, there was no option to play a sound-track in loop. That is when the idea to create a bookmarklet to get the job done, dawned on me. Also, thanks to my friend Krishnan (a budding musician and a heavy user of SoundCloud) that I felt the need for this repeater functionality. 

Using the luxury of the search engines these days and Github, I could figure out that the problem was already solved. Just that I didnt find that the solution was neatly packaged so that people could use it, easily. I am doing the packaging of the solution here.

Credits:
Bookmarklet sourced from here

Drag and drop the link below to the bookmarks bar, so that the bookmarklet is installed in your browser. 




Youtube Repeater

All the music lovers out there, I am sure many of you would have the habit of listening to a song repeatedly for hours. It is annoying in a way, when you have to keep going back to the youtube tab to play the song again, each and every time the song is over.

I found an elegant solution online for the same. What makes the solution elegant is the ease with which any user can get benefitted from this solution available online. Well thought out, I must say.

How to play songs in loop on Youtube :

1. Let's say the song you are listening to is http://www.youtube.com/ABC
2. Add repeater in between "youtube" and ".com" and you are all set.(and everything else remains the same)
     Eg: http://www.youtuberepeater.com/ABC

Get addicted to the favorite tracks of yours.

Addiction is good!

Update:
I want to point out that if you are streaming youtube via https, merely adding repeater in the URL is not enough. You will have to change the URL so that you use http instead of https as well.

Wednesday, October 31, 2012

Content!!?


Content
 
Long road, pitch black night, walking alone, vulnerable
Not even shadow for company, forlorn
The winding road, every corner raising hopes of reaching the end
The so called fate making you walk to its tune
 
The Euphoria of taking the less-travelled road, long gone
Uncertainty in the mind leading to doubts about the path taken
Only the will and self-belief to guard against giving up
All the profound lessons in life helping you keep calm
 
Fear seeps through the mind, with every passing second
A real test of will, want and desire
With the last surge of energy to see it to culmination
The end comes, slowly, snail pace or so you feel
 
Content that the destination is reached
Feeling the worth of the struggle and pain
All the pieces of the jigsaw in place
We fly away happily having lived a life devoid of crassitude

GT

Saturday, October 13, 2012

LCA - My attempt in deconstructing the recursive solution

Have given enough comments to explain the solution step by step.

/*LCA in a binary tree

Karumanchi Solution : Recursion (Found in http://www.flipkart.com/data-structures-algorithms-made-easy-java-1466304162/p/itmd34fz5jzb599u
Data Structures and Algorithms Made easy in Java
)

*/

//a, b -> parameters - nodes for which LCA is to be found out, they should remain unchanged throughout
BTNode LCA (BTNode root, BTNode a, BTNode b) {
BTNode left, right;

/*
Base Condition 1: if the root pointer is null - do nothing - return null
*/
if ( root == null ) return null;

/*
Base Condition 2: root pointer in this program is searching for a or b;
  so once we reach a or b, no more search is required.
*/
if ( root == a || root == b ) {
//Pointer comparison is enough here
return root;
}

/*
traverse left and right subtrees
*/

left  = LCA(root.getLeftChild(), a, b);
right = LCA(root.getRightChild(), a , b);

/*
Condition 1:

When nodes a and b are on either side (left and right) of a node,
we know that we have arrived at the LCA
*/
if ( !left && !right ) {
return root;
}

/*
Condition 2:

Condition that is required when both a and b are in the same subtree

        eg: 1
        2
        3

Here let a = 2 and b = 3; LCA of a and b in this case will be 1. 2 and 3 are in the same subtree

*/
return ( left ? left : right);

}

OAuth vs OpenId

Last week when I was in my home-town, I was having a conversation with my brother about OAuth and OpenId. When he asked me the difference between the 2 and asked me to give one line for each protocol I was not able to do so. That is when I realized that I was not clear about both the protocols myself.

As usual, went to the drawing board to figure out what each protocol is for.

Found the following presentation extremely helpful :
http://www.slideshare.net/rmetzler/identity-on-the-web-openid-vs-oauth

Summarizing the content here :

OpenId - is meant for identifying the user in the web-world. Only for identification. (as the name says)

OAuth - is required when a 3rd party is looking to access a user's data present in another server.
               Data access.

OpenId - Identification
OAuth  - Data access

Period.

Sunday, July 15, 2012

My Girl

The warmth, the smell, the touch
The kiss, The cuddle and the talk
She makes me feel alive
She makes me feel good

The courage, the confidence, the smile
The conduct, the style and the face
She helps me clear my head
She helps me feel confident

The smart, the sweet, the cute
The hot, The bad and the sexy
She makes me feel my manhood
She makes me what I am

The sad, the hate, the worries
The cry, The weak and the sob
She helps me understand the world
She helps me know my limits

The pain, the remorse, the mistakes
The regret, the past and the failures
She makes me forgive everything
She makes me learn from it

The dark, the fear, the unknown
The ghosts, the demons and the devils
She helps me stay alert
She helps me be inquisitive

The lessons, the experience, the feelings
The care, the affection and the love
She has given me everything
That I will live my life with her, for her, only her

Tuesday, July 3, 2012

perl - Identifying who is loading a module

So far I was under the impression that it is difficult to identify who is loading a module since all the use statements are executed even before the debugger prompt appears on the terminal.
Ref: http://perldoc.perl.org/perlmod.html#BEGIN%2c-UNITCHECK%2c-CHECK%2c-INIT-and-END

One can setup a break point when a module is loaded by another module.
b load GT/A.pm # this will set a breakpoint on module load of A.pm

But since use statements are evaluated much before the debug prompt appears on the terminal, we will not be able to identify who has actually loaded the module.

However, we can identify the same via a workaround as follows:

1. Start the debugger
2. set a breakpoint on load of a module (eg: b load GT/A.pm)
3. R # This will restart the debugger session - however, the debug point will be retained
4. T # see the stack trace to identify who is trying to load the module


I will upload the script and module used to experiment this, shortly. Meanwhile, one can take a look at the demonstration of this hack below.


ganesathandavamponnuraj@GT-MBP.local:DebugModuleLoad:>>perl -d useAB.pl

Loading DB routines from perl5db.pl version 1.3
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

A BEGIN
A static
A method print
B BEGIN
B static
B method print
Inside BEGIN block
main::(useAB.pl:8): print "Before function call\n";
  DB<1> b load GT/A.pm
Will stop on load of `GT/A.pm'.
  DB<2> R
Warning: some settings and command-line options may be lost!

Loading DB routines from perl5db.pl version 1.3
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

A BEGIN
'GT/A.pm' loaded...
GT::A::CODE(0x825600)(GT/A.pm:8): print "A static\n";
  DB<2> T
$ = require 'GT/A.pm' called from file `useAB.pl' line 1
$ = main::BEGIN() called from file `GT/A.pm' line 0
$ = eval {...} called from file `GT/A.pm' line 0
  DB<2>

Thursday, March 22, 2012

Mac Address Book and gmail LDAP sync

Given that majority of the people on this planet, who have a web-mail account, have a gmail-id, it's natural that almost all of our contacts are residing on gmail's address book. But there are obvious advantages associated with using a desktop client for tracking your mails. (http://familyemailhosting.com/advantages-of-using-an-email-client.php)
But it becomes a pain when your Address book on the Mac OS X(Snow Leopard) doesnt contain all the addresses you have on the gmail address book.
( To the contrary, I found this article on the web that hotmail and yahoo mail have a larger user-base when compared to gmail - Incredible!, I say http://www.cbsnews.com/8301-501465_162-20022793-501465.html )
Inorder to access the gmail address book en masse on your Apple Mail client, do the following.
http://www.techrepublic.com/blog/mac/syncing-macs-address-book-and-ical-with-google-apps/266
1. Open Address Book App; Accounts tab - Enable Google Sync
2. Then force sync, for the first time alone by choosing the sync icon from the Finder Bar.
Now you should be able to see the contacts in your gmail address book, from your Apple Mail client!!!

PS: mrplow pointed out that this doesnt work on OS X Lion, and so I have edited the post accordingly. Thanks mrplow for pointing that out. (I havent tried it myself, I am trusting mrplow to be a Lion user, here :) )

Edit 2:
[Update] Kara Moss pointed out (in the comments section) that the solution mentioned here works on OS X Mountain Lion too. \m/. Looks like it doesnt work only on OS X Lion, AFAIK. It works like a charm on both OS X Snow Leopard and OS X Mountain Lion.

GT