Pastebin clipboard support

Wednesday, 26 April 2006, 22:41

I had a feature suggestion to add a “copy to clipboard” link to pastebin.com. This was easy for IE, but I had a hard time getting Firefox to play ball. There’s an article at MozillaZine covering the issue, but I wasn’t able to get the technique to work. If anyone knows how, let me know!

I know clipboard access is a potential security vulnerability, but Firefox has the right idea in explicitly granting sites access to the clipboard rather than IE’s rather dumb “yeah, clipboard, here you go!” approach.

Anyway, for the time being, a bit of javascript during onload will figure out if your browser can do clipboard copies and will insert a “copy to clipboard” link when you’re looking at a post. Seems like a handy feature.

There’s also been a few bug fixes since the release a few days ago.

Download pastebin.tar.gz (130 KB)

Stop Hacking CSS

Tuesday, 25 April 2006, 9:00

David Shea (the CSS Zen Gardener) urges web designers to stop CSS hacking or be stopped. Nice article from the fledgling Vitamin website.

CSS Zen Garden inspired me to try and do a better job of CSS and semantic markup, I’m hoping to find enough time to make Geograph a whole lot better in that area too. One thing David’s article mentions is the difficulty of testing, but I find the BrowserCam service invaluable. Not only can it take screen captures of a page on many different OS/browser combinations, you can also remotely access some systems via VNC to play with your site for real. Easier than maintaining your own virtual machines or real test kit!

Rocket Commander

Monday, 24 April 2006, 23:45

Rocket Commander is a nice looking Microsoft tutorial to produce a 3D game using C# and DirectX. I don’t have much use for C# at the moment, but this looks like a fun way of kicking the tyres!

Pastebin v0.40 released

Sunday, 23 April 2006, 20:08

There hasn’t been a source release of pastebin.com in over a year, and I promised one in April, and here it is!

There’s no new features yet, just what you see on pastebin.com, but the code has been substantially reworked from the last available release. Source is GPL licenced, if you have any questions, add them as comments to this article in case the answers are of benefit to others…

Download pastebin.tar.gz (130 KB)

Advanced MySQL Replication

Friday, 21 April 2006, 8:45

There’s an interesting article over at ONLamp which covers
Advanced MySQL Replication, covering how to go beyond master-master replication to create a circular cluster of MySQL servers. It includes details on how you can use MySQL 5.1 features to manage automatic failover to remove any failed node from the cluster.

mysqlreport and other useful tools

Thursday, 20 April 2006, 18:33

A colleague pointed me at the Hack MySQL site which has a couple of nice tools available.

  • mysqlreport which can give a nice snapshop of how mysql is performing
  • mysqlsla which will analyse your query logs to tell the frequency of each query, its execution time and an EXPLAIN for each query too.

Interesting site anyway, I’ll stay tuned to its RSS!

UK Geocaching Events on Google Calendar

Tuesday, 18 April 2006, 12:47

I’ve been using the new Google Calendar the past few days and liking it a lot. I’ve created a shared calendar of UK Geocaching Events, to use it, simply search the public calendars for “uk cache events” and add the calendar. The event calendar is also available in iCal and XML formats.

If you spot any errors or omissions, let me know.

Smarty considered harmful

Sunday, 16 April 2006, 10:06

This post by Mike Morgan “Scalable PHP with APC, memcached and LVS (Part 2)” includes the increasingly popular opinion that Smarty is a waste of time.

I’ve used Smarty successfully in the past and been pleased with the result, particularly on Geograph where we need to maintain reasonable code quality with potentially many developers of varying levels. You’re forced to handle the presentation logic separately – a “good thing”.

I believe the primary purpose of any programming language is to communicate ideas and algorithms to other programmers – not computers. In this respect, PHP+Smarty does a good job.

However, while I like it and use it, I recognise one of the main failings of Smarty is debugging – the template is turned into PHP code which really wasn’t meant for human eyes. Single-step through it at your peril.

Pastebin doesn’t use Smarty, but then it only really has one page to display. However, to make it easy to integrate into other sites, it is templatable. It gathers all the data required on a page and then includes a separate php file to format it for display. Simple, yes, but has all the benefits of Smarty with the ability to debug it too.

In a wider sense, what’s really needed are more common patterns of PHP code structure to help push better practices out there. Getting smart without Smarty. The Zend Framework includes a Zend_Controller set of classes, which aid in adopting an MVC pattern. Too early to say whether it will take off, but it’s a good effort.

Maybe I should just switch to Ruby on Rails. It’s got everything I want, I’m just waiting for the right project to give it a decent crack of the whip…

PHP and Eclipse

Saturday, 15 April 2006, 11:16

Lukas Smith recently wrote about the development processes surrounding Zend’s planned Eclipse-based IDE.

I never really understood why Zend have duplicated the existing PHPEclipse effort, but Lukas’s post shed a little light on it. It’s certainly a shame that they don’t appear to have fully embraced the community element of open source development, but in the long run, a competing project might be good thing.

Every few months I give PHPEclipse a try. It looks great, but last time around a few minor bugs stopped it becoming my primary IDE. I submitted a bug report and the developers checked in a fix to CVS and I’ve been eagerly awaiting the next release ever since. Version 1.18 was released last week and I can’t wait to see if it’s ready for me to make the switch!

What I particularly liked with PHPEclipse was the live preview pane, where you can have the IDE request the file you are editing from the webserver. Great for front end UI work obviously, but even better when you’re developing a class. With a bit of effort, you can can configure your server to run a unit test for you. Edit, save, see test result….edit, save, see test result, doesn’t that sound great?

Whenever I do a little C++ development I use Microsoft Visual Studio, which is a fantastic IDE. It always leaves me hungry for the same features in my PHP environment. When you write C++, using the debugger is the norm, whereas in PHP, developers reach for a debugger as the very last resort (if at all). Hopefully things are a-changing…

Geograph Guppy

Friday, 14 April 2006, 11:53

Geograph is taking a bit a hammering at the moment, which is frustrating for all those trying to submit new photos. A few months back I started working on a desktop application codenamed Guppy (”Geograph Uploader”) which would let you queue up your submissions quickly, which the application would then upload for you while you did other things.

Looks like it’s time I completed it!

I’m writing the software in C++ using the wxWidgets GUI framework. This should (hopefully) mean I can produce a Mac version fairly easily. So far so good – I’ve not used a single Win32 API, which bodes well.