BlogIt Maintenance Release 1.2.2

Maintenance release 1.2.2 of BlogIt many of the day to day bugs found over the past 8 weeks or so since the last release. None of the bugs are critical, but it’s worth upgrading, particularly if you tend to use apostrophes in your titles.

In addition to the help from prior contributor SteP who provided some code fixes, we also saw some additional participation from Peter Kay who as a first time BlogIt user managed to find some pretty interesting bugs, including the apostrophe issue, and a problem where non-BlogIt links in the sidebar were incorrectly rendered with hyphens. Thanks Peter.

Hopefully as BlogIt matures we’ll start to see increasingly broader involvement from the PmWiki community. One day we might even get us a code review.

Enlighten: PmWiki Skin Conversion

Enlighten is my latest contribution to the PmWiki platform. Nothing too special here: a basic 2-column blog layout. But it was easy to produce, and helped me narrow the time it takes to do each part of a skin conversion. Turns out the basic conversion is pretty quick. A few hours. What adds the time is all the extras. Adding fixed/fluid width support; multi-color themes; support for BlogIt. All told, it seems to take around 20 hours to do a skin conversion.

Set IFRAME height based on size of remotely loaded content

Update 13-Mar-2010: After writing this I discovered a bug which occasionally caused the iframe to be sized incorrectly – subsequently a number of others had the same problem. I was unable to determine the cause, but implemented a work-around solution. Redux: Redux: Set IFRAME height based on size of remotely loaded content.

When you load a remote page (a page which is not on your domain) into an IFRAME how do you ensure that the IFRAME expands its height to completely wrap its content, and has no vertical scroll bars (avoids having both the browser scroll bar and an iframe scroll bar), regardless of the content loaded? Well unless you have the willing consent of both domain on which the remote content is stored, you don’t. But, if you can all agree to get along, then it is possible to seamlessly load remote content into your page, with no scrollbars, borders, or other visual queues of content being stored elsewhere.

The technique for cross-domain communication is used by Facebook, iGoogle, and Google Maplets, but there doesn’t seem to be wide recognition of when and how it can be used.

Works across browsers, including Chrome, Firefox, Opera, Safari, and even Internet Explorer 6/7/8.

read more...

Google Wave

Google Wave is being developed under the leadership of the same brother team that developed Google Maps (Lars Rasmussen and Jens Rasmussen), and basically re-envisions the 35+ year old email concept, from todays perspective – really a personal social dashboard. 2 years in development using Google Web Toolkit, Google Wave mashes together and federates a huge number of more recent social and collaborative concepts, from email, IM, file and image sharing, document collaboration, wikis, blogging, and more. Say bye to having to manage 35 different social networks! Wave will consolidate them all into a single interface. Along with every other collaboration and social tool you use. Oh, and it’s also a protocol – more on that later.

And it does this in real-time, within a browser.

When you add content, the content is immediately available to who-ever you’re sharing with, without them having to reload pages. It’s just there – true real-time multi-author document collaboration. And when I say mash, I mean, completely blurs the boundaries between modes of collaboration. An email style Wave can become an IM, and a blog, and a document. Back and forth, whenever you like.

There’s new concepts in there too. Real-time, context sensitive spell checking. Type in “I really like been soup” and it knows you meant “I really like bean soup” and corrects it. “Icland is an icland” automatically becomes “Iceland is an island”. There’s also real-time language translation. The devil will be in the details here, but the demo was very smooth.

The federation is a key concept here as well. Clearly Google will be hosting Wave. But it’s open source. You can also host your own Waves on your own server – Google doesn’t get that content. It’s also fine grained federation. If you have a Wave hosted on a Google server, but share that out to a federated server, and then decide to make some of the Wave content private, that private content resides only on the federated server – not at Google. This is all done using the Wave protocol – again fully open.

Oh, and it’s open source. At the moment it’s an early developer release. They’re opening things up early to get developers working on extensions, using the full API.

Check out the video demonstration – it’s 90 minutes long, but well worth watching.

How to install AdSweep for Google Chrome

Update 12-Feb-2010: Now that Chrome more fully embraces extensions, I’m using the AdBlock extension.

Update 16-Nov-2009: Looks like Chrome 4 is not yet supported by AdSweep. In addition it looks like AdSweep was abandoned by the original author, and has been taken over by someone else, and the AdSweep site itself has been turned over to low-life advertising. At this point, I’d recommend not using AdSweep. I have not yet found any good alternatives – let me know if you find anything.

read more...

Check for a valid date in PHP

Update 30-Jan-2010: This version doesn’t work if the date format switches the day and month. Check out the updated version for a fully functional date validator.

PHP is an atounding language. There are 48 different functions to do things with dates and times. And the one to validate that a given string is a valid date requires you to do your own date parsing.

Here’s a simple routine that takes a dd-mm-yyy H:M date string (optionally including a timestamp), or a Unix timestamp, and checks to see that it’s a valid date.

The routine accepts date strings with slash, comma, or dot separators, and tries to find a valid date in either %d-%m-%Y, %Y-%m-%d, and %m-%d-%Y formats. Time stamp is optional and in the form %H:%M.

Also check out this great tool for visualizing regular expressions. Here it is in action with the date and time regular expression used to validate the date and time in the code below.


function isDate($d){

$ret = false;
$re_sep='[\/\-\.]';
$re_time='( (([0-1]?\d)|(2[0-3])):[0-5]\d)?';
$re_d='(0?[1-9]|[12][0-9]|3[01])'; $re_m='(0?[1-9]|1[012])'; $re_y='(19\d\d|20\d\d)';

if (!preg_match('!' .$re_sep .'!',$d)) $d=strftime("m-H:%M",$d); #Convert Unix timestamp to EntryFormat

if (preg_match('!^' .$re_d .$re_sep .$re_m .$re_sep .$re_y. $re_time. '$!',$d,$m)) #dd-mm-yyyy
$ret = checkdate($m[2], $m[1], $m[3]);
elseif (preg_match('!^' .$re_y .$re_sep .$re_m .$re_sep .$re_d. $re_time. '$!',$d,$m)) #yyyy-mm-dd
$ret = checkdate($m[2], $m[3], $m[1]);
elseif (preg_match('!^' .$re_m .$re_sep .$re_d .$re_sep .$re_y. $re_time. '$!',$d,$m)) #mm-dd-yyyy
$ret = checkdate($m[1], $m[2], $m[3]);

return $ret && strtotime($d);

}

Unix time dooms us all and the world will end

->Update 16-Feb-2009: The partying was prolific, profligate, and pervasive. Even Google got in on the act with a special logo, displayed for the very occasion!

The end of the world is nigh… Friday the 13th of February, 2009, at exactly 6:31pm and 30 seconds EST to be exact (that would be 2009-02-13 23:31:30 GMT). That’s because at that exact time, Unix time will read “1234567890”. That’s a sign if I ever saw one. Scary times. What we need is a giant ass countdown clock.

Of course, not everywhere in the world is luck enough to experience this particular turnover on Friday the 13th, so for them all will be fine (that would be anyone east of Greenwich). Doom be unto all ye others though. Oh, and all iPhones are pretty much totally out of luck, being based on Unix as they are.

Now you might be sitting there all nice and safe thinking, it’s only one second, how bad could it be? Ha. One second is way longer than the 10⁻³⁷ seconds it took to for the universe to start expanding in the first place. So be afraid.

What it all boils down to is that it’s Y2K all over again, except without all the problems. Oh, wait, there were no problems. Yeah, so it’s just like Y2K.

Other momentous celebratory occasions have occured in the past, and we all know how that ended up.

  • At 01:46:40 UTC on September 9, 2001, the Unix billennium (Unix time number 1000000000) was celebrated.
  • At 01:58:31 UTC on March 18, 2005, the Unix time number reached 1111111111.
  • At 03:33:20 UTC on May 18, 2033, the second billennium will be celebrated (Unix time number 2000000000).

Of course, on Tuesday 19 January 2038, 03:14:07 UTC all non-64 bit (or greater) Unix systems really will be screwed, as that’ll be when time actually rolls over, from 2147483648, back to zero. Now that’ll hurt. Ouch.

Find out what time the world ends in your region.

  • Perl: date -d @1234567890
  • PHP: php -r 'echo date("m-d-Y H:i:s", 1234567890)."\n";'

Personally, I shall pass the event downing beverages with nary a care for the consequences. Pah. The world shall end.

jQuery browser chess

Check out this browser based Chess implementation. The site is in French, but it’s pretty easy to work your way around.

The first player to the site gets a URL to send to the second player. Once the second player visits the URL, the game is on. Moves made by one player are seen on the other players web-browser immediately. Very smooth. Written in jQuery.