✓ I'm available for hire! Check out my open source work on Github or drop me an email

Douglas F Shearer

Posts Tagged with php

There are 4 matching posts.

Insomnia

I had a cup of tea at about 2300, the result of which is that I can’t get to sleep, and it’s now 0226.

I now have a good idea of where I want to go with the Ruby on Rails blogging engine and CMS for running this site. The framework that RoR provides should make it much easier to achieve what I desire than pure PHP did. My PHP code ended up being fat and bloated, and adding any functionality became a nightmare.

Using Rails should also solve the problem of templating, as the view code shouldn’t be as mixed with the business logic. We’ll see how it goes, but the current want list is looking like the following:-

  • Admin – Multiple users, Permissions (definitely a later iteration)
  • Posts – tagging, textile, rss feed, drafts, previewing, recycle-bin, searching.
  • Nice addresses – http://douglasfshearer.dyndns.org/2006/09/04/tagline_of_post.
  • Commenting – akismet and CAPTCHA integration a must
  • Editing – Pane to add photos in gallery into post + uploading new images.
  • Pages – just html, textile will allow me to do this where I desire.
  • Gallery – tagging, resizing/thumbnailing w. cache (similar to what my php version did), sets, photostream
  • Links – tagging, thumbnails

This is exactly where I realise that my current blog formatting is pretty poor when it comes to lists.

 
 

Ruby on Rails

The past few days I’ve been having a play with Ruby on Rails. After all the praise on the web for it, i thought it was about time I gave it a try.

Most languages and frameworks require you to have a server, either as a stand-alone or running on your desktop system, to test the code. Rails comes complete with it’s own server, Webrick allowing you change and test code very quickly, The shipped version of Ruby on OS X 10.4 is unfortunately broken; you need to compile it yourself using the Xcode Tools (a free download from Apple) and these instructions. The instructions tell you to install Lighhttpd and fastCGI, but I just used Webrick, as it seems to involve a lot less fiddling around when I don’t need a fully blown server on my Macbook. Thankfully OS X 10.5 ‘Leopard’ is going to come with Rails already installed.

When I actually got down to doing some code, it was pretty easy to pick up. Compared to the time it takes to prototype and build a blog app or similar in PHP, it took about 15 minutes in Rails, and that’s with no previous Rails nor Ruby Experience! It’s very impressive how Rails matched your database with your business objectts, and I look forward to trying to build some more complex web apps using it.

 
 

Improved Image Resizing and Site Move

After much playing around I decided that my image resize script was chewing up too much processor time and memory, thus making page loads a lot longer.

The solution? Cache the thumbnails, and each time the script is called, check to see if an image with those parameters has already been created. If it has, return that image straight from storage, no waiting for it to be re-rendered.

But what happens if the original image is changed, surely the cached thumbnail will be out of date? For this I check that the last-modified date of the thumbnail is greater than that of the original. If not, it renders a new one.

Pretty spiffing. I’ll probably release this script when I’ve cleaned it up a bit

Anyone sharp eyed will have noticed that the URI for this page has changed slightly, I moved my site to the root directory, just felt like it really. I’m getting a lot of things not working because of this, so email any errors you come across to dougal@shearfx.com. Thanks.

 
 

August 29th 2005

Add your comment

Massive Re-write!

Had a massive re-write of my base code today. The most significant change is the reduction in mySQL database queries on the blog page from a maximum possible of 102 to 2! I can’t quite believe my code was this inefficient. WIll be sure to use the power of SQL in future rather than multiple queries with PHP middlework.

Thanks to Ben for his testing of stuff while I made these changes, and also for testing the swear filter (again!).