I was recently shown this puzzle: There are some things I found a little unclear about it. For example, should the following two circles count as being connected? There is a line between them, even if it’s interrupted by a circle. And what about these two circles? Are they connected? Again, there’s a diagonal line […]
In class-based object-oriented programming, when there are classes that appear to share some functionality, this is often a time when people will refactor them into two subclasses of a common base class, avoiding repetition.
For example, in my farm model the Horse class and the Tractor class each implement a pull_plough method. (American readers might prefer pull_plow.) So this method is a candidate to split out into a Hitchable class for Horse and Tractor to each inherit from.
This would have nice benefits for polymorphism. I’ll be able to pass an object to my Farmer which will only need to check that the object inherits from Hitchable rather than having a hard-coded list of classes like Horse and Tractor that it knows are acceptable. […]
Tonight I've released another alpha version of Cognition, my semantic web parser. Changelog includes: Microformats: Add option (disabled by default) to require <head profile> for microformat support. Microformat profiles are treated as opaque strings! Supports the following profiles: http://purl.org/uF/2008/03/ http://www.w3.org/2006/03/hcard or http://purl.org/uF/hCard/1.0/ http://dannyayers.com/microformats/hcalendar-profile or http://purl.org/uF/hCalendar/1.0/ http://purl.org/uF/hAtom/0.1/ http://purl.org/uF/rel-tag/1.0/ http://purl.org/uF/rel-license/1.0/ No profiles required for rel-enclosure, adr or […]
I’ve searched around the ‘Net for something like this before, but without success, so decided to write my own. The basic idea is this: there are certain circumstances in which you need to write some styled HTML without access to the document’s header. For example, when composing HTML-formatted e-mails, which may be displayed in a […]
Here’s my latest update to dhyana.pl… Change Log Added a title to the output image, which can be in a different font and colour from the rest of the text. Use Getopt to parse command line, and accept more options. Improved handling of certain dodgy WMV files, mostly thanks to Matt Pinkham. Improved use of […]
This release works around errors in capturing screen shots from certain WMV files. It also changes the default geometry from 240Ã180+0+0 to “auto” which is an automatically calculated, hopefully appropriate, geometry. Download dhyana.pl Highlighted source code […]
So, I was looking for a way to create sequential video thumbnails (like this one) from a video file on Linux. I found that my options were severely limited. On Windows there are a plethora of tools capable of this fairly simple task, including Media Player Classic, but on Linux all I could find was […]
PHP lets you define your own error handler, so I decided to get a bit fancy. MegaErrorHandler (MEH) outputs its errors as specially-formatted HTML comments, with the details of the error encoded using JSON. A small client-side script, with an associated stylesheet then pulls this data out of the comments and formats it as a […]
Here’s an example of how to parse an HTML table into an array using the PEAR module XML_HTMLSax3. It supports the , and elements and the rowspan and colspan attributes. It’s worth noting that this code will raise a bunch of notices if you run it displaying all errors. This is pretty difficult to avoid, […]
On Usenet an often-asked question is how to programmatically determine the “domain” of a particular hostname. That is, excluding the components traditionally thought of as subdomains. As an example, groups.google.com and www.google.com both have a domain of google.com. Invariably, one answer comes back stating that you just need to chop off everything from the front, […]