Archive for the ‘Writing Software’ Category

Reggy for regular expression testing

Saturday, June 7th, 2008

Handy new tool I came across today which allows you to test regular expressions and see what they select.

Reggy

Flash CS3 - Trace not producing output?

Friday, March 14th, 2008

Found an odd problem with Flash CS3 today. I was working away and I realised that I wasn’t getting anything in the output window from calls to trace().

Just a completely empty output panel.

The answer is simple, make sure Filter Level is set to verbose in the menu on the output panel. If you have it set to None then you won’t get any output.

I’m not quite sure if this is something that I changed or if it is the default, but it isn’t exactly obvious.

XML, UTF-8 and Java

Monday, August 27th, 2007

Apparently, valid UTF-8 strings aren’t necessarily valid XML. You can get a situation where you have valid UTF-8 strings which fail xml parsing.

Fortunately Mark McLaren offers a solution.

HTMLValidator 1.0

Tuesday, August 7th, 2007

HTMLValidator 1.0 is finally released.

As I write this, it’s been out since Friday, so I guess I’m a bit late in writing this. HTMLValidator 1.0 is identical to HTMLValidator 1.0b8, except of course that it 1) doesn’t expire and 2) asks for registration.

The first non-beta release seems to have gone reasonably well. People are downloading it, trying it and some are starting to buy it. (If you’re reading this, then thank you!).

Oddly enough the most difficult thing about the whole thing was making sure that the order processing system could correctly deal with more than one product. We have a system that interfaces with our payment provider and it handles logging orders and generating serial codes. When it was originally written, HTMLValidator didn’t exist, we sold only one product and there wasn’t really a plan to develop others; So there were several areas that assumed that was only one product. The lesson here is to assume that you’re going to expand and plan accordingly.

Work has already started on the next release of HTMLValidator. The main areas for improvement are speed and memory usage. Plus there are some improvements to validation that the W3C released in their version 0.80 code release that would be nice to have in HTMLValidator. (Which is of course based on the W3C validator).

If you want to try HTMLValidator then we have a page that tells you all about it.

[HTMLValidator]

building antlr 2.7.7 on Mac OS X

Saturday, April 28th, 2007

It appears that antlr on Mac os x doesn’t like the jikes compiler, at least when I tried building antlr it gave lots of weird compile errors like this:
Found 2 semantic errors compiling "ANTLRException.java":

While it would be a good thing to try to fix the actual code, it’s easier to see if the solution is already available.

The answer came in this posting which suggests renaming jikes before building. Which works, but there is an easier way. Just declare an environment variable before starting the build.


export JAVAC=javac
./configure
make

Changing the java compiler that gets used is documented in the configure script.

Java class file version numbering

Saturday, April 21st, 2007

http://alumnus.caltech.edu/~leif/opensource/bcver/BcVerApp.html

This page has a list which shows how java class version numbers relate to java platform version numbering. It’s useful if you get one of those UnsupportedClassVersionError errors.

This relates to the Java ClassFile structure which defines how classes are represented.

Linux autologin

Wednesday, February 21st, 2007

I use a collection of virtual machines in parallels for a number of things, like testing SQLEditor and running web apps that would otherwise require lots of software dependencies. However I’ve been getting tired of logging in to my linux virtual machines all the time. If it were just a case of ssh then obviously I could set up ssh key pairs and do auto-login, but I also need direct terminal access too, in this case in the main parallels window.

With a physical machine to get autologin in this situation would mean that the machine would boot and immediately log the user in without interaction.

Important Warning

This represents some security risk. You need to consider your circumstances carefully first to ensure that this will not open your machine to malicious use.

(Of course there is always the point that if someone has physical access to your machine then there’s not much hope anyway. But still …)

Fortunately this is possible and actually quite easy if you don’t mind editing a configuration file.

The file you need is /etc/inittab

Important Warning (2)

/etc/inittab is vital to the operation of your machine. Incorrect editing will cause a number of problems.

If you are making these changes to a virtual machine simply make another. Alternatively try logging in via ssh to undo the changes.

The change you need to make is to find the line that looks like:

1:2345:respawn:/sbin/mingetty tty1

and change it to look like this (where username is the user that you want to autologin as)

1:2345:respawn:/sbin/mingetty --autologin username tty1

The original source of this is EasyMameCab; which looks like a clever idea in itself. They are using linux as the base system for building a video game cabinet, so obviously they don’t want logins appearing.

MacFuse released - userspace Mac OS X file systems

Friday, January 12th, 2007

I just noticed this announcement on the google mac blog.

Amit Singh has released a mac version of Fuse, which is way for people to write interesting extensions to the file system without writing kernel code. The way it works (as I understand it) is that the Fuse system runs one kernel module which communicates with the actual file system code in userspace.

It looks really clever and there are already a number of useful file systems available for fuse (including ssh as a filesystem and a ntfs driver).
[link]

Writing Unit tests for Cocoa

Wednesday, November 15th, 2006

I realized something interesting today.

I use unit testing to (hopefully) improve the quality of my code.

With Java I use JUnit. With native Mac stuff I use OCUnit.

One really clever thing about OCUnit that I realized today is that if you have several SenTestCase subclasses, each with multiple tests in it, you can put all of them into one XCode target and OCUnit will automatically run them as suites in one test run. This means that you get a summary of all of the tests at the end.

Previously I had a separate XCode target for each test case, where each test case class reported its results separately, which isn’t nearly as good.

Crash with WSMethodInvocationInvoke and malformed XML

Tuesday, December 27th, 2005

I’ve been doing some stuff recently with XMLRPC for both SQLEditor and an unannounced new product.

One of the key parts of XMLRPC in cocoa is the Apple web services Core. It provides almost everything you need to use web services.

However I did discover one oddity that led to some puzzelment

As part of my development I’d written a test server in php which operates a few simple functions that the client can try. This means that I can simulate various commands and cause intentional failures to see what happens. I also have a php client to check the server independently.

I had been making alterations to check a particular function in the client worked correctly. It was a new function that provided an array of values that could be placed into a menu on the client. The idea seemed sounds, the design had been worked out and new functionality had been added to both client and server. The server seemed to work fine with its test client and I was ready to try my main client application.

Unfortunately it either crashed or generated an exception on every call to WSMethodInvocationInvoke. Initally I assumed that it was a bug with my client application, perhaps I’d passed in the wrong arguments or made a mistake in setting up the context for the call.

However after some testing of various possibilities I discovered what seems to be the actual cause.

One of the included php files contained an extra new line character at the top before the doctype.

Removing this extra new line solved the problem
(presumably because it was now valid XML).

Moral of this story:

XMLRPC implementations and XML parsers are not always very forgiving of whitespace at the top.

Interestingly, the xml parser in camino doesn’t like xml files with extra lines at the top either.

I’m still looking to see if there is some setting that can be changed to make the parser more forgiving, or to pre-process the xml first.

(I’ll be reporting this issue as soon as I can produce a suitable test case)

Forum for malcolmhardie.com

Monday, June 27th, 2005

Following the suggestions in this article, I’ve been considering forum software recently to offer customers (and others) somewhere to discuss SQLEditor.

Currently I’m considering PunBB, because it seems to be simple, fast and well received by reviewers and users.

PhpBB seems a popular choice but is probably a bit more than I actually need for this project.

flyspray subversion integration

Saturday, February 12th, 2005

Somebody asked me to post a link to the script that integrates flyspray and subversion:

Script is Attached to Bug 301

DocBook and Apple Help

Monday, November 15th, 2004

One of the key tools I’ve been using recently is Docbook. Docbook is an xml-schema which can be used to write documentation for things. This can then be converted via the wonders of XSL, XML and XML-FO processors into PDF, HTML or several other formats. I’ve written all of the documentation for SQLEditor using docbook and it is really handy. Slightly verbose, but really handy.

Unfortunately at the moment there doesn’t seem to be an Apple Help stylesheet for docbook. Since one of my targets is Apple Help this is slightly unfortunate, but I suppose in time either I can write one or someone else will. In the meantime, I’m using the microsoft help stylesheet and altering the results a bit to work with Apple Help.

Docbook is definitely a handy tool for documentation though. I wish I had discovered it earlier.

SQLEditor released!

Monday, November 15th, 2004

After a rather over-extended development cycle SQLEditor version 1.0 has now been released. Which is a great relief to me. I’ve been working on it for so long now that I can’t quite remember not working on it, which is weird. Admittedly that’s only really about 12 months, but still, it’s a significant portion of my life. It’s also the first major product I’ve released.

In a moment of commercialism I would encourage you to buy a copy because it makes a wonderful christmas gift, or at least it might if the recipient really loved databases or if it was some other kind of program altogether. As it is, it probably wouldn’t make much of a Christmas gift. Socks or bottles of wine would be a better choice for almost anyone.

Releasing SQLEditor isn’t the end of the situation though. Version 1.1 is already being planned and I’ve various other projects that I’m working on as well, but SQLEditor is first and will always be the first piece of software that I released for sale.

Releasing software is complicated. In addition to the actual program, there is the distribution package, online help, the website, notifications to trackers like MacUpdate and Versiontracker, plus checking the online store is working correctly. Bad news with this release for anyone hoping for the pre-release discount. With the release of version 1.0 the offer expired.

People keep talking about MacPAD but nothing seems to be happening at the moment, only MacShareware.net seems to be supporting it (which is logical, since the two are quite closely tied together). I’ve got a MacPAD file up now, but nothing much else. I haven’t integrated it with the release managment stuff I’ve written (a motley collection of php and make files with a bit of XML for good measure).

If there was any market in it there is an interesting opportunity for a release management system (written perhaps in java?) that could generate everything automatically. Perhaps if I get really bored at some point I might do that.

The next step is to write a press release and send it out today. Joy :-(

So, in conclusion, if you haven’t already tried SQLEditor, then version 1.0 will improve your life so much that you won’t know how you got by without it. Or at least might save some time when designing SQL databases.

Writing Documentation

Thursday, November 11th, 2004

I’m currently in the middle of writing user documentation of SQLEditor. I finally settled on docbook as the format of choice since it seems the most compatible with other things.
I’m using this tutorial to build the stuff although saxon has now made it into darwinports which is nice.
http://www.boksa.de/tutorials/docbook_macosx.mpp

Integrate flyspray with CVSWeb

Saturday, October 23rd, 2004

Currently I’m using flyspray for bug tracking.
I use cvsweb to view the cvs tree online.

One thing that I really wanted was to be able to click one bug numbers in the cvs log reports and see the bug tracking entry that matches it.
It turns out this is amazingly simple. I added the following code to the cvsweb.cgi file inside the htmlify function, just below the bit that does the urls. (new section in bold)

# get URL's as link
s{
((https?|ftp)://.+?)([s']|&(quot|[lg]t);)
}{
&link($1, htmlunquote($1)) . $3
}egx;


# replace FS with correct bug track link in flyspray
s{
FS#([0-9]+)
}{
&link(”[$1]“,”/flyspray/index.php?do=details&id=$1″)
}egx;


# get e-mails as link

And now my cvs logs display a link whenever I use FS#100 or a similar bug number. Next I suppose is to integrate it the other way and have the cvs system automatically close resolved issues in flyspray. There is actually already some code for subversion so it wouldn’t be very hard to implement probably (but there are better things to do with my time).

[edit]
subversion code is at http://flyspray.rocks.cc/bts/index.php?do=details&id=310&area=attachments#tabs

Java FileWriter, XML and UTF-8

Saturday, October 23rd, 2004

Oddly enough the java.io.FileWriter class doesn’t use UTF-8 by default. I’m not exactly sure what the default encoding is (possibly ISO-8859-1 or US-ASCII?) but it doesn’t seem to be UTF-8, which is odd given that java strings are supposed to be unicode. This causes a problem if you want to have non-ascii characters and you don’t realise what’s happening. This was a bug in SQLEditor and somebody accidentally typed an umlaut into one of the fields and the file wouldn’t reload. (Which was annoying).

The correct thing to do seems to be to use the following:

OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(path),"UTF-8");

Which ensures that you are using UTF-8.

I suppose that the motivation for this is that it means that simple use of FileWriter is compatible with applications that are not unicode aware and don’t support UTF-8. It probably makes sense at some level, but it just goes to show that you can’t assume anything. :-)

Cocoa#

Sunday, October 10th, 2004

I’ve been playing around a bit recently with mono and cocoa#.

There also seems to be an experimental build of Mono-develop.

I begin to think that .net and mono are going to be excellent java competitors. I also think that the idea of supporting platform differences makes more sense than the java swing approach of lowest-common-denominator functionality.

I started off SQLEditor in java swing and then switched to cocoa. I wonder if there will eventually be another rewrite to mono and .net?

Online Store

Tuesday, September 14th, 2004

I’ve been working recently on integrating a registration system into SQLEditor (sorry).

Unfortunately I kind of need to make some money out of my software and so people have to pay for it. I really wish this wasn’t the case but sadly it is.

So I now have an online store powered by swreg. If you visit the SQLEditor page you will now see a couple of purchasing options in the right column and further options are an a subsequent screen. It looks fairly close to the rest of the site and swreg offers better fraud prevention than paypal, particularly for credit cards.

The complexities of integrating everything together are quite great, which suprised me a bit. I was hoping for something easy, but it required a lot of steps to get everything pretty much working.

  • Sign up to online store
  • Add products
  • Create templates for shopping basket
  • Create serial number system
  • integrate serial number system into application and online store

Although I won’t need to do this for any future software that I develop. Most of it was a one-off cost.

One oddity is that the serial number code is written in ANSI C. This is a bit odd, because most of the code that I have been writing recently has been either Objective C, Java or PHP. But ANSI C proved to be the best way of using the same codebase for both the server and client side components.

Hopefully lots of people will love and therefore buy the licenses.

Serial Number Systems

Thursday, September 2nd, 2004

I’ve recently been trying to write a serial number system for SQLEditor. I’m also looking for a new name for it. It was pointed out that the current name is generic and difficulty to pronounce, plus there is already at least one other “SQLEditor” out there already. Suggestions are welcome!

But back to the serial number thing. If I could remember more of the maths that I learnt at university I would be happier, but as I tend to do I had forgotten most of the stuff that I don’t use, retaining only the bits I do use (Vectors primarily, plus some other stuff).

Obviously serial number values end up in base 36 (0-9, A-Z), but other than that the problem occurred on how exactly to represent them. I need to have a link between the username and the serial number because that’s one of the methods implemented to discourage copying. If you see someone else’s name on the thing.

I’m currently looking at a graphic convertor like delay (it will wait 20 or 30 seconds at startup after the trial period is ended) rather than a complete lockout. Because I think (a) it’s nicer to do it that way and (b) it offers people a chance to experience the feature set even after 30 days have expired.

One thing I have noticed is that there are very few descriptions of how serial number systems actually work, probably to prevent people reverse engineering them and creating generators.

Of course the most secure system is one that receives a license key directly from a server, but I think that could be too intrusive. I guess we’ll see how well the first version works out.

New features for Beta 7 include “crows-feet” style referential cardinality indication and a new way of exporting foreign keys; following a suggestion they will be placed after the tables as soon as I write the code anyway, the parser is already capable, but the exporter is not.

Finally Beta 7 will also offer selectable colors on the fields, more transparency and prettier connector drawing. Possibly also table type for mysql as well as a new export system for creating databases via scripts on remote servers. More later.