Categories
Technology

A report card of AJAX/DHTML platform compatibility.

I’ve been checking out more of the AJAX/DHTML libraries which have been released lately. In the back of my head I have a nagging question about their cross-platform compatibility. I certainly don’t want to use anything which isn’t cross-platform, because that smacks of the browser wars from long, long ago.

Luckily I’ve found someone who has already worried about this and put the effort into finding out. The article also talks about the history of dynamic HTML on the Web and the battle between Microsoft and Netscape.

A big thanks to musings from mars for creating the AJAX/DTML Report Card

Categories
Misc

Great 3D sidewalk art by Julian Beever

batman-robin.jpgI stumbled upon some web sites with photos of 3D sidewalk-art by English artist Julian Beever. Click here to see a larger image.

All of the images I have seen show the artist interacting with his work, which are amazing, three dimensional chalk drawings. The one shown on the right is one of my favorites, here Julian is teetering on the edge of a burning building while Batman and Robin come to save him.

You can see lots of other examples at Julian Beaver’s web site. Also here are some other web sites with photos of his work:

Categories
Programming Python

Doing Python-style imports in JavaScript

Lately at work I’ve been doing a lot of programming in JavaScript. Among other things, I have been learning about using the prototype object to do object oriented programming. One thing that I missed was the feature in Python used to import modules directly into other code. For example:

from glorp import blah
import foo

I was happy to have found an open-source project which emulates that functionality in JavaScript! I haven’t been able to do more than skim the web site, but it looks promising.

h3. Resources

Categories
Geek How-To

Hacking the front page to display my blog entries

h3. The problem

I wanted the home page of my web site to show my blog entries and also be a little more dynamic by displaying other related content.

The default @index_html@ page for my blog software, Quills, does display the current entries, but from what I read online there was no great solution to get its default page to show at the root.

Plan B was to replace my generic @index_html@ page with one which would query the Quills weblog object for all of its entries and then display them one at a time. I wanted to use one of Plone’s built-in user-addable types for the script but as far as I can tell they are only used to display formatted text and won’t execute any code. I finally used the Zope Management Interface (ZMI) to add a single Zope Page Template (ZPT) called @index_html@.

h3. Understanding how Plone draws a page

I read several chapters in the book The Definitive Guide to Plone to figure out how to proceed, but the one which gave the most pertinent information was Chapter 7 – Customizing the Main Template.

In short, Plone has a special Zope Page Template (ZPT) at @/your_plone_site_folder/portal_skins/plone_templates/main_template@ which contains the HTML and special markup used to render the basic structure of each page in the site. Among other things, the markup defines regions within the page called @define-slots@. These slots are filled in by an object as it is being rendered for view in the browser. Using a master template like this assures that the site has a consistent page layout.

Within this master template there are slots defined for different sections of the HTML like @head_slot@, @css_slot@, @column_one_slot@, and @content@. Some examples of these slot definitions follow. Notice that they can be within different types of tags.


  This content will be replaced.

...

When you are rendering your ZPT, you define the areas which will “fill” these slots and place the pertinent content within them. These areas are appropriately called @fill-slots@. Here are some examples:


  your stuff here


your stuff here

There are other things to know about how a page gets rendered, but this is the basic idea.

h3. Creating the page

With @define-slots@ and @fill-slots@ in mind, I created my ZPT at the root of my Plone site called @index_html@ so I could start hacking. For my purposes I was only interested in changing the fill-slot @main@ so I defined my fill-slot like above and put some bogus content in it to make sure I was on the right track. I filled out the rest of the code with guidance from examples in the book, other code in the Plone @portal_skins@ area as well as in the Quills product directory.

h3. Getting the entries

The Quills file @/Zope/Products/Quills/WeblogArchive.py@ had two methods defined which return a list of blog entries – @getEntries()@ and @getLazyEntries()@. The difference being that the latter only returns the catalog search objects, so it’s fast but the data which can be displayed is limited to the metadata definitions in the @portal_catalog@. I was hoping to get the full text of the entry so initially used @getEntries()@, but it turned out to be too slow.

h3. Keeping with the site look

Next I wanted to use as much of the site style sheet as possible too keep the look consistent. Most of the important entries are in the main style sheet which is found at @/your_plone_site_folder/portal_skins/plone_styles/plone.css@.

h3. Extras

I added this page to the site RAM Cache since this is the front page and the entries don’t change very often. ZMI > Cache Tab > Cache Object Using RAM Cache > Save Changes. Easy.

I also hacked together an RSS icon and feed in the h1 title.

h3. Things to update

My page works, but I should tidy up some of the CSS and change the design to be a little more interesting. I also have hard-coded the name of my weblog object instead of using the @portal_catalog@ to find it for me.

You can click here to download the template.

Categories
Apple Geek Misc

Ho Hum on the Apple front, but I still want a Mini

I am glad that Apple has upgraded the Mac Mini with the new Intel processors because I wanted to get one to use as my web server. Awhile back I read something which stated that Python runs slower with FreeBSD on a Mac. I can’t remember if it was a combination between the language/processor or language/OS, though I’m hoping for the former. The latter would mean that the processor change wasn’t going to help the bottleneck in the multi-threaded environment (or whatever the issue happened to be). Now that the upgrades are a reality perhaps I can dig into the problem again and see if it’s is no longer an issue.

The performance of Python is important because my web server of choice is Zope and it’s written in Python. Within the next year I’d like to have my web sites on a hosted server instead of sharing space, and I’d rather it be running on a Macintosh. I like the idea of having a Mac because they’re easier to administer when you’re not a system administrator in real life. On the other hand I’d hate to buy a Mini and have it sitting in a dark colocation somewhere with no one to fully appreciate its classy exterior. It would better serve me running Front Row, sitting on top of my entertainment center right next to my Airport Express, and then I could ship a “Dull” to the data center.

Categories
Misc Technology

When did Linux become mainstream?

I read an “article on lxer.com”:http://lxer.com/module/newswire/view/54858/index.html which talks about perceived changes in the culture of LinuxToday.com. It blames the widespread adoption of Linux as the culprit which shooed away the hard-core geeks from the site. Of course Linux adoption was a slow, gradual process brought out by a series of events in the computer world. The article gives several examples including IBM embracing Linux at the LinuxWorld Conference & Expo in 2001 and a congressman from Venezuela telling Microsoft to drag its underhanded business practices elsewhere because he was going to adopt Linux for use in his country.

I personally think the shift started back during the United States vs. Microsoft case. I can’t remember, but I think it was Ballmer who stated, “We’re not a monopoly, because there’s that Linux thing.” Well, that statement unleashed the curiosity of the American media, gave Linux plenty of free press on national television, and launched it into the mainstream.

Why? Linux had been around for almost a decade, existing only as source code passed around the Internet between only the most hard-core of geeks. But now Aunt Helen, located in a little town somewhere in the Corn Belt of America, found out about Linux by watching Fox News even before she was able to get broadband.

This is one of the few times I will say, “Thank you, Microsoft”.

Categories
Geek How-To Technology

Setup MarsEdit with Quills 0.9 Final

I have been wanting to find a better way to write blogs rather than using the Plone interface. I was happy to find that MarsEdit and Quills both implement several blog APIs. Though it would appear that the implementation for both the BloggerAPI and the MetaWeblogAPI are not complete, MarsEdit can still be used to post articles using the BloggerAPI.

Here are examples of necessary configuration:

Name: MyBlog
Home URL: http://www.davidmccuskey.com/weblog
Software: Other Blogger-compatible
RPC URL: http://www.davidmccuskey.com/weblog
Blog ID: weblog.2006-01-10.2395214781

The tricky part is obtaining the Blog ID. Plone uses an immutable identifier for all objects so that they can be found even after renaming them. Quills in turn uses this ID to get at your weblog object.

In order get this ID you’ll need to login to your Zope Management Interface (ZMI) and go digging through the uid_catalog in Plone. When you have clicked on the catalog object, click on the tab labeled Catalog. Find your blog object in the list of results and click on its link.

Search on the resulting popup page for the key named UID. The value of this key is what you will need to use for the Blog ID.

Note: Because of errors in the implementation of the MetaWeblog API, you will see a Zope error after posting, however the post will be correctly saved.

Categories
Design Patterns Programming

Design Patterns – The Decorator

Tonight was the second night of my design patterns meeting I hold with some friends from work. Most of us already had the book Head First Design Patterns by O’Reilly Publishing, but never made the time to go through it. Jennifer was the one who came up with the idea to start having a meeting every two weeks and we all agreed that it was a good idea.

We’re currently working on our format, but so far have settled on one person being the ‘teacher’ for the evening. This person is responsible for presenting the highlights of the chapter to everyone even though we have all read it. After they are finished presenting, we then go around the table and share our ideas on how the pattern could be used at work or on personal projects.

Tonight we discussed the Decorator Pattern. Here were my solutions:

Recipe card

In this design, the recipe card is the base object and the decorators are ingredients. As per the design, ingredients would be stacked up to create the ingredient list. Here’s a rough cut at the class diagram.

decorator_class.png

click to view a larger image

Some of the interesting characteristics of recipes is that they often have to be scaled (eg, from 4 to 12 persons) or translated to another type of measurement (eg, metric/english). This functionality can easily be added down at the ingredient level. The different ingredients could also have superclasses based on their type – liquid, solid, etc. This makes it easy to separate scaling and measurement translation as necessary.

Invoice discounts

In this example the base object is an invoice and the decorators would be different types of discounts or rebates. This would allow a sales team to be creative with the types of discounts given to a particular client.

Discount objects could be applied to different products, plus you have them expire at certain times (free for 3 months), also be percentages or flat dollar amounts.

Next time I’m presenting the Command Pattern.

Categories
How-To Technology

Added AdSense by Google

One thing that I like about Google is that they make things easy.

One thing that I like about Plone and Zope is that they make things easy.

In about an hour or two, I managed to put AdSense ads on my web site.

Go to Google.com/adsense and sign up for your account. Click on all of the emails to activate your account. Log in and grab your AdSense code.

Add a portlet to your custom area in Plone. Paste Google’s AdSense code in the body of your portlet.

Add portlet to your root Plone @right_slots@ property. Refresh your browser to see your Google ads.

h3. Resources

  • “Plone book errata”:http://www.agmweb.ca/plone/book/scripts.html
    This webpage has an Google AdSense portlet example in ZPT. Search for “Page Template: google_ad_portlet”
  • “Plone.org : A webpage with an example Page Template used to create a portlet”:http://plone.org/documentation/how-to/create-static-slot
  • “Plone.org – how to control portlets”:http://plone.org/documentation/how-to/control-portlets
    A website which has instructions on properties which control portlet activation.
Categories
Photography Reviews

New Canon Digital Rebel XT

There is a huge difference moving from a low-end digital camera to a digital SLR – and it feels really good!

Last week I received my Canon Digital Rebel XT from Dell. It’s my third digital camera in 6 years and I’ll say I’m happy again to have come back to an SLR with real lenses.

For the past week I’ve been taking photos around my apartment and outside just to get used to it and its controls. So far I have shot around 700 photos.

Here are the top reasons why I chose the Digital Rebel XT:

  • (almost) instant on
  • real lenses (SLR)
  • low shutter lag
  • highly rated
  • upset at Nikon’s decision to lock down their RAW format

I looked through many of my old photos taken with my Kodak DC240 and Nikon 4500. I saw that many of them were unusable for these following reasons:

  • slow focusing (missed photo)
  • shutter lag (missed photo)
  • slow boot up time (missed photo)
  • difficult manual focusing (blurry photo)

Also there are some features of the camera which have pleasantly surprised me:

  • the battery life !! (350 photos)
  • speed of autofocus (fast)
  • flash range (really far)

I have no regrets at all buying this camera. All of the previously mentioned issues I had with my other cameras are now a thing of the past. I feel like a have a real tool in my hands. The experience has been very very liberating.

Thanks Canon!