Archive for the ‘System’ Category

Is it true? A decent JavaScript editor?

Of all the software I have on my Mac, I’ve always been missing a decent JavaScript editor. I do have editors that support JavaScript syntax highlighting and such but they lack those extra features. For other languages such as:

  • CSS I have CSSEdit and StyleMaster,
  • PHP I have Zend Studio and it’s wonderful developing environment,
  • HTML, JavaScript and general code editing I have the awsome BBedit,
  • and for general subversion access there’s svnX.

(note the lack of a WYSIWYG editor! Everything by hand!)

But I really want a good JavaScript IDE. And I may have found one. A colleague pointed me at Aptana, I just downloaded it and gave it a quick try and looks very promising:

aptana_test.jpg

My only complaint is that it’s written in Java so it doesn’t use the standard windowing methods on my Mac but I can look past that if it’s good enough. Hopefully this will now complete my tool set.

24 Ways: CSS Production Notes from Subversion

I came across a great article about creating CSS production notes by Andy Clark. It’s a great idea to show co-workers the information and notes about a file but in my production environment I often use subversion so I’ve merged the two. If you use subversion and a dynamic language such as PHP there’s no reason why you can’t show the subversion log for the current file in the same way. Here’s a quick little PHP script that does exactly that. Feel free to use and edit it as much as you like, just let me know if you make a big improvement so I can post it here. Enjoy:

<?php

/**
 * A quick PHP script to produce the notes markup from subversion logs.
 * @see http://24ways.org/2006/css-production-notes
 */

//the current file in the repository, you could use $_SERVER['PHP_SELF']
$file = '/home/jeff/subversion/myproject/trunk/index.php';

//retrieve the log from subversion
$exec = array(
        'cmd'=> 'svn log --xml --verbose ' . escapeshellarg($file), //command
        'output'=>null,
        'return'=>null
);
exec($exec['cmd'],$exec['output'],$exec['errors']);

//make it a string.
$log = join($exec['output']);

//create the notes
$notes = '';
$xml = new SimpleXMLElement($log);

//build the notes
foreach ($xml->xpath('//logentry') as $entry) {
    $message = nl2br($entry->msg);

    $notes .=
<<<NOTE
<li>
    <blockquote cite="{$entry->author}">
        <p>{$message}</p>
        <p class="date">{$entry->date}</p>
    </blockquote>
</li>
NOTE;

}

$notes = '<ul>'.$notes.'</ul>';

//do whatever you need with it.
echo $notes;

?>

Relativity and Your Web Site

Caution: Paths may explode.I bet, at some point, you’ve come across a broken link or maybe an image that just wasn’t loading properly into your web site. When it comes to linking files, or more specifically, file paths in your web site, everything is relative. But relative to what? The problems associated with relativity become especially apparent when working with dynamically created pages. (more…)

Yet another JavaScript logger

While writing Beginning Google Maps Applications, I grew accustomed to using GLog.write() while debugging any JavaScript I was working on. It was a wonderful alternative to alert(). That was great while I was working on map related projects but without the Google Maps API, it wasn’t there. Finally the other day, frustrated the 100th time I accidentally put my browser into an infinite alert loop, I decided to write up a quick logger myself. Afterwards, I realized there were already a bunch on the net but I had fun writing my own and even learned a few DOM tricks. For any of you out there who want to use it, go nutz. I’ve called it JSLog and the primary methods are JSLog.write(); which outputs escaped angle brackets while JSLog.writeHTML() outputs the raw input.

JSLog Window

The best part is now when debugging things like Prototype AJAX calls, you can easily log and see all the exceptions!

new Ajax.Request( 'example.php', {
    onComplete:function(request){
        try {
            //do whatever you need to an errors will be logged!
        } catch (e) {
            if(JSLog) JSLog.write(e);
        }
    }
});

No more errors floating into dream land!

To use it, just download the source or add

<script type="text/javascript" src=http://jeffreysambells.com/openprojects/JavaScript/JSLog.js"></script>

to the head of your document.

TODO: Get PHP 5 Certified - Check!

Well I guess I was better prepared than I thought. The exam was tough, so if you’re preparing I suggest studying hard and make sure you know all the little details!

Dear Jeffrey Sambells, Congratulations on passing the Zend PHP Certification exam! As a Zend Certified Engineer you are now among an elite group that leads the growth of PHP. The benefits you receive as a Zend Certified Engineer include:
  • Personal profile on the on the ‘Yellow Pages for PHP Professionals’ at: http://www.zend.com/zce_yp
  • Standing out from the competition when looking for a new job; or at your annual salary review
  • Global recognition of your PHP skills
  • Discounts on selected Zend products and PHP conferences worldwide
  • Exclusive previews of emerging Zend products
Whether you are distributing an application, seeking employment, bidding on contract work, or pursuing career advancement, your new status as a Zend Certified Engineer provides a tangible and verifiable advantage. You are welcome and encouraged to add the Zend Certified Engineer logo, found at http://www.zend.com/zce-logo/, on your website or online resume with a link back to your profile on the ‘Yellow Pages for PHP Professionals’. Use the following link: http://zend.com/zce.php?c=ZEND901180&r=5112390 Your official certificate will be mailed to you within 4-6 weeks. Bonus: Get your own Zend Certified Engineer business cards for FREE! Best of luck and happy PHP’ing. Sincerely, Dhwani Vahia Education Programs Manager Zend Technologies, Inc. http://www.zend.com The php Company

php|works 2006 Day 3

Session 1: eZ components

Derick Rethans Slides

eZ components are re-useable, clean IP, Open Source friendly, building blocks that you can use in your PHP applications.

Similar to PEAR, it requires a base class for common exceptions and other common elements and provides components for:

  • Command line
  • File
  • database
  • Mail
  • Image
  • Logging and Debugging
  • System Information
  • as well as a output Templating and Translation component.

Components are generally independent and do not rely on other components unless absolutely necessary and each class in prefixed with ecz to eliminate the possibility of conflicting with your existing classes.

Installation is as simple as downloading the latest source and adding the appropriate ini include path. the only trick is that component framework relies on the __autoload() function so if you’re using it in your framework, you’ll need to check for the components using ezcBase::autoload($classname); (assuming you’ve already included the base using “require ezc/base/Base.php”).

For installation of new components, you can also use the PEAR installer using the channel://components.ez.no, so for example to install the base automagically, just run PEAR install channel://components.ez.no/Base

For usage examples see the docs or Derricks slides from the seminar. Neat things include:

  • Console table formatting and progress bars!
  • Really nice logging components for creating and managing your own custom log files.
  • Database query abstraction, looked a little messy to me, but I’ll have to check it out a bit more before I judge.
  • Creating and sending MIME mail (similar to PEAR)
  • Feed readers
  • Graphs
  • SignalObserver: IPC for PHP

Session 2: Explaining EXPLAIN

Lukas Smith Slides EXPLAIN is an SQL keyword implemented by most databases that outputs what the query is going to do (execution plan) and ‘explains’ how it’s going to do it and the estimated “execution cost”. If your queries are running slowly, using EXPLAIN could reveal some interesting information about the performance of your query and where you can improve things. Remember however that EXPLAIN isn’t actually part of the SQL standard, it’s just a nice developer feature added after the fact.

When looking at the output of EXPLAIN:

EXPLAIN ANALYZE SELECT * FROM customer JOIN contact USING (last_name);

QUERY PLAN

Hash Join (cost=1.02..92.23 rows=2048 width=351) (actual time=1.366..58.684 rows=4096 loops=1) Hash Cond: ((”outer”.last_name)::text = (”inner”.last_name)::text) -> Seq Scan on customer (cost=0.00..60.48 rows=2048 width=107) (actual time=0.079..21.658 rows=2048 loops=1) -> Hash (cost=1.02..1.02 rows=2 width=287) (actual time=0.146..0.146 rows=2 loops=1) -> Seq Scan on contact (cost=0.00..1.02 rows=2 width=287) (actual time=0.074..0.088 rows=2 loops=1) Total runtime: 62.233 ms

the order of the table is important. Form the presentation, in general for complicated queries, PostgreSQL is better at picking a good execution order over MySQL (ya!).

When using indexing, the formate of your query is important. for example in you have a table where c1 and c2 columns are indexded, “c1=c2 AND c1=12″ would be better written as “c1=12 AND c2=12″ as the index may not be used on the c1=c2 comparison.

PostgreSQL allows you to specify the storage order of the records in your table so you can further optimize based on what you’ll be sorting on (he didn’t say HOW to do this, I’ll have to look into it more).

Lukas has a tendency to run out of time on his presentations so he was flying through this presentation to fit it in. I stopped typing everything to pay attention so definitely check out the slides. Related

Session 3: Apps Made Easy on Zend Framework

John Coggeshall

I’ve poked about in the Zend Framework (even submitting a proposal which was ultimately rejected due to the scope of the framework) and have been following it closely. Were at a point at work where we need to reevaluate some of our platform and decide if there are better alternatives out there. ZF combined with PEAR and eZ components, offer a lot of compelling reasons to start integrating more ‘off the self’ components rather than trying to re-invent the wheel.

The Zend Framework is just a small part of the PHP collaboration project that offers a “clean IP”, modular collection of PHP classes based on PHP 5 / E_STRICT. It provides a starting point for all your applications and demonstrates the PHP 5 best practices. It’s modular design allows only pieces to be used within your applications and achieves it’s goals with a minimal object hierarchy.

One of the ideals I like the best is that the frameworks strives to be simple and easy to use. “Simple things should be simple, complex things should be possible”. the architecture is distributed as a package, not as individual modules, which provides a “use at will” setup so everything is accessible if you want it.

The framework is namespaces to Zend:: and all constants are class based so it will lay nicely with any other components (ez, Pear). Other than setting up the proper include path in your php.ini file, all you need to do is download it (or check it out from the subversion as I do).

ZFApp

ZFApp is a framework based of ZF that sets up the initial structure of an application using the Zend Framework. It’s in the Lab project of Zend’s framework, where non-core idea prosper. ZFApp is working towards, for example, being able to write a blog in 30 minutes with all the bells and whistles including authentication, searching, syndication and more.

Taking a lot from Ruby on Rails, ZFApp provides a rudimentary installer that sets up an initial app framework where you can then begin to play. Taking the “Convention over Configuration” approach, you can then add controllers and views in the specified format and -tada-, your app will be up and running is seconds.

The demo app for the seminar was a fully functioning blog app, which appeared well rounded on minimal code. If you’re looking to build new apps based on the Zend Framework, this is definitely worth a look. From the brief introduction, the only hesitation I have is the views reliance on Smarty. I’ll have to explore more but allowing alternate template engines would be a nice add-on.

Roundup

Overall the conference was worthwhile, much better than last years. The speakers seemed well prepared and knowledgeable but I was more selective about what sessions I attended based not only on the topic but also the speaker. A few speakers could have presented themselves in a little more professional manner (no ripped shorts and flip-flops please) but the content of their presentations was still good.

I didn’t get a chance to attend the after hours events but I heard they went well so I’ll have to attend next year. Aside form the conference, I do have a few gripes with Wordpress now that I’ve been using it consistently for tree days (code formatting and headers anyone?).

As for ideas, I have a ton. I mentioned in a previous post that we’re in the rocess of migrating to PHP5 at work and I’m responsible for upgrading and improving the overall framework and system. Zend Framework, XML, convention over configuration, namespaces and a bunch of other PHP5 goodies will be at the front of my brain as we wade further into v5. It’ll be exciting!

And as a followup to my Ap’p'le post, they’ll be replacing my MacBook keyboard, but I have to leave it with them for a week once they get the part in. I’ll have to argue that a bit more as I live an hour from the store and my wife and I are expecting our first child next week so I’m not going to have time to be diving there at their leisure, let alone be without my MacBook for a week when the baby’s coming and I have to unload my cameras!

Oh, and here’s the solution they came up with for the lack of plugs…

Plugs

php|works 2006 Day 2

Aside: just a note that I think abot 30-40% of the people here are using Mac laptops and about 80-90% of the speakers are.

Keynote: Microsoft platforms for the PHP Developer

Joe Stagner (Microsoft) An introduction to PHP on Windows and why you should consder it. I didn’t take a lot of notes here since we use Linux/Apache/PostgreSQL/PHP at work and have no intentions of changing for a variety of reasons I won’t get into here. This was recorded so perhaps they’ll distribute it from the phparch site.

Mentioned was PHP Designer, which may be worth a look.

(more…)

php|works 2006 Day 1

Keynote

Rasmus Lerdorf Slides (may not be working yet)

Yet another excellent keynote by Rasmus, I’ll have to track him down at lunch for a little chat. Rather than go into detail, I’ll just link to the video of the keynote on Google. Highlights are:

  • Flash and IE header/cookie hacks
  • Optimizing your server and script to handle a Digg/Slashdot (including how to find bottlenecks)
  • Dom and simple XML
  • Geocoding/maps/flickr
  • Real file upload progress detection in PHP 5.2, Finally! (source)

(more…)

php|works 2006 Day 0.5

Arrived early again today so I have almost an hour before the Rasmus Lerdorf keynote starts. Just a quick post over my excitement on getting free swag in the conference package - an Apress t-shirt! Coincidence?

Apress shirt back Apress shirt front

php|works 2006 Day 0

The official conference doesn’t actually start until tomorrow as today was an ‘extra’ day of in-depth tutorials (hence day 0 not day 1). I was however pleasantly surprised by the initial preparedness of the extra day. I arrived an hour and a half early (to beat the downtown Toronto traffic) and they were already accepting registrations and everything was ready to go. Last year I was worried I was in the wrong building as I waited in the lobby for about an hour before I even saw signs of the conference. The location itself is pretty easy to get to and has a nice atmosphere.

Conference Room

(more…)

Content & imagery © Copyright 2007 by Jeffrey Sambells as appropriate.