Thursday, August 22, 2013

The Treasures of Europe

We're just back from a very memorable tour of Europe, and I could write a thousand things about it. But for now I will let the pictures do the talking.

Visiting the musical and intricate clockwork of the Black Forest Cuckoo clock factory



Taking a boat ride through the thunderous cascade and spray of the Rhine Falls 



Sitting on the shores of the serene Lucerne lake with the picture perfect alpine backdrop.



Spending a relaxing evening in Engleberg, nestled high up in the angelic peaks.



The vertiginous climb to the top of Mount Titlis, the panoramic views the breathtaking heights! And then the throwing, dodging, falling and generally having fun in the snow.




Taking a  gondola ride through the narrow canals, walking over a never ending series of bridges and falling in love with the most romantic of cities, Venice!



Traveling back in time to the gladiatorial arena, walking down the imperial way at the centre of the ancient Roman empire, and  visiting the humbling and awe inspiring Basilica.






Being enchanted by the architecture, the culture and the home of Michaelangelo, the city of Florence.



Amazed at the miraculous piazza with the ever leaning tower of Pisa



The Jet d'Eau at the "Peace Capital" of the world, the city of Geneva.



From the panoramic views upon the Eiffel Tower, 
to the cruise along the river. 
The Sights viewed from the Seine, 
while enjoying the light rain. 
Along the resplendent Champ d'Elysees, 
to the magnificent Arc de Triumphe. 
Being swept of your feet by the city of love, the city of lights, Paris!






And not to forget the iconic national monument of Belgium




Tuesday, May 14, 2013

Professional Guidelines for a Geek


Every field has its own skillset requirements and people with those specific strengths are drawn to it. The general principles that enable you to succeed in life are the same across most fields, but depending on which field you are in, they apply in different ways.
I’ve spent all of my working career in various IT roles, and my knowledge of life outside of IT is all second hand. So if this post appears to be out of touch with the world outside IT, then don’t be too surprised.
Lets start with the TL;DR version first:
  1. Be Prepared – Pre-fetching isn’t just for processors
  2. Be Proactive – And the same goes with branch prediction
  3. Be Decisive - Don’t stall cause you see 100s of possibilities
  4. Be Attentive - Remember, input is just as important as output
  5. Be Straightforward (but not blunt) - Politics should be “Read Only”
  6. Work Hard, but leave on time – The longer you run, the less efficient you are
Stay tuned for posts on each of those points..

Wednesday, February 13, 2013

Programmatic Logout mechanism for Google APIs


While recently working on a project requiring integration with youtube, I had a requirement where I had to switch the currently logged in google user.

The project was using AuthSub authentication to do a web browser based video upload. The way this worked was:
  1. The user was redirected from my site to google's server for the authsub
  2. He would be presented with a choice to grant or deny access of his account to my site (by google) (If he wasn't yet logged into google, he could do that now)
  3. Then google redirects the user to my site, with the required accesses and the site can upload video's on that user's behalf as long as the session contains the token.
However if the browser already has a different logged in google user, then the only option is to log out and re log in when presented with the "allow access" page. This broke the redirection flow and the user would not automatically come back to the site.

The solution to this problem was simple, just log the user out of google services before redirection. Right? Well google had other ideas.

After some searching I found out that there was no documented (by google) way of signing out a user from google. However there were a few sites that mentioned a few approaches.
  1. Open the link: https://mail.google.com/mail/u/0/?logout&hl=en and the user will be logged out of that browser.
  2. www.google.com/Accounts/Logout [?service=mail|youtube|etc &continue=url (url should be inside the google domain)] Optional to pass the parts mentioned in the brackets.

And another one that i found was that you could post "action_logout" with value "1" to www.youtube.com to log out the currently logged in user.

Either of these options required opening the url in a browser window (and possibly posting a parameter). So one way of doing this was opening it in a hidden iframe.

I tried that on firefox as:

<form style="display: inline;" 
      target="hiddenFrame" 
      action="http://www.youtube.com/
      method="post" id="autoLogout">
    
     <input type="hidden" 
            name="action_logout" 
            value="1" />
</form>

<iframe name="hiddenFrame" 
        src="" 
        height="1" 
        width="1" 
        frameborder="0">
</iframe>

<script type="text/javascript">
    dojo.addOnLoad(function (){
        dojo.byId("autoLogout").submit();
    });
</script>

And voila, this worked in Firefox 7 perfectly. However, a quick inspection of the scroll bar for this post, will tell you that this isn't the end of it.

If you try this out in internet explorer 8, you will find that it instead tells you that the url cannot be displayed in an iframe due to security concerns (Specifically: "This content cannot be displayed in a frame"). This is to prevent occurrences of cross site scripting and click-jacking exploits.
http://groups.google.com/group/youtube-api/browse_thread/thread/2d2236731672a098

So instead the only option available was to open this in a new window. So how it goes about was:
(Either on page load or when the user clicks logout)
1. Open a popup window with a name
2. Post auto submit the form to that window
3. Wait for a second or 2, and then close the window just opened.

If you do this in an event handler it should be smooth, but if you do it on any other event (like onload for example), then the popup blocker will block it and the user will have to explicitly grant it permission to proceed.

<!-- The form: Note the target is set to 
     _hiddenFrame, the same as the window 
     that we will be opening -->
<form style="display: inline;" 
      target="_hiddenFrame" 
      action="http://www.youtube.com/
      method="post" 
      id="autoLogout">

    <input type="hidden" 
           name="action_logout" 
           value="1" />
</form>

<script type="text/javascript">
    // This should ideally be called in a click handler, 
    // since then it definitely wont be blocked by a popup blocker.
    function logoutFromGoogle(){
        var windowHandle 
            = window.open("", "_hiddenFrame", 
                          "left=20,top=20,width=1,height=1,toolbar=0,resizable=0")
        dojo.byId("autoLogout").submit();
        setTimeout(function(){
            windowHandle.close();
        }, 2000);
    }
</script>

So there we are, a programmatic logout mechanism for google!

Monday, August 15, 2011

The Lord's Prayer (Programmer's Version)

Here is a programmer's version of the Lord's Prayer that i came up with.

The Programmer’s Prayer

Our Program, who art in RAM,
"Hello" be thy name.

Thy schedule come, thy commands be done,
In memory as it is on screen.

Give us today our daily output,
And forgive us our erroneous inputs,
As we forgive those who input errors to us.

Lead us not into exception, but deliver us from SegFaults.

For thine is the algorithm, the implementation and the execution,
looping for ever and ever.
System.exit(0)



(Though technically the System.exit(0) will be flagged as unreachable code due to the infinite loop above)

I got the idea from a post in tdwtf . (Which i then rewrote)
Thanks to Carl, and Candice for their edits as well.

Sunday, May 11, 2008

My Newest Fan!

Thats right folks, i just got myself another fan. Or more correctly... my cabinet "got a new fan". After all, it also needed some respite from the sweltering Mumbai heat. And the reason why i am writing about it, is because i didn't just buy it of the shelf, but instead cobbled it together from old parts.


Here are some snaps of it...







In case you are interested, here is how I managed it:

Parts I used:
1. A fan from an old SMPS
2. A female molex connector
3. Some insulation tape and a scissor

I salvaged the fan from
an old SMPS box that i had lying around the place, this 2 wires attached to it, but did not have any way to connect it to a power supply. So i went to a hardware store and brought a female molex connector. (These weren't available by themselves, so i had to settle for a male - female molex connector, from which I cut of the male plug)

The fan was a 12 Volt fan (as
are most smps fans), I had to connect it to the 12Volt rail from the connector. However the fan had a red and a black wire, but the 12 volt connector on a molex is yellow, so that is something to watch out for. (If you make a mistake, and connect the red wire from the fan to the red wire on the mole connector, then the fan will still work, however will run very slowly, since the red wire from the molex connector only supplies 5 volts.)


Here is how it should look:


Then i plugged in the connector into the power supply and screwed the fan to the back of the cabinet, such that it would blow the air outwards.
(Note: Before actually fixing the fan to the cabinet, i would suggest that you test it to ensure your connections are fine, otherwise it will be a lot of extra effort in removing the screws and re-doing the connections.)

And there, i now measured the temperatures via the monitor built into my cabinet, and it had dropped from 41 degrees on idling before, to 38 degrees now. The temperature of the CPU, GPU, HDD changed from


Also, when deciding the direction of the air flow within the cabinet, make note of the existing situation.
If you have too much air blowing in, then the new fan should ideally blow outwards, and vice versa.
Sometimes you might want to tinker with your existing fans to direct airflow towards critical components, etc.

You can find a lot more info about airflow related issues here...
http://www.technibble.com/case-cooling-the-physics-of-good-airflow/
http://www.endpcnoise.com/cgi-bin/e/computercooling.html?id=Jm7C4TYQ

Monday, September 25, 2006

An astrologer’s nightmare...


As we say goodbye to Pluto after so many years of faithful service, we ought to stop at look at all its ramifications.

Sure it invalidates all those school text books... (And forces an edit, though this time for non political reasons), it would also cause some disagreement among astronomers, but if you look further think about its effect on all these astrologers.

These people have been going about all along telling people how the position, inclination, gravitational pull and god knows what not else of these planets affect our future and current sense of well being (and not to mention the amount of money that goes into their pockets). And now all of a sudden they learn of this development. So what do you suppose they would do?

Firstly, they could argue that it doesn’t matter whether we call it a planet or not... it still exists and thus can affect our lives just like before, well in that case what about those other new dwarf planets that were discovered? Weren’t they also existing and affecting our lives all along? Or is it upto the astrologers to decide which heavenly bodies can and cannot affect our lives.

Secondly, if any heavenly body can affect our life... then what about those thousands or millions of bodies in the asteroid and Kupier belts orbiting our solar system. Some of them are even bigger than Pluto. How can call their predictions accurate if they don’t account for so many of these?

Of course I know that these 2 points that I brought up are based on reason... not something your average astrologer would fathom. But then again this is not really written to enlighten an astrologer, but rather to the common man spending his money and wasting aspirations on something some soothsayer said would happen in the future.

(On a different note: who would imagine that in my first post it self I would be saying something concerning "everyday life, "the universe" and "something I came across" all in the same post. :D )

See ya around