UI Guidelines (apps)

As I’ve been through most of these at one point or another, and finding them is a pain in the ass:

I’m of course still stuck with a PalmOS 4 handheld, so the pre PalmOS6 docs are what I refer to the most. I have no real motivation to buy another handheld when they’re looking like the entire market is going to be eaten by micro PCs like the OQO.
[links edited, text slightly changed 2005-10-14]

Corrupt oracle tables

The brother has a problem today, his dispensing system kept keeling over when he dispensed to some people, but not to others.
Firing up the utility which is what all normal pharmacy people would have had access to would only show that the system failed to validate a table, and that the connection to the database was broken. The only clue I had was the table name that I last saw in the utility. I’ll just say from the get-go that this is Not good diagnostic programming practice.
Firing up the SQLPlus worksheet, I ran the ANALYZE TABLE <foo> VALIDATE command over the table, and saw no error. I ran it with the CASCADE, option and the same thing happened as the utility – the database fell over.
It turns out that one of the indexes was corrupt on the table. Iterating over all the indexes using ALTER INDEX <foo> rebuild, which narrowed down the indexes. Then I extracted the DDL for the index, dropped and recreated them, re-validated the table and everything was hunky dory.
Full documentation on the ANALYZE command is in the oracle documentation. For the purposes of this exercise we used ANALYZE TABLE BLOB VALIDATE CASCADE to see the error.
Solving the problem took about an hour, most of which was spent chewing on a sandwich and booking tickets to see Star Wars, and of course cardboard programming by another friend. A backup of the database would not have helped in this case as the corruption occurred silently some time ago, and was only uncovered when certain customer’s records were accessed, so the loss of all the data input from the point of corruption to then would have been unacceptable.

C++ version

Well, I got bored enough to do this too. It’s a C++ version. It was compiled using visual studio.NET. It’s unicode aware, using the proper API’s, and it’s a bit longer than the Delphi version.
The first thing you notice is that the C++ binary is smaller than the Delphi binary. There’s a lot of framework code in the Delphi application that isn’t in the C++ application.
Apart from that, the code is virtually identical.

Saving desktop Icons

After another annoying rearrangement of my icons, I wrote this small Delphi class (and corresponding program). SaveIcons takes either a parameter save or restore and just either saves or restores the icons. it’s a zip file containing the program and source and is released under the GPL.
I’ll probably get around to writing it in C++ as well – delphi was a pain creating all those messages, and it’s not Unicode aware.

Continue reading “Saving desktop Icons”

Blog Modifications

I decided to make a few changes in the blog. The first thing I did was made the comments appearable in-line. It required a few changes in the moveable type back-end.
I needed to add the ability to strip extraneous bits from the comment.cgi form. This was accomplished with a ‘raw’ parameter, that allowed it to remove code that fell within a <COOKED></COOKED> pair of tags. I also added in a ‘redir’ tag. This allows it to rediret the page somewhere other than the default redirect page – namely back to the homepage instead of back to the comments page as it is by default.
I was greedy, and wanted to add the ability to control output if there already were comments, so I added the <MTEntryIfHasComments> tag, which works quite nicely. I may need to add an inverse to this. This allows me to have entries on the main page that read Comments or Comments (<Number>)
Finally, and slightly annoyingly, I had to add a redirect to the proper hostname of my website, as the XMLHttpRequest open operator will not operate correctly cross domains (security feature for unsigned scripts). I have no intention of signing my scripts, so a simple javascript redirect is in place there.
Mozilla throws an exception if you try to cross-site execute and XMLHttpRequest, IE does a security confirmation and Konqueror (and probably safari) simply ignore the open request. annoying, but I suppose the have a point.
Things learned at this point

  • XMLHttpRequest rocks!
  • MT is a bit of a pain to customize
  • IE caches more than it should – I can’t get the comments to reload.

Network printers and big print jobs

Hmmm, strange one this. We have print jobs that are actually a batch of documents sent to the printer over the standard print spooling mechanism of Windows 2003. The problem is that the printers are network printers, so they can be stolen between documents by other machines feeding to the same printer.
How do we fix this?
Windows does not seem to be providing us with a way of doing this. There is no way of specifying that all the jobs need to be printed at once. Getting a lock on the printer seems impossible – they’re designed to just be dropped into the network taking the jobs as they’re being fed to it.
Potential solutions:

  • Remote queues per printer – spool jobs for each printer on the single machine. This cuts down on the scalability of the system, but it’s probably the quickest fix
  • Combine all the separate documents into the one print job and send that to the printer. Requires no reconfiguration of the printer queues. Means we have to concatenate all the jobs from the batch into the one file. This is ok, as weve got PDFs and there are a multitude of programs around that allow us to concatenate them.

Anyone have anything else like this happen to them and how did they solve it?

Makefiles and VPATH

Ok,
Time for a little bit of programming trickery – this one related to makefiles and the fun of VPATH. One of the projects I was working on used the VPATH feature to build the code for each version in a subdirectory. That meant that you can have one makefile for any version, and simply include the delta makefile which contained all the conditional compilation work. The problem with this is that you need to write the makefile carefully, otherwise you can’t take advantage of this feature.
When you write a makefile rule you end up with something resembling:

target: dep1.c dep2.h
   $(CC) $(CFLAGS) -o target dep1.c

The rule itself is fine, the problem is that the build command will mess up when executed on a relative path build. The make tool cannot change the target and dep1.c entries to match the locations of the files in the build command; It’s not been given the ability to parse shell scripts. You need to use the correct variable syntax.
Firstly, we never use the absolute target name in a build – that’s really effing stupid – after all if we change the name of the target every other entry needs changing. What we use is the $@ variable – this is expanded at run time to match the target name – it means less typing, and less chance of an error.
The Second change is to replace the dep1.c with $<, this means take the first dependency of the rule, and as this is a vpath substitutable entry, this gets replaced with wherever the dep1.c is found.
I’ve been experimenting with this on a linux box and it works exactly as advertised for the gmake. I’ve not tested it recently on Solaris for svr make, I know there is a different semantic to $lt; there.

traps and shells

UNIX has signals, various signals. When you’re working on shell scripts, you may need to intercept and deal with them. The syntax for intercepting signals is the trap action SIG1 … SIGN, where depending on your shell the SIG1…SIGN may be specified as an integer (bourne shell, i.e. raw sh), or symbolically as HUP, TERM (ksh, bash, zsh). Of course those of you using csh and tcsh should get a real shell 🙂.

Continue reading “traps and shells”

Input fields of evil

Ok, ok I realize that this is more of a bloody rant than an actual programming thing, but what’s the problem with dealing with input fields properly? Take for example inputting credit card numbers. Type it into a text field, but the program complains that it’s wrong. What’s the problem? you used a space! An effing space! why the hell doesn’t it just strip the bloody space out of the input before processing it? but noooooooooo that would involve another one fucking line of code to fix such a complicated input condition as that.
Then let’s not talk about phone numbers! for fucking christ sake what is it with people and their insistence that you use the ‘proper’ format – XXX-XXXX noone in their right mind uses this format.
If the number is preceeded with a plus (+) it’s a fucking country code prefix … like every other goddamn country on the planet … but of course this does not work in the fucking U S of A, oh no, when I visit I have to fix all the numbers I call because some dumb fucking stupid motherfucking telephone engineer can’t deal with a proper mutherfucking phone number.
Other than that get rid of every other fucking non-numeric entity in the phone number. How hard is that? I mean really! Lazy fucking programmers! I’m a programmer myself and I hate it when I encounter UI disasters like that. It’s not difficult to write something that makes people more likely to use your system.

#define evil

It’s funny to see things defined as nothing, so they are ignored. Aparently for nice-reading code. This gives me some good ideas; you could do:

#define please
#define also
#define thanks
#define let

then you can write code like:

also please let a = 1 thanks