Tim's Blog

Page 2 of 7

FABridge.js play nice with Chrome

Today at work I got an email that said, “The site text editor is broken in Google Chrome. Remember about 3 years ago when you thought FABridge.js was a good idea?” In hindsight I would not have used FABridge. I think the levels of indirection out weigh the ease of use (especially if you need tons of control). Nonetheless I had to fix it. Once I found the bug it was pretty easy to fix. I narrowed the error down to FABridge__bridgeInitialized in FABridge.js. FABridge__bridgeInitialized looks for either an embed or object tag based on the browser type. A check for Chrome did the trick.

In FABridge.js if you change:
if (/Explorer/.test(navigator.appName) || /Konqueror|Safari|KHTML/.test(navigator.appVersion))
to:
if((!(/Chrome/.test(navigator.appVersion))) && ((/Explorer/.test(navigator.appName) || /Konqueror|Safari|KHTML/.test(navigator.appVersion))))

you should be in good shape.

So if you hear FABridge.js does not work in Chrome. Or your JavaScript wrapper to the Flash widget is broken this may solve your challenge.

THERE IS A BETTER WAY TO DO THIS. HERE IT GOES
/**This function searches for the flash dom object that has the flex movie in it.
*In some browsers this is an object tag. In other browsers this is an embed tag.
*We know we have the right thing when we find a dom object with the function getRoot.
**/
function FABridge__bridgeInitialized(bridgeName)
{
var searchStr = “bridgeName=”+ bridgeName;
var flashInstanceWithBridge = null;

var flashInstances = document.getElementsByTagName(“object”);

//search object tag
if (flashInstances.length == 1)
{
flashInstanceWithBridge = flashInstances[0];
}
else
{
for(var i = 0; i < flashInstances.length; i++) { var inst = flashInstances[i]; var params = inst.childNodes; var flash_found = false; for (var j = 0; j < params.length; j++) { var param = params[j]; if (param.nodeType == 1 && param.tagName.toLowerCase() == "param") { if (param["name"].toLowerCase() == "flashvars" && param["value"].indexOf(searchStr) >= 0)
{
flashInstanceWithBridge = inst;
flash_found = true;
break;
}
}
}

if (flash_found) {
break;
}
}
}

if(!flashInstanceWithBridge|| !flashInstanceWithBridge[“getRoot”] || !(typeof(flashInstanceWithBridge.getRoot) == “function”) ) //search embed tag if the object tag does not have the needed methods
{
flashInstanceWithBridge = null;

flashInstances = document.getElementsByTagName(“embed”);
if (flashInstances.length == 1)
{
flashInstanceWithBridge = flashInstances[0];
}
else
{
for(var i = 0; i < flashInstances.length; i++) { var inst = flashInstances[i]; var flashVars = inst.attributes.getNamedItem("flashVars").nodeValue; if (flashVars.indexOf(searchStr) >= 0)
{
flashInstanceWithBridge = inst;
}

}
}
}

if(flashInstanceWithBridge)
{
FABridge.attachBridge(flashInstanceWithBridge, bridgeName);
}

return true;
}

I can’t wait to watch this.

Here is a clip about the spiderman show that is going to open on Broadway. I have to go see this.

It’s your job to know

Imagine the time that went in to planing and producing this shot.¬† So serious…

I placed in Kumite and Kata!

Okay so it was a few years ago ūüôā One of my father’s old karate students uploaded these old images to facebook. I snagged them and put them here. Looks like I won in Kumite and Kata. Rad!

red dragons

article

JNI + OSGI + Refactoring + Idiot = 2 wasted days.

I just wasted two days.¬† I am working on a desktop application¬†in JAVA.¬† It needs to sniff web proxy settings from the Window’s registry (and some day other platform specific locations).¬† I decided to use JNI¬†¬†to do this.¬† Everything worked like a charm in my sandbox JAVA application.¬† I then¬†embarked on moving it to and OSGI bundle.¬† When I ran the thing I received a java.lang.UnsatisfiedLinkError.¬† WTF!!¬† WHY!!¬†

When I debugged my call to System.load(“somedll”) worked, but an exception was triggered when I invoked the native method.¬† I then thought well maybe its and OSGI thing.¬†¬†After some¬†Google-ing I found a few write ups on how to tweak the manifest to load the system specific library.¬†¬†I tried effing with the manifes eight ways from¬†Sunday, but still¬†no workie.¬† I then came across a forum where someone¬†had the same issue I did and they eventually discovered that that they had renamed their¬†JAVA class, but did not regenerate the¬†JNI lib.¬†¬†It then dawned on me that I had refactored my JAVA class in to a new package, but did not update the generated .h file.¬†¬†

The¬†morale of the story is if your¬†JNI call works outside of OSGI, but then stops working when you move it in to OSGI; ask yourself “did I refactor this thing when I moved it in to a bundle?”¬†

Happy Turkey Day

                             ,+*^^*+___+++_
                        ,*^^^^              )
                     _+*                     ^**+_
                   +^       _ _++*+_+++_,         )
       _+^^*+_    (     ,+*^ ^          \+_        )
      {       )  (    ,(    ,_+--+--,      ^)      ^\
     { (@)    } f   ,(  ,+-^ __*_*_  ^^\_   ^\       )
    {:;-/    (_+*-+^^^^^+*+*<_ _++_)_    )    )      /
   ( /  (    (        ,___    ^*+_+* )   <    <      \
    U _/     )    *--<  ) ^\-----++__)   )    )       )
     (      )  _(^)^^))  )  )\^^^^^))^*+/    /       /
   (      /  (_))_^)) )  )  ))^^^^^))^^^)__/     +^^
  (     ,/    (^))^))  )  ) ))^^^^^^^))^^)       _)
   *+__+*       (_))^)  ) ) ))^^^^^^))^^^^^)____*^
   \             \_)^)_)) ))^^^^^^^^^^))^^^^)
    (_             ^\__^^^^^^^^^^^^))^^^^^^^)
      ^\___            ^\__^^^^^^))^^^^^^^^)\\
           ^^^^^\uuu/^^\uuu/^^^^\^\^\^\^\^\^\^\
              ___) >____) >___   ^\_\_\_\_\_\_\)
             ^^^//\\_^^//\\_^       ^(\_\_\_\)
               ^^^ ^^ ^^^ ^^

Happy TURKEY Day!
*Image courtesy of http://home.comcast.net/~855ardmore/ascii-thanksgiving.html

Caltrain woes

Like most days I began my morning by riding Caltrain from San Francisco to Palo Alto. ¬†About 10 minutes in I realized that I had forgotten my train pass. ¬†I decided to do the “right thing” and inform the ticket attendant that of the situation. Here’s where it gets interesting. ¬†He advised me that speaking with him was not helping me and that I should run up 2 cars and then hop off at the next stop and purchase a ticket. ¬†I politely replied, “My bike is on the train. ¬†You are giving me a 30 second window to do something that takes at least 2 minutes.”. ¬†I mean even if I teleported to the machine I still have to put the money in the box and wait for the machine to spew out my ticket. ¬†He then told me to get off at the next stop or be written up. ¬†Okay so that’s when I decided to conduct an experiment. ¬†The max fine for not having a ticket is $250. ¬†I sneeze that. ¬†Perhaps he gets off by striking fear in the hearts of most by treating them with a fine, but not me. ¬†I had already decided to get off the train, but not before I tested his humanity. ¬†I put on a sad face (the kind that looks like I’m fighting tears back) and pleaded, “I have a wife and 2 kids at home. ¬†I have been unemployed for 6 months and am on my way to a big interview (monster lie). ¬†I was honest with you about not having a ticket. ¬†Please let me slide this once.”. ¬†He told me to “that’s too bad”. ¬†This whole experience left me with a few questions:

1.  Is this really Caltrain policy?  That is, I turned myself in.  Is their idea of customer service advising me to sprint for the machine?  If I was a 60 year old lady would they advise the same?

2.  How can some people be so not nice?  I mean why would you as a Caltrain attendant threaten to fine someone who willfully acknowledged the situation?

3.  Am I alone or does this happen often?  The Caltrain is used by thousands of hard working people everyday.  Certainly a percentage of which forget their ticket.  Do they get chucked from the train or did I just happen to catch the ticket checker when he was on his period?

« Older posts Newer posts »

Copyright © 2019 Tim’s Blog

Theme by Anders NorenUp ↑