ColdFusion, HTML, and other geek stuff.
-
Saturday, 8 May 2004
-
Bundling your resources
Java has a concept (presumably stolen from prehistoric cave-dwellers) called resource bundles. It's nothing too profound: simply a set of strings localised for a given language. I am currently working on localising some of my products and adapting resource bundles to ColdFusion. I'm starting with (would you belive it?) Dutch. The Dutch are my number one non-English-speaking customer. I have no idea why.
It seems like every other week I am visiting the ISO site to look up ISO 3166. But it's always annoyed me that the only languages available are English and French, and on top of that everything is uppercase. A poke around on the web turns up a few other languages but little that is up-to-date (countries appear and disappear like mushrooms) and reliable-looking.
So finally today I tried Wikipedia, and voila nine languages! That's a good deal of translating I no longer need to pay for. 
-
Tuesday, 30 March 2004
-
The launch today of Macromedia Flex has been rather a slap in the face for loyal ColdFusion developers. This exciting new product is designed to facilitate rich internet applications by allowing developers to create Flash apps using an XML-based tag markup, rather than the counter-intuitive (to developers) movie/stage paradigm of Flash Studio.
Naturally, the ColdFusion crowd have been waiting with bated breath. Unfortunately, the pricing regime is prohibitive for most applications with a server license costing USD12000 and shared hosting specifically forbidden by the licence terms.
There's a lot of miffed developers around the world tonight. Macromedia took our new toy away. 
-
Wednesday, 18 February 2004
-
I'm just working through this book and thought I may as well compile any serious errata I find. I'll just keep updating this post as I find them. If you're not a CF developer please skip!
- 2.5.1 Hello.java
The book says to type java Hello to run the program. This is incorrect, which is unfortunate as it is the very first example in the book. You need to change to the parent folder and run the program from there:cd .. java javaforcf.Hello
- 3.4.2 Floating Point Types
"If you are interested in the use of 'e' in numbers, it is engineering notation for an irrational number representing the base of the natural system of logarithms, having an approximate numerical value of 2.7182818284. It was first used in the mid 17th century and has been calculated to 869,894,101 decimal places. So, 4.5E6 is another way of writing 4.5*106."
This is seriously wrong and doesn't even make sense. e, the constant, is not the same as the E that appears in numbers written in engineering notation. In the context of floating point numbers, the only relevant sentence is the last one.
- 3.4.6 Unicode in Java
"Unicode is referred to as a double-byte character set, because it uses 16 bits to store character data, unlike the 8-bit ASCII with only 128 characters. Unicode is therefore capable of storing 65,535 different values. . . ."
This is, as Joel points out, one of the great myths of Unicode. UTF-8 is an 8 bit encoding of Unicode, while UTF-16 is a 16 bit encoding. Unicode itself already contains more than 65535 characters, so it cannot be represented fully by a 16 bit encoding.
- 3.6.5 Bit Manipulation Operators
"Note that while the operators for bitwise and logical operations appear the same, Java knows the difference based on the types of the operands involved. If you ask Java to mix, say, a boolean and an int in an expression, it will refuse."
But they're not the same! Boolean operators look like && and || whereas bitwise operators look like & and | .
- 4.2.3 StringReplace.java
greeting.replace('1',
'x'); // here's the difference: in CF, the original // string would have been modified. not so in JavaThat's not true. The ColdFusion equivalent is:replace(greeting, "1", "x", "all"); which returns the new string but does not change the original. To change the original you'd need: greeting = replace(greeting, "1", "x", "all");
-
Wednesday, 28 January 2004
-
It's always the way: the browser that once led the field falls behind and becomes the lowest common denominator everybody has to code for. No matter what advances there have been in HTML / CSS / other browser technologies, designers can't use them because that one last browser doesn't support them. This happened to Netscape 4, which had a particularly negative impact as it was so buggy. Now it's happening to Microsoft Internet Explorer. Both these browsers are or were trailing the field in terms of technology yet leading in terms of market penetration.
MSIE doesn't have terrific stylesheet support. One of its limitations is that you can't apply a hover selector to any tag. If you could, then building a dropdown menu could be accomplished using just styles — no JavaScript at all!
Here's an interesting article on getting MSIE to support the :hover selector.
-
Wednesday, 21 January 2004
-
Saturday, 13 December 2003
-
Weighted random selection
I was talking to Mark the day before yesterday about weighted random selection. He's using it to display banner ads. This is a surprisingly difficult problem. We came up several different solutions.
- Each ad effectively holds lottery tickets in proportion to its weighting (which would need to be an integer). You then draw a lottery ticket. This would be implemented by building an array and picking a random row. This technique should be fast, but relies on integer priorities.
- You can do the whole thing in a SQL Server database if you create a table that contains all the possible weighting values (e.g. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) then use a query like this:
SELECT TOP 1 * FROM ads INNER JOIN weightings ON ads.weighting >= weightings.weighting ORDER BY NewId()
-
Add all the priorities of all the ads together. Then pick a random number between 0 and that total. Loop through all the ads, incrementing a totalPriority with the priority of each ad. Check if the random number is <= this totalPriority. If so, that's your ad. This technique will work for non-integer priorities but in theory would slow down if there were a lot of ads.
-
Finally yesterday I had another idea. Create a pool of ad impressions scaled according to priority. For example, if you want 1000 impressions then create a scale factor that is 1000 divided by the sum the priorities of all the ads. Use this scale to calculate the number of each ad to add to the pool (the total won't be exactly 1000). Now randomly select an impression from this pool (which is probably an array) and remove the impression from the pool when you select it. When you run out of impressions, you simply regenerate the pool. This technique means that you are not relying on probability to get the ad proportions right, which may be a good thing when dealing with paying clients. This solution would also adapt well to cases where you are selling a total number of impressions.
-
Monday, 8 December 2003
-
SimCats Beta
OK SimNina and SimMitty are online. Check the menu on left a little way down. They are a total of 406 lines of code. Unfortunately they don't have individuated personality traits yet. I may need to rewrite the entire thing. And now I'm off to see RealNina and RealMitty. And of course RealGrace.
-
Monday, 20 October 2003
-
Thursday, 16 October 2003
-
Silly Oracle
Usually you would write a SELECT TOP n query like this: SELECT TOP 10 * FROM myTable ORDER BY myColumn
But this doesn't work in Oracle. You have to write the following: SELECT * FROM (SELECT * FROM myTable ORDER BY myColumn) WHERE ROWNUM < 10
Can you believe it? Ridiculous! How can this be such a successful database platform with crap like this?
-
Wednesday, 15 October 2003
-
Remember the days of the web-safe browser pallette? This column points out that if you are still living those days then you're living in the past buddy (Lynda says so). I remember with great fondness the colour Tom mentions: #336699, which I used for pretty much everything (Grace calls it Matthew Walker blue). I've now graduated to more sophisticated shades of blue (like the background to this site: #006B82). #336699 is still in action at Dilbert.com.
Pages:
[Newer]
1
2
[Older]
|
|