February 27, 2010

Thought of the day...

Being fearless isn't being 100% not fearful, it's being terrified but you jump anyway.

In similar words "Throw yourself to the wolves and learn from the bites.. ;-)"

February 21, 2010

Patch for extjs ItemSelector

At work, extjs was the first javascript library we used. It provides very nice UI and probably has the best documentation and forum support available among other similar libraries. We modified its code to provide legend support which is nothing but title in the custom ItemSelector ui element. Below is the patch(not a big deal but i didn't want to loose this change so thought to post here).

### Eclipse Workspace Patch 1.0
Index: webcontent/ext-3.0.0/examples/ux/ItemSelector.js
===================================================================
--- webcontent/ext-3.0.0/examples/ux/ItemSelector.js (revision 230)
+++ webcontent/ext-3.0.0/examples/ux/ItemSelector.js (working copy)
@@ -41,6 +41,8 @@
     delimiter:',',
     bodyStyle:null,
     border:false,
+    legendFrom: 'Available',
+    legentTo: 'Selected',
     defaultAutoCreate:{tag: "div"},
     /**
      * @cfg {Array} multiselects An array of {@link Ext.ux.form.MultiSelect} config objects, with at least all required parameters (e.g., store)
@@ -60,17 +62,17 @@
 
         // Internal default configuration for both multiselects
         var msConfig = [{
-            legend: 'Available',
+            legend: (this.legendFrom || 'Available'),
             draggable: true,
             droppable: true,
-            width: 100,
-            height: 100
+            autoWidth: true,
+            autoHeight: true
         },{
-            legend: 'Selected',
+            legend: (this.legendTo || 'Selected'),
             droppable: true,
             draggable: true,
-            width: 100,
-            height: 100
+            autoWidth: true,
+            autoHeight: true
         }];
 
         this.fromMultiselect = new Ext.ux.form.MultiSelect(Ext.applyIf(this.multiselects[0], msConfig[0]));

And the result looks something like below

February 17, 2010

Thought of the day...

मुआ क्या कब्रिस्ताना माहौल है
सब ने खुद को किसी गम-ए-कब्र में दफना रखा है?

January 26, 2010

Transparent iframes

Firefox by default makes all iframes transparent (no effort required from the developer) if you don't define the background css property.

IE requires extra effort to ensure that the hosting page as well as the iframe's content owner both wanted this iframe to be transparent (few may agree with IE's approach while most will condemn M$). Whatever, here is the css (for page loaded in the iframe) and iframe tag declaration that works flawlessly:

body{
    background: transparent;
}



January 11, 2010

Bypassing browser history

Ahh, this was interesting thing@work. We've an iframe that opens within a website and its location keeps changing with user interactions. The problem was with all these new urls going into browser's history and interference with the default browser back/forward navigation (back/forward navigation gets enabled for the iframe instead).

Initially i thought it wasn't possible to control this (history object doesn't support it, i knew). But then came this simple thing i used in my first year while experimenting in one of my first few projects.

location.replace(newurl);

Ahh, what a savior. Works well in all the browsers. Here are the details from mozilla on this.

January 03, 2010

intercepting javascript errors from live system

Ever wondered how to intercept javascript errors (that happen on client side browsers) for your live system? Yep, i know! Despite all the efforts, a visitor might encounter an issue in his "foobar" browser that you just couldn't test before you went live. So how to do it? This little guy is the savior:
window.onerror = function(errorMessage, url, line) {
}

I just stumbled upon this blogpost by xing developer Christopher; who summarizes how they do it in xing. Pretty interesting and clever stuff, here is the code:
window.onerror = function(errorMessage, url, line) {
  var loggerUrl = "https://www.xing.com/js/logger";
  var parameters = "?description=" + escape(errorMessage)
      + "&url=" + escape(url)
      + "&line=" + escape(line)
      + "&parent_url=" + escape(document.location.href)
      + "&user_agent=" + escape(navigator.userAgent);
 
  /** Send error to server */
  new Image().src = loggerUrl + parameters;
};

For details read the original post here.

December 27, 2009

Interesting 45 things to ponder about...

Written By Regina Brett, 90 years old, of The Plain Dealer, Cleveland,
Ohio - "To celebrate growing older, I once wrote the 45 lessons life taught
me. It is the most-requested column I've ever written."

1. Life isn't fair, but it's still good.

2. When in doubt, just take the next small step.

3. Life is too short to waste time hating anyone.

4. Your job won't take care of you when you are sick. Your friends and
parents will. Stay in touch.

5. Pay off your credit cards every month.

6. You don't have to win every argument. Agree to disagree.

7. Cry with someone. It's more healing than crying alone.

8. It's OK to get angry with God. He can take it..

9. Save for retirement starting with your first paycheck.

10. When it comes to chocolate, resistance is futile.

11. Make peace with your past so it won't screw up the present.

12. It's OK to let your children see you cry.

13. Don't compare your life to others. You have no idea what their
journey is all about.

14. If a relationship has to be a secret, you shouldn't be in it.

15. Everything can change in the blink of an eye. But don't worry; God
never blinks.

16. Take a deep breath. It calms the mind.

17. Get rid of anything that isn't useful, beautiful or joyful.

18. Whatever doesn't kill you, really does make you stronger.

19. It's never too late to have a happy childhood. But the second one
is up to you and no one else.

20. When it comes to going after what you love in life, don't take no
for an answer.

21. Burn the candles,.
Don't save it for a special occasion. Today is special.

22. Over prepare, then go with the flow.

23. Be eccentric now. Don't wait for old age to wear purple.

24. The most important organ is the brain.

25. No one is in charge of your happiness but you.

26. Frame every so-called disaster with these words 'In five years,
will this matter?

27. Always choose life.

28. Forgive everyone, everything.

29. What other people think of you is none of your business.

30. Time heals almost everything. Give time, time.

31. However good or bad a situation is, it will change.

32. Don't take yourself so seriously. No one else does.

33. Believe in miracles.

34. God loves you because of who God is, not because of anything you
did or didn't do.

35. Don't audit life. Show up and make the most of it now.

36. Growing old beats the alternative - dying young.

37. Your children get only one childhood.

38. All that truly matters in the end is that you loved.

39..Get outside every day. Miracles are waiting everywhere
40. If we all threw our problems in a pile and saw everyone else's,
we'd grab ours back.

41. Envy is a waste of time. You already have all you need.

42. The best is yet to come. – (Always! ;-))

43. No matter how you feel, get up, dress up and show up.

44. Yield.

45. Life isn't tied with a bow, but it's still a gift.

PS: you might also like the following
  • http://matkahtml.blogspot.com/2008/11/sunscreen-by-baz-luhrman.html
  • http://matkahtml.blogspot.com/2007/12/golden-rules-for-career-success-by.html