Category Archives: Code

The logo doesn’t make it secure

http://www.greatreads.com.au/the7deadlysins/competition1.htm

See the protocol on the front? On the page, net to the big verisign logo:

We guarantee that every transaction you make on our website will be safe. Our secure server software (SSL) is the best software available today for secure commerce transactions. It encrypts all of your personal information, including credit card number, name, and address, so that it cannot be read as the information travels over the Internet. When an order is received, SSL is again used to unscramble the message, check that it came from the correct sender, and verify that it has

Has what? It’s a mystery.

What is it with these half-baked web pages?

They never learn

Webform, major financial group. I entered my phone number, only to be presented with an error message:

Contact Number is invalid. Contact Number can contain only numeric digits. There is no need to include a country code.

My crime? Putting in spaces. Heaven forbid that the computer strip them out again.

ANZ computerised banking is user-hostile

I have an ANZ Bank account. Using their website to pay bills is an exercise in frustration. I only have one account, but the website insists on me picking it out of a dropdown with two entries – the first one, the default, instructing me to pick an account. Failure to do so results in an error – “Please choose a From Account.” I only have ONE! Assume that’s where I want to pay from! Then one must pick who to pay, with an option to pick previous billers from a drop-down list. If you pick from the dropdown without JavaScript enabled, you get the error “Please select a biller from the drop-down list or enter a biller code.” – with JavaScript it fills in a few fields for you, but why does it even need you to fill those fields in if you’ve picked your biller already? Fill them in when I click the “I’m done” button!

Finally, we come to a bugbear I have with ANZ currency fields. You can’t enter a dollar amount, it has to include a decimal point with two following cents; they can’t infer from a lack of a decimal point you’re talking about a dollar amount. They enforce this rule on their website, and they insist that at an ATM you enter the number of cents you wish to withdraw from the ATM. Given the smallest unit of currency available from an ATM is $20, what is wrong with this picture?

How to do null dates in database queries in VB.Net

They do make you jump through some hoops, but I think I’ve got it worked out.

Dim dYourDateField As Nullable(Of Date)

…then you either set it to be a date (using DateSerial or CDate or whatever, or you set it to Nothing.

Then when you’re using it in a database query, the parameter can be set like this:

oCmd.Parameters.Add(“@YourDateField”, System.Data.OleDb.OleDbType.DBDate).Value = dYourDateField

That’s it. At least, it seems to work okay for me. Touch wood. Apparently it should be okay in the .Net Framework 2 onwards.

[Another in an occasional series of things Daniel posts about so he can easily re-discover it next time he needs to remember how it’s done.]

Mortgage ‘Calculator’

Have a go at this crappy morgage calculator. Insofaras mortage calculators go, it’s middle of the road. It doesn’t allow for being an investor, which renders it useless to me – I have a substaintial investment income (only matched by my substaintial interest expense), and I’m not trading up from my current house.

But my biggest gripe is how the calculator has been “designed” to only work if you enter a valid, live email address. So this thing turns out to be a marketting tool, not a calculator per se. The address of me@example.com doesn’t work. If you enter an email address that isn’t live, it doesn’t give an error message – it barfs with an ASP error when sending the email fails. WTF? How is J Random User meant to figure that one out? Thankfully, it hands over the results (for what they’re worth) because jobs@google.com is a valid email address. Sorry about that, Google.

Snopes Love/Hate

I love Snopes.com. It’s an invaluable resource for urban legends. Every time some idiot forwards me the latest fad email, I can debunk it (or, far more rarely, prove it isn’t true.)

I hate Snopes.com. Because they go out of their way to make their site fiddly to use. There’s popups that beat Firefox’s default blocker. If you click through to another site from their pages, it not only opens in a new window, but they try to hide its URL when you mouse over the link.

And they’ve got code that prevents you clicking or selecting on their page — so for instance if the browser gets focus in the address bar, you can’t click back onto the page to get the up/down keys working again. I guess it’s to stop you copy/pasting text off the site:

if (typeof document.onselectstart!=”undefined”)
   document.onselectstart=new Function (“return false”)
else{
  document.onmousedown=disableselect
  document.onmouseup=reEnable
}

… though right-click / Select All works (at least in Firefox). Right-click also works for getting focus back on the page, thankfully.

The Project

I started The Project primarily so I could learn PHP. I’ve been using ASP (classic and .Net) for a while now, but wanted to try another web development language, preferably one that would be compatible with my dirt cheap web hosting. The way I envisaged it, it would be straight HTML/CSS, no fancy AJAX, using PHP and database lookups.

For development, I set up a Virtual PC with Win2K on it (quickest, best, easiest basic Windows version I had an unused licence for) and put IIS and PHP and MySQL on it. All reasonably easy. For database admin I put on PhpMyAdmin; it’s what runs on my web ISP, and is reasonably easy to use. For the IDE I looked around at Zend and some of the other paid tools, but decided to try DevPHP, a freeware thing, until I figured out if this project was going to fly.

It was all going well until I wanted to do some mod_rewrite fiddling with .htaccess. There are a few things around the place that purport to make mod_rewrite (or an approximation of it) work in IIS, but nothing seemed to do it well. In a fit of rage I ended up removing IIS and going the whole hog and installing Apache instead. It actually runs very well on Windows, and (after re-installing PHP and doing some config fiddling) matches my web ISP much better than any version of IIS could.

After using it for a bit, I also got a bit fed-up with PhpMyAdmin, which is particularly laborious for entering data. It’ll only do two records at a time, and semi-regularly seemed to ignore the second. Then I found the MySql GUI tools, which by comparison are an absolute Godsend. Why did nobody tell me about this before? (Actually it looks like I found a bit of it some time ago, but hadn’t used it properly until now.)

The coding has been coming along nicely, and the basic functionality is ready. I’ve got a couple more enhancements I’d like to do before it goes public.

So what is The Project? Not telling. But it’s aimed at non-geeks, going to be free for users, with Google Adsense to try and pull in some income (and get it indexed quickly). Maybe it’ll pay for itself, maybe not. But even if not, it’s already been successful as a way for me to learn some PHP.

Update 2007-04-19: The Project is now live.

CSS for table displays

After much time swearing over how to get a table-like display out of CSS, I was stumped. All I wanted was an definition with the label on the left hand side and the text on the right, wrapped into a column.

And let me tell you: given my limited knowledge of it, wrestling with CSS is not my idea of fun.

Finally after scouring Google for various terms, I did a search for “hanging indents” which led me to a good way to do it using dd dt and dl tags, and appropriate CSS for each. Eureka! (Yes, if I’d thought about it, these tags are for “definitions”, precisely what I was trying to do.)

Thank you, the good people at Max Design.

Programming for beginners (The Next Generation)

Microsoft are doing more in the beginner programming area, with the Coding 4 Fun web site and the Beginner Developer Learning Centre, backing up their various Visual Studio Express free packages. No doubt to fight back against the onslaught from PHP and other open-source tools, but hopefully it also helps get some more people into programming, particularly kids whose brains pick up such concepts so fast and have the imagination to make use of this kind of thing.

But I wonder if we’ll ever again see the heyday of home computer programming that there was in the eighties. Call me a teary old nostalgic if you like, but it strikes me that the eighties was the sweet spot sparking interest in programming: you had millions of computers going into homes with a relatively easy to use programming language built-in (all those variants of BASIC), but crucially, you also had a shortage of the kind of productivity software that lets people express themselves nowadays on computers without having to program anything.

For instance, back in the day, I used a Commodore 64 and a BBC B to do video titles for friends’ productions. To do this, I had to program them. Initial attempts were pretty pathetic, but let me tell you, the Doctor Who starfield sequences I eventually got working were pretty damn good. Thanks to the miracle of colour palette manipulation, along with some year 10-level mathematics I got not only stars flying out of the screen, but galaxies spinning around and wormholes appearing. (Unfortunately for that particular production an earlier, decidedly less impressive and readable credits sequence made it into the final edit.)

These days something similar would be done on Powerpoint or in a video editing package, which would probably have its own built-in titles editor. It’s undoubtedly easier, but half the motivation to dabble in computer programming is gone. OK, so this is just an example, but it’s something you see in various areas of computer use, such as web page design (do beginners still learn HTML?) or games (why code up your own Donkey Kong like you love in the arcades when you can just get it on MAME?).

This is not to say the huge variety of software enabling high productivity on computers is bad, of course, but I do think it means people are much less likely to get into programming these days as a hobby.