What's been happening?

January 5th, 2009

Posted at 11:00pm by Stan

I've upload some updates to sanctus.org tonight, they include fixes to the existing iPhone optimized version (for those curious, just go to the normal site in your iPhone/iPod Touch), fixes to the Sundays after Christmas and New Years, fixes to some backend logic that no one cares about, the addition of text-links to Libronix (little icons at the end of Scripture readings) and the ability to go directly to a date by doing... http://sanctus.org/lectionary.html#YYYY-mm-dd where YYYY-mm-dd is the year - two digit month - two digit date, ie. 2009-01-05.

For those that have been asking, an iCal file is on the way. The file generated from the old sanctus.org site ended on 12/31/08 so if nothing else I need it. I'm verifying dates and things of that sort and then need to figure out a place to post it. There's also the possibility of a Libronix Lectionary file coming as well. If you're in need of these resources and would like to see it and others please consider a donation to help support the Lutheran Lectionary Project. All donations go to defer the cost of hosting and bandwidth.

Pax Christi

December 22nd, 2008

Posted at 2:34pm by Stan

I've just release jGrowl 1.2.0beta3 over at the jQuery plugin page. This release includes some minor changes based on user feedback to the way that a notification is closed. Currently the triggers occur by the little "x" close button or by way of time elapsed or by way of the "close all" button. While it's possible to introduce your own trigger for closing a notification (for example, click anywhere on the node), it's not as easy to implement. Subsequently, the closing off a notification has been moved such that at any time you can call, jQuery("div.jGrowl").trigger("jGrowl.close); and the close operation will be initiated.

You can download this release here.

December 22nd, 2008

Posted at 9:00am by Stan

Dates and timestamps and things of this sort have often been the bane of my existence when working with javascript. For whatever reason javascript never came out-of-the-box with handy dandy date utilities to make working with those types of variables painless. I'm slightly spoiled, because in PHP you can do just about anything with strtotime() and the formatting options of date(). PHP 5 tossed in the DateTime object and then things became really fun. Likewise, when I work in the world of Java there is SimpleDateFormat and the far superior Joda. Most of the time I just let these things do the grunt work when it comes to dates and I let Javascript feed off of their superiority.

Today I stumbled into Datejs, which is a Javascript library that takes from the best elements of the Java and PHP world, mixes them together and tacks on some excellent jQuery-style chaining to make what is by far the best date solution for Javascript I have seen to date. There are formatting features for outputting dates, conversion features for reading in dates, modification and comparison methods and best of all a series of chainable function to build dates, ie. Date.today().next().thursday();. How cool is that?!? I'm bundled this into just about everything I do, if I include jQuery or some other primary library into a project I expect to be tucking this in with it. Too often am I stuck with a date conundrum, so it's better to have this utility around.

Bottom line, if you're doing javascript work of any kind and haven't already found this gem - go download it now().

December 13th, 2008

Posted at 7:00pm by Stan

Unlike some other languages, PHP does not continue to run in the background even when "stuff" stops happening. Compare PHP to Java for example and you'll see what I mean. This can pose problems for large requests, where perhaps the browser gets locked up longer than most users are willing to sit by and endure. This can cause problems. One of the issues I've also run into deals with updating static content. Sometimes content changes, and in order to detect static content changes you have often have to do some work which calls into question the benefit of static content, or resort to caching which brings its own set of problems. Other times you just need to do something at a given interval or period, say for example checking to see if an RSS feed has changed. You may want to do this every 30 minutes. Your options are to check the time when a user access a page and decide if you should do some background work or resort to a cronjob and let it take care of this business. Most of the time one of these two options will work just fine.

I'm a firm believer that an out-of-the-box application should be as stupid-proof as possible, and that as the application packager I should assume the user knows nothing and do everything I can to make installation seamless. This is why I use a Phar to distribute app's and have them extract their own SQLite database, for example. With this line of thinking it's just not safe to assume the user has the slightest clue about cronjob's or how to set them up, let alone have access to them. So, what do you do?

Initially I assumed I would setup a single cronjob and call a single script which would dictate scheduling for programmatically designed "jobs". This would allow any one of my various modules to create a job on the fly programmatically and not have to concern itself with the particulars of how that job would be executed. Sounds fine, but still doesn't solve my dummy proof approach. Then I stumbled across this code snippet in the PHP manual while looking at ignore_user_abort()...

<?php
ignore_user_abort(); // run script in background
set_time_limit(0); // run script forever
$interval=60*15; // do every 15 minutes...
do{
   // add the script that has to be ran every 15 minutes here
   // ...
   sleep($interval); // wait 15 minutes
}while(true);
?>

Some purists won't like this code, but I think it's golden! I've been running some tests locally, and as best I can tell if you're smart about your "job" code you won't run into any issues. Part of the trick is remembering to make sure the scheduling script is running. I do this by updating a row in a database to indicate the last time the scheduler ran, and if that last scheduler execution exists outside of a given range (say twenty minutes with the above example), then I trigger the scheduler again. For this to work, though, keep in mind the scheduler needs to be triggered with an http request. You can do this either in the HTML-word using javascript or something similar, ie. an AJAX request to the scheduler. Or you can use PHP itself like this...

<?php 
$ctx = stream_context_create(array( 
    'http' => array( 
        'timeout' => 1 
        ) 
    ) 
); 
file_get_contents("http://www.mydomain.com/scheduler", 0, $ctx); 
?>

Notice this will timeout right away, the purpose is to initiate the scheduler and not to actually see what the scheduler is doing or wait for it. Another important thing to note is that you'll want to check to make sure the scheduler isn't already running when you go to start up the scheduler. I realize we just covered spawning the scheduler, but in the actual scheduler code you want to double check it's not running. It's entirely possible depending on your setup that a scheduler could get triggered when another scheduler is executing, and you want to be assure to avoid tying up your apache processes with unnecessary instances of the scheduler.

As a final precaution, realize that you need to be smart about your code in the scheduler. You need to aware of variable usage and what you're doing to the memory allotted to PHP. I suggest even going so far as to maybe evaluate memory usage in the scheduler itself, shutdown the scheduler when necessary and spawn a subsequent scheduler process. You also have to deal with error handling, both from PHP and from user-land. Cron takes output and e-mails it to you, that's an option, or an external log file is an option. Either way you want to be aware of errors and make sure the right people know about them.

Well, happy scheduling!

December 4th, 2008

Posted at 5:17pm by Stan

A new beta of jGrowl 1.2.0 has been uploaded on the jQuery plugin page. This latest beta fixes several syntax errors if you went to compress the library or obfuscate it, as well as fixes a major bug in the log callback. That error would have occurred in the event that a custom option object did not define a log callback. If you run into any issues or have any suggestion please feel free to send them to me. Otherwise, you can download this release here.

November 28th, 2008

Posted at 10:06pm by Stan

I've released two new versions of jGrowl this evening, the first is 1.1.2 and includes minor changes to 1.1.1. Nothing serious or exciting there. The other release is an initial beta of 1.2.0 which offers pooling capabilities. What I've noticed is that sometimes too many messages get sent to jGrowl at a given time and messages which are the bottom of a listing can expire before they ever come into view by the user. This really defeats the purpose and functionality, so I've been trying to figure out how to avoid this problem. Messages are pooled into a queue and will only be rendered in the event that the pool has now reached its pooling size. By default this functionality is turned off, however I've included an example file that enables this functionality and sets the pool size to 5 messages. For those who use jGrowl and have run into this issue I highly recommend trying out the 1.2 beta. I haven't decided if anything else is going into 1.2 yet, so you may be looking at a final release... who knows, only time will tell! :) Anyhow, feel free to provide me with feedback on this recent change. You can find these releases on the jQuery plugin page here.

September 1st, 2008

Posted at 10:47pm by Stan

I've been playing around with Google Gears on an application I work on in my spare time. That application is heavily driven by jQuery, and the decision to leverage Gears came with mixed emotions. In the developer's FAQ there's a pretty diagram which recommends utilizing a "data switch" between the user interaction and the subsequent process. I think this is Google's clever way of saying, make your application driver-driven! This makes sense and fits the design too...

Let's get hypothetical and say we have an interface for your hypothetical driver has two methods, one for reading and one for writing. In driver implementation A AJAX requests are fired off for reading and writing your data, however in driver implementation B we'll rely on locale storage - in this case, Gears. With jQuery you normally just write the act of reading or writing into the handlers, however that just doesn't cut it once you have alternative sources that those handlers need to deal with. One option is to simply test for which "driver" you need and use conditionals to get where you need to going. I like to look ahead though, and surmise that some day I may want to add support for Safari's HTML5 Database Implementation in addition to my online mode and my Gears support. Who knows too... if the application ever gets ported over to Adobe AIR we've added a fourth data source to the mix.

The point is we need to abstract this stuff out. One option is to simply test if you need a driver and then overwrite the handlers, first unbinding them and binding new ones in their place. But what do you do when you want to switch back? We can start encapsulating stuff in functions for binding all of these elements, but we wind up reusing a lot of code in the process. As best I can tell, right now there is one other option, and that's to create an object and have all of the event handlers reference that option for certain tasks. This object then can be dealt with as you're switching between states, but ultimately parallels a traditional driver-based design pattern. The down side to this is it suddenly doesn't look like unobtrusive javascript code (ie. jQuery).

I'm wrestling with what my alternatives to that final solution are... right now it doesn't seem like there are any. I confess I was tempted by Low Pro for jQuery, but suspect this will be limiting in the long run. I'm wondering if anyone else has any ideas? If so, drop me an e-mail I'd love to hear about them.

August 24th, 2008

Posted at 9:48pm by Stan

I was reminded the other day of cool a mashup of PHP, Phar and Sqlite can be. Hopefully you know what PHP is, but it's possible you haven't heard of Phar yet. Phar is a file format that can contain an entire application in a single file. It is available via the PEAR library through the PHP_Archive package. Think of Phar in terms similar to Jar for Java. It allows you to ship around an entirely functioning application in a single file that can be executed by the interpreter it was written for. Since Phar debuted as a PEAR library it's also been developed into a native extension via the Pecl repository, and I'm happy to report it will be moved into the core for PHP 5.3. Lastly there is Sqlite which beginning with version 5 of PHP has been bundled and embedded into its core. Currently you get the 2.x API via the native methods (sqlite_*()) and the 3.X API via PDO. In 5.3 this will change though, and you'll get access to 5.3 in the native methods as well, which is nothing short of wonderful.

[ read more ]

August 17th, 2008

Posted at 10:03pm by Stan

I have released jGrowl 1.1.1 this evening on the jQuery plugin page. This is a simple maintenance release fixing some minor issues that arose in 1.1.0. One new feature has been added, which is an optional setting to customize the content of the [ close all ] link for containers of multiple notifications. Additionally I have expanded the examples to include some more flashy skinning, and I have added a new example called jTweet. jTweet uses Twitter's javascript API to fetch twitter updates and generate several jGrowl notifications for them. The latest release can be downloaded here. All existing jGrowl users are encouraged to upgrade to this release.

August 17th, 2008

Posted at 5:26pm by Stan

I ran into an interesting problem last night that yielded little to no documentation when I searched Google. The problem involved Mail.app and my ability to search for messages. I'm a adamant user of MailTags, which is a plugin for Mail.app on Max OS X that adds tagging support to e-mail messgaes. MailTags is actually one of those few Shareware applications actually worth paying for. Well, I was trying to run a search for a MailTags keyword and nothing was coming up, but I knew there were messages tagged with that keyword. To make things weirder, when I went into the MailTags preferences and tried to "collect" tags and projects from my message index it would clear out my preference lists. Something was wrong, but I couldn't figure out what. Then I realized that searching "entire message" didn't work as well. At first I chalked this up to a bug in MailTags, but when I uninstalled MailTags I still couldn't search the body of messages. Well, it turns out that Mail.app's search methods utilize Spotlight, and MailTags also depends Spotlight's searching power. A couple of weeks ago I used Onyx to disable Spotlight entirely. See, I hardly ever use Spotlight... the truth of the matter is that I'm a QuickSilver fiend. I've been for awhile, and haven't had much use for Spotlight. I disabled Spotlight thinking it might save a small amount of processing power behind the scenes. I'm sure I was right, but whatever it saved me wound up being negligible in the long run. When I disabled Spotlight I essentially neutered Mail.app of it's search capabilities. Turning Spotlight back on and then reindexing my drive solved the problem, but it turns out this one of those areas where Onyx seems quirky. I suggest if you run into this problem turning to your terminal and entering this into the prompt:

sudo mdutil -i "/Volumes/Macintosh HD"
sudo mdutil -E "/Volumes/Macintosh HD"

In case you were wondering, mdutil is a "Utility to manage Spotlight indexes", and the first line using the "i" flag toggles the indexing on or off for the specified drive (BTW, substitute your drive's name in for "Macintosh HD" as necessary). That second line with the "E" flag erases any existing index and then begins rebuilding the index from scratch. That quick fix, and some time spent indexing solved all of my Mail.app search woes. So, if you are experiencing trouble with Mail.app searching, or any other app for that matter and may have tinkered with Spotlight or other system related settings, consider running the above commands and fixing your Spotlight indexing.

tags: mac, software
1    |    2    |    3    |    4    »    [4]
Powered by BlogSCL3 0.5.0alpha