Archive for the ‘Writing Software’ Category

Big changes to Mac Developer Program

Friday, March 5th, 2010

Apple have rearranged their Mac developer program so that it now costs only $99 and seems to have only one paid variant rather than the three previously available. (Student, Select, Premier). The online only variant is still available and still free of charge.

It appears that this is possibly influenced by the amazing success of the iPhone developer program, which is also $99.

Anything that makes it easier and cheaper for developers to develop applications is probably a good thing. Although obviously you only need this developer program if you need access to pre-releases of Mac OS X and the other benefits it provides. It isn’t now and never has been a required purchase.

They’re still upgrading the sites as I write this, so I haven’t seen all of the details yet, but definitely looking good.

[edited to correct information about the free online program]

Rails Migrations and Schemas

Friday, February 26th, 2010
  • A schema.rb file is typically a ruby script containing a call to the ActiveRecord::Schema.define method.
  • A rails migration is a ruby class which inherits from ActiveRecord::Migration and contains a method called up

The useful fact that I realized only after doing some ultimately unnecessary work today is that because the schema file contains a method call, it’s actually easier to extract the information from it than with a migration (which needs SQLEditor to figure out a class name and then call the up method)

Hopefully this new work will appear soon in SQLEditor

XCode function popup

Thursday, October 16th, 2008

I love the XCode function popup, particularly in Objective C, because I can add #pragma mark comments to divide up the list.

Unfortunately languages that aren’t C derived don’t offer #pragma, so I missed these little dividers

Then I noticed that a comment that contained FIXME had appeared in the list too, looking just as if it were a #pragma mark entry

Looking at the XCode documentation reveals that XCode will also search code comments for a range of keywords and use them to control entries in the function popup. And it will do this for Java, Perl, Python, and Ruby (as well as the C based C, Objective-C and C++).

This means I can write in other interesting languages and still get my function popup dividers.

Just prefix the comment line with one of the following:

  • MARK:
  • TODO:
  • FIXME:
  • !!!:
  • ???

and the remainder of that line will appear in the list.

There is more in the Apple Xcode tools documentation

(It looks like there has been some discussion of this already (1,2,3)

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. :-)

Update: Bela’s comment (below) explains more about which character set you’ll actually get.