Thursday, May 7, 2009

Dude, I won an SSLMatic SSL certificate!

It is very funny at-times how events unfold. Awhile back I stumbled on David Walsh's blog and I was immediately won over by the wealth of content and information available on his blog, so I subscribed to his feed via my Google reader. Last weekend, I saw his tweet via my desktop client (DestroyTwitter) that he has some free SSL certificates to giveaway and all I had to do to partake of the giveaway was to post my favorite actor/actress’ name with “FTW” after it. For example:
  • Christina Ricci FTW!
I went ahead to his blog and posted Jason Statham; who's one of my favourites because of a few of his movies that I've watched (Death Race - I'm a very gentle guy but I somehow liked the violence in this movie, probably because it made me feel as if I was playing the games I've missed in times past - , Transporter 1, 2; not yet watched 3, Crank - though a stupid movie). I rarely put in for such things because I don't believe much in them, but somehow that day I was lead to just put in my own submission and I was very surprised when I saw my name in the list of winners. Even while opening the mail pertaining to the list of winners, I just wanted to see what actors/actresses made winners of them, and there I was. Here's the comment David made about my pick:

(Jason Stathom) - The movie Snatch is unbelievable but ever since this guy’s been putting out crap. He went from a manly man to rubbish.


So Jason Statham, though as people rightly said that the movies you do these days are crappy, you made a winner outta me anyway. Thanks to David Walsh and SSLMatic.

Tuesday, April 28, 2009

The time has come...

“You may fool all the people some of the time, you can even fool some of the people all of the time, but you cannot fool all of the people all the time.” - Abraham Lincoln

Some of our leaders in power have been fooling us for years now by doctoring political elections and forcing their mandate on us such that we've lost confidence in elections in this country but I'm happy to announce that the tides are turning around for us in this country. Not everybody can be so easily bought, which was the case with Mrs. Ayoka Adebayo, the Resident Electoral Commissioner (REC) of INEC in Ekiti state, who resigned yesterday as a result of her not being comfortable with the way some elements who call themselves our leaders tried to manipulate the Ekiti elections as used to be the case with elections in this country. A copy of her resignation letter can be seen below:

The time has come when all of us who have been praying for Nigeria and who desire a change to stand up and say no to all forms of rigging and foiling of due processes in this country. Let us all be like Mrs.Adebayo and put the fear of God before us as we carry out our daily activities. If we can all imbibe this quality that has been found in Mrs.Adebayo, we'd attain Vision 2020 earlier in time. Mrs.Adebayo, heaven is proud of you with this action you've taken.


You can read more about what has been happening as regards Mrs.Adebayo case in the following links:

Mrs. Ayoka Adebayo's Resignation Letter

FG declares Ekiti State REC, Mrs. Ayoka Adebayo, Wanted!

As Ekiti State hurtles towards “June 12", FG Moves against INEC Commissioner, Mrs. Adebayo; But She Says "I am Not Hiding"

Saturday, April 11, 2009

Avoid that next coding migraine!

I discovered that reading some data into an array and dumping the whole array to disk, creates a corrupt file because null indices in the array are written to disk with each invocation of the I/O's write method that receives only the array as the argument. What I mean is this; assuming you have the following code:
URL zURL = new URL("http://www.some_server.com/some_zip_file.zip");
InputStream bstream = zURL.openStream();
ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();


byte[] buf = new byte[4*1024];

int readByte = 0;
while (((readByte = bstream.read(buf)) != -1)) {
outBuffer.write(buf, 0, readByte);
curSize += readByte;

try {
Thread.sleep(20);
} catch (InterruptedException ex) {
Logger.getLogger(Extractor.class.getName()).log(Level.SEVERE, null, ex);
}
}

FileOutputStream outStr = new FileOutputStream(new File("C:/sample1.zip"));

outStr.write(outBuffer.toByteArray());


The file written to disk in the code above is corrupted even if the actual one downloaded was not, because of this line of the code:
outBuffer.write(buf);
which should have been:
outBuffer.write(buf, 0, readByte);
So please whenever you read into arrays like that, dump only the valid bytes to disk and not the whole array. This could be any oversight that will cause you headache or migraine. So please avoid that next migraine.

Wednesday, March 4, 2009

JQuery Selector Headache

Wasted some valuable time 4 days ago, very early in the morning trying to figure out what has gone wrong with JQuery-1.3.2 and even when I tried reverting to version 1.3.1, the problem still persisted and it left me wondering if there was a bug in the 1.3 releases.

To select an element with an attribute equal to a particular value, you'd write an attribute selector like the one below:

$item = $('div[@class=scrollable]");

which would select all elements matched by DIV tag that have a class value exactly equal to scrollable. I have used that feature a million times (just joking, but I've really used it so many times) and it had always worked only to fail me today. I consulted Jonathan Chaffer and Karl Swedberg's JQuery Reference Guide to cross-check if what I was doing was wrong or something; but it validated my code and I resorted to using an alternative, which was to give that element in question an ID and select it with JQuery using that ID. Of course, this would only work for cases where you can easily assign an ID to the element in question. If there are several occurrences of such an element in the document, giving each one an ID might not work for you, though you can resort to using a consistent naming scene for the IDs.

It was only after I got the script to work after selecting the element via its ID did I remember that I saved a copy of JQuery's 1.3 release features on my hard-drive. So I perused the document and discovered that such a feature as the one I used has been changed making the new 1.3 releases backwards incompatible with such selector expressions. I just felt like posting this per-adventure someone finds [her]himself in the same fix. I have always thought that I can just point my script to use the latest release of JQuery without breaking things but I have learnt my lesson that this is not always so. I also rarely take my time to read the releases features posted about the libraries I use, but now I know that it's not a good idea to be doing that. So the change in 1.3 releases as regards the attribute selector expression I used earlier is to remove the @ to upgrade. So we now have something like this:

$item = $('div[class=scrolable]"); - v1.3 upwards

Some other notable features that could break your old scripts are:
  • Triggered events now bubble up the DOM. Unsuspecting event handlers may accidentally capture more events than they're expecting.
  • The ready() method no longer tries to make any guarantees about waiting for all stylesheets to be loaded. Instead all CSS files should be included before the scripts on the page.
  • .isFunction is simpler now, it no longer handles some strange edge cases (in favor of simplicity and performance).
  • The order of "a, b, c" style selectors may change. Browsers that support querySelectorAll (Safari, Firefox 3.1+, Opera 10+, IE 8+) will return the elements in document order, other browsers will (currently) return them in the order specified. In an upcoming 1.3.x release all comma-separated selectors will be returned in document order.
  • The trigger and triggerHandler methods no longer accept event objects within the data array. Instead they should be specified directly as an argument.
  • The undocumented 'extra' function is gone from trigger and triggerHandler functions as well.
  • The internal jQuery.event.trigger no longer returns the last item returned by a handler, instead it return true or false as per the W3C specification. You should use a jQuery.Event object to capture the specific return value.
  • You should always be sure to run your page in standards mode. There are known issues with methods not working correctly in quirks mode (including errors in the selector engine in Safari).

The following properties have been deprecated (in favor of feature detection and jQuery.support, as discussed in the Overview).

  • jQuery.browser
  • jQuery.browser.version
  • jQuery.boxModel

The following browsers are no longer supported:
  • Safari 2

Thursday, February 12, 2009

JavaFX Mobile, not an option in our present day world.

Happy new year to you dear readers. Since the release of the JavaFX SDK v1 in December, I've been on the look-out for any good news from fellow developers out there that have started taking the red pill of JavaFX, but there hasn't been too much activity in that space. Besides the work of James Weaver and Chris Oliver, I've seen very little impressive JavaFX apps out there. Even Joshy (Joshua Marinacci) that used to dazzle me back then with the Filthy Rich Clients he used to come up with back then with Romain Guy has done very little to impress me with JavaFX since he joined the team.

I have long been reading up a lot of materials (books, blogs, tips, tricks and all) on Flex since around last year, but I just recently had my first shot with a real project and I wasn't disappointed at all. Pimping up an application can be done in a matter of minutes without having to write any code.

Getting back to the point of writing this post, one of my resolutions for the year is to get back to mobile and build some serious apps on that platform and I'm doing so with a variety of mobile technologies ranging from JavaME, Flashlite, Python, Android and WRT. In my working with JavaME, I'm looking forward to create a very compelling UIs on these devices so I thought of two options:
  • One is to go low-level and develop my own custom components, which would take a lot of my time, or
  • Use LWUIT

I thought of using LWUIT because of the experience I had with Majimob player, which currently boasts of over 1 million downloads. It was highly impressive, though still a little crude in my opinion and at-times slows down on my device. But overall, it's okay. I've also been looking forward to the next release of JavaFX SDK which will come with full support for JavaFX Nobile, but I was disappointed to learn that JavaFX Mobile is based on MSA which is currently available on very limited devices and that JavaFX Mobile is for people looking forward to develop for the future mobile devices which I want to state is not acceptable. So what Sun is simply telling us is that we can't develop for the over 2 billion devices out there with JavaFX Mobile? So why do we have to look forward to a platform that is kinda doomed at the moment?