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 {
} catch (InterruptedException ex) {
Logger.getLogger(Extractor.class.getName()).log(Level.SEVERE, null, ex);

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


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:
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.