Using CSS to underline text in a textbox

As used in SharePoint 2007 – putting a red wavy line below text in a text box. Neat.

Just in case I ever need this (and the page goes missing):

<style>
.squiggle
{
background-image:url("squiggle.gif");
background-repeat:repeat-x;
background-position:left bottom;
padding-bottom:2px;
vertical-align:text-top;
font-style:italic;
}
.container
{
border:1px solid #a5a5a5;
overflow-x: hidden;
width: 100%;
color: windowtext;
height: 18px;
background-color: window
}
</style>
<div class="container" contenteditable="true" tabindex="0">
<span class="squiggle" contenteditable="false" tabindex="-1">
<div style="DISPLAY: none" displaytext="here"></div>
<span contenteditable="true" tabindex="-1">unresolved!</span>
</span>
</div>

Using CSS to underline text in a textbox

Getting the Public Key Token without copying things into the GAC

1) Create your Key pair, as per normal. Typically, this can be done as:
Sn.exe -k PublicPrivateKeyPair.snk
This will create a file containing both keys.

2) Extract the public key:
Sn.exe -p PublicPrivateKeyPair.snk PublicOnly.snk

3) Calculate the token. Note that the ‘-t’ parameter MUST be lower case (‘-T’ does something different)
Sn.exe -t 'PublicOnly.snk'
And there you have the public key token

Getting the Public Key Token without copying things into the GAC

More about frozen panes…

So, I’ve been working with ‘Frozen’ panes in tables in HTML. The problem is, some of these tables are, well, a little big. Like maybe 100 cells square. I found that the technique mentioned earlier in my blog didn’t work very well, as the scrolling on the DIV tag became slow and jerky.

This makes sense really – each cell is having it’s CSS rerun each time. Then it struck me – the styles were defined as:

td.frozen {
padding: 3px;
position:relative;
top: expression(document.getElementById('pane').scrollTop-2); /*IE5+ only*/
z-index: 5;
}

This mean that ‘getElementById’ was being run repeatedly. However, the style’s JavaScript was being run before ‘onload’. I just couldn’t run the ‘getElementById’ to populate a global variable after the element had been created, but before the style expressions were run. Instead, in a moment of clarity, I changed the style to:

td.frozen {
padding: 3px;
position:relative;
top: expression(getPane().scrollTop-2); /*IE5+ only*/
z-index: 5;
}

And added a script:

var pane;

function getPane() {
if( pane == null ) {
pane = document.getElementById(“pane”);
}
return pane;
}

Thus, we only run getElementByID once – the first time a CSS style’s javascript expression is run. This worked – the DIV tag now scrolls much more quickly, certainly not so as users will notice any lag.

More about frozen panes…

"malformed header from script"

So, in testing simplyXiangqi, I found I was getting error pages when I tried certain actions. The actions seemed to happen okay, but I got the standard Rail ‘Application Error’.

Looking in the logs, I was getting an error ‘malformed header from script’. ‘Curious’, I thought. The full error was of the form:
malformed header from script. Bad header=isRed = 1:
/home/simplyxi/public_html/dispatch.cgi

It seemed to me that part of my code was appearing as a header when the page was returned.

Eventually, I figured it out. My code still had ‘puts()’ calls in it. I’d added these for debugging during development on WebBrick. In WebBrick, the strings output by ‘puts()’ were written to the command window WebBrick was running under. On my Apache installation, though, this was output as a header. Consequently, I got errors.

I removed the ‘puts’ calls, and it all worked fine.

Comments from my old blog:

Thanks, buddy. Saved my sorry ass. 🙂

By Magnus Bergmark at 18:07:07 Saturday 29th September 2007

"malformed header from script"

Dispatch.cgi and End of File Characters

So, I was setting up my Chinese Chess site (domain name might not have propagated yet), and I had some problems. I kept getting the error ‘Application error: Rails application failed to start properly’. Looking in the logs the error was “Premature end of script headers: dispatch.cgi”. Tracked this down to the Dispatch.cgi file through Google, where other folks seem to have had problems with the EOF character.

I couldn’t figure out how to delete these characters – why is it that ‘vi’ is so popular? – so what I did in the end was create a new rails app and copy the cgi files across into my app. The files, although they appeared to have the same text, had very different file sizes.

Anyway, that seemed to do the trick.

Dispatch.cgi and End of File Characters

Bespoke Software

Cost aside, given the choice between a suit ‘off the shelf’ and one ‘made to measure’ in Saville Row, most people would go for tailored suit every time. So why doesn’t that happen in software?

Okay, so I know I just made that comparison so that it wasn’t like-for-like by excluding cost, but it seems to me that tailors are a good analogy – and that the shopping habits of the well dressed man and the well equiped company are quite different.

Consider the suit. You can buy one ‘off the shelf’. It won’t fit as well as one made specially for you, but it might fit well enough. Sure, the legs might be a little long, and it’s a little broad across the back, but hey, it’s a lot cheaper.

Another option would be to get a bespoke suit. Bespoke it a wonderful word that makes me think of bicycles, but here I mean it as ‘made to measure’. You suit will be unique, comfortable and well fitting, and it’ll cost much, much more. I know I’ll have made it when I get a bespoke suit.

The third option is to get the cheap suit, and have some alterations done. That is, you get someone to make small changes to the cheaper suit, so you get a better fit, and it still costs less.

Software is the same. It can be made for you, you can buy it off the shelf, or you can buy it and hack it until it does what you want it to. (I mean ‘hack’ in the old school way, not the illegal way).

Most people, when they buy suits, just keep shopping until they find one that fits. The luck few (or those unlucky enough to have unusual measurements) get them made for them.

Companies and software doesn’t seem to be the same though. They’re in all shapes and sizes, and as profitability often depends on good software enabling your processes, they all want suits that fit very, very well.

Lucky companies can find a bit of software that fits just perfectly, and within specialised fields, there are products like that. This is great – the suit is cheap and fits well. However, most companies have oddities that mean, for certain applications, no software fits very well. I guess, companies have less regular measurements than people.

So, now they’ve got a choice – bespoke, or get something and customise it. Actually, here the analogy breaks down a bit – there is a third option. Some software is built to be highly flexible and adaptable, so that it can fit many jobs. I kind of think of this as a ‘shrink to fit’ suit – I know, it’s straining. Humour me.

Okay, so, imagine we get some software and decide to customise it. Customisation costs, and it means that what you’ve got isn’t exactly the same as anyone else. You need someone to figure out what needs done, and make the changes for you. The constraints of the system can make some of those changes hard. Indeed, if the software fits poorly enough, you can end up having to rip the whole thing apart and rebuild it to do what you wanted to (Been there, done that). Indeed, you might as well have had it made bespoke.

Alternatively, you could use a ‘shrink to fit’ option. I think Microsoft SharePoint 2007 is a great example of that. It’s very flexible, with all sorts of neat bells and whistles, so it will fit many, many different needs. The problem is configuring it, shrinking it so that it fits well is also made very hard by this. Again, you’re into the realms of needing a specialist to help you. And you might not even need all those bells and whistles. At the end of it all, it could be as bad as having someone dismantle it.

So finally, we come to bespoke. You get someone to make it specifically for you. It does the what you want it to, and only that. You’re not paying for bells and whistles, and as it is designed to do just what it does, it is simpler than the other options. Sure, the tailors costs are a little scary – but done right, you don’t get all sorts of extra cost creep in later.

I keep ‘seeing’ bespoke solutions. I’m not working on them – I’m probably hacking around with some third-party application again, trying to make it do what the customer wants – and this vision comes into mind of what I could build to solve just that problem. Normally, they solve just a single problem – but do that well. And I wish I could do them. It seems to me that development is become faster, and frameworks are becoming better. Look at Ruby on Rails – it gives so much for free, you can really build an application quickly in it. Even (though I hate to admit it) Visual Studio can give you a lot, sometimes – although it is collapsing under the weight of trying to be all things to all people.

So my question is this – why do companies seem so keen to stay away from an application that just does what they need it to, and yet happy to buy something off-the-shelf and then have to change it to do what they want it to?

I guess I’ll consider that later…

Bespoke Software

Why Geeks shouldn't write Documentation…

Just came across this paragraphy in some of the documentation for Windows Workflow Foundation. The first sentence is okay, but it goes downhill from there…

Workflow Task Content Types

By default, all SharePoint task types are assigned content types. If you do not specifically assign a content type to a task type, the task type uses the Task base content type. All task-type content types must be based on the Task base content type.

WTF?

Why Geeks shouldn't write Documentation…

Advice to American IT writers

When you say ‘soup-to-nuts’, we don’t know what it means. Frankly, it sounds like a potentially painful accident (depending on the temperature of the soup).

I looked it up. It means ‘end-to-end’. Why not use ‘end-to-end’ then? We all need to avoid strange localisms in our language. I mean, I’ve never finished a meal with nuts. Cheese or coffee, yes, but never nuts.

And the word ‘doable’ is not a word – we’ve already got a word for that anyway, and it is possible.

I’m guilty too – I used “elephant in the room” for a bit of humour. Completely confused my Zimbabwean colleague with that phrase. Presumably, elephants in rooms really was more of a problem for him.

Advice to American IT writers