2010-07-31

Ergonomic Keyboards

In my never-ending quest for the perfect input devices, I have been using two new keyboards this summer.

For those programmers on the go, I'm enjoying the only compact ergonomic Bluetooth keyboard I could find.

Picture of Microsoft Bluetooth 6000 keyboard and keypad with measured dimensions

The Microsoft Bluetooth Mobile Keyboard 6000 is nearly as compact as the Apple Wireless Keyboard, similar in shape but curved a bit to be easier on the wrists. The 6000 works well, though not nearly as sleek and cool looking as Apple's. And the name is not only boring but stupid: Microsoft has another unrelated keyboard also named '6000' – Did MSFT stop providing free caffeinated drinks to their marketeers?

This 6000 is true Bluetooth, not proprietary wireless, so it works with your Mac with out requiring a dongle. The curve is only in two dimensions (in contrast to the Arc) so it is is very flat. Works fine with Snow Leopard without installing any drivers. Has a power Off switch, so important for portable use. The feel is similar to Apple's, though a bit firmer, more definite key stroke. Seems sturdy enough, though plastic rather than Apple's amazing use of aluminum. Comes with a separate Bluetooth keypad, requiring a single AAA battery. I gave mine to a friend, as the main keyboard carries the programmers' requisite PageUp/Down, Home/End, and arrow keys. If only Waterfield made a case for the 6000. Lists for $90. Bought mine at Office Depot.

Tip: To make a Microsoft keyboard's layout more like the familiar Apple layout, choose System Preferences > Keyboard, press the "Modifier Keys" button, and switch the "Option" and "Command" settings. Apple layouts usually place the Command keys close to the Space Bar, while the Option keys are further away toward the outside. Did you know that? Your thumbs do.

Screenshot of Mac OS X System Preferences Keyboard Modifier Keys dialog box

For desk jockeys, the ultimate ergo keyboard is from Kinesis, the Freestyle Adjustable Split Keyboard for Mac. Kinesis specializes in truly ergonomic keyboards, not ergo-looking fads.


Picture of the left and right parts of Kinesis Freestyle keyboard




Though pricey, this is the best keyboard I've used. I bought the model with an even longer tether than pictured here. The tethering allows you to keep your hands at your sides, like a pro pianist, rather than unnaturally squeezing your arms and hunching your shoulders toward your anterior meridian. They document the keys as requiring substantially less pressure than is common, yet the key have a definite key stroke, reminiscent of the old battleship-sturdy key-clicking IBM keyboards of yore. The macro keys on the left are superfluous to me, though as a programmer I do appreciate the Forward Delete key above the usual Backspace key. My one regret with the Freestyle is not buying the riser flaps; instead I'll try some low budget rubber door stops.


Picture of rubber door stops to lift keyboard



If you live in the Seattle area, you may contact Kinesis to arrange a visit to their Bothell WA office for a hands-on trial.

If only I could get the Freestyle in a SteamPunk version.

2010-07-27

Data Types in REAL Server 2009

As an old hand with relational databases but new to SQL, the topic of data types has thrown me for a loop.

Supposedly we have data types in standard SQL. Unfortunately, they are not defined precisely as in how many bits for each type of numeric format. And there are some commonly used data types such as "Currency" (a fixed number of digits on each side of the decimal point) that are not in the official SQL standards.

REAL Server uses SQLite as its engine. Then we have SQLite which has only 4 actual data types:

  • Integer
  • Real
  • Text
  • Blob

SQLite accepts many of the usual data type names, but they all get mapped to one of those 4 actual types. By accepting these various other type names, you can write code and SQL scripts that are compatible with other databases. Beware that while SQLite allows you to use the names of stricter data types, SQLite does not enforce that strictness. For example, you can specify VARCHAR(10) but SQLite will let you insert a string longer than 10 characters.

In addition, SQLite is unusually liberal in accepting various kinds of data that strictly speaking violates the declared data type. For example, you can stuff a string into an Integer column. This feature is called "type affinity". So, if you want compatibility with other databases, be sure to tighten up your programming code to not store the wrong type of data to the database. While SQLite may accept it, other databases will refuse with an error.

SQLite has various limits you should study.

If you are using REAL Studio 2010 and REAL Server 2009, I have built a table listing your data type choices.

Data Types in REAL Server 2009
CategoryREAL Server TypeStored in SQLite asREALbasic constant valueDescription
TextualTEXTText5UTF-8 character encoding. SQLite accepts other Unicode-compliant encodings, but they are moot as the REALbasic language uses only UTF-8.

While the various documentation is vague, it seems the size limit on both REALbasic language and SQLite engine is about 2 billion octets. That may translate to fewer characters given that UTF-8 uses multiple octets per character for letters beyond the US-ASCII range (first 127 of Unicode).
VARCHAR(n)Text5UTF-8 character encoding. SQLite accepts other Unicode-compliant encodings, but they are moot as the REALbasic language uses only UTF-8.
TemporalDATEText8YYYY-MM-DD
TIMEText9HH:MM:SS.nnnnnn
No time zone that I know of.
TIMESTAMPText10YYYY-MM-DD HH:MM:SS.nnnnnn
No time zone that I know of.
Whole NumbersINTEGERInteger3Uses up to 64-bits, as needed.
SMALLINTInteger2REALbasic language variable type is 32-bit. SQLite stores as Integer, up to 64-bits as needed.

32-bits means numbers in the range of about ± 2 billion. 64-bits means a humongous range of about ± 9 quintillion.
Fractional NumbersCURRENCYReal1164-bits.
nnn,nnn,nnn,nnn,nnn.nnnn (or nnn.nnn.nnn.nnn.nnn,nnnn)

15 digits for the whole portion (left of decimal point).
4 digits for the fraction (right of decimal point).

Those 15 digits means numbers in the range of ± hundreds of trillions, up to about a quadrillion. Those 4 digits means as fine as a ten-thousandth of a fraction, or in the terms of US dollars, as fine as a hundredth of a penny.

'Currency' is a misnomer; while frequently used for money you can use it for any fractional number. This type is not actually savvy about monetary issues.

The name 'Currency' is not standard SQL. While many databases offer a 'Currency' or 'Money', to be strictly standard in other databases you would define: DECIMAL(19,4)
DOUBLEReal764-bit floating-point numbers.

With floating-point numbers you trade off accuracy for a greater range of numbers. You get about 16 digits from which you can make either very large numbers or very small fractional numbers, but not both at same time. If you know you do not need small fractions, you may be better off using the Currency type.
FLOATReal632-bit floating-point numbers.

You get about 7 digits. As with DOUBLE, you may be better off using the CURRENCY type.
OtherBOOLEANInteger12SQLite stores as 0 or 1. But that fact is moot, as the REALbasic feature DatabaseField.BooleanValue conveniently interprets it as a FALSE or TRUE.
BLOBBlob15The 'B' in blob stands for 'binary'. Binary means the data is treated simply as a bunch of bits without any kind of processing and without any interpretation of its meaning or how to handle it.

The absolute size limit in SQLite for a blob is about 2 billion octets. But in most releases of SQLite the usual limit is set to 1 billion. I've not tested REAL Server's limit.
BINARYBlob16Same as BLOB according to REAL Software's Tech Support.

There is one additional type offered by the REAL Server Admin app's Structures feature: "Real". That type is not documented as having a constant value in REALbasic. And in many other database engines, 'Real' means 32-bits whereas in REAL Server it means 64-bits. So, I suggest using the other fractional number types such as Double or Currency. REAL Software Tech Support agrees.

2010-07-25

Pointing REAL Server (SQLite) to a database

REAL Server can serve many different databases simultaneously. You find a list of them on the Database sidebar item in the REAL Server Admin app.

One of the first things you need to learn when using the "Console" in the REAL Server Admin app is that you must tell the server which of these database you want to use. Even if you have only one database, you must consciously "point" the console session to that database. If you fail to point the console, any SQL command requiring a particular database will fail with an error. If that happens, the Admin app is usually good about reminding you to select a database.

To point the console session to a database, execute this sql:

USE DATABASE 'ExampleDbName'

Any more commands executed is this console session apply to that particular database.

To switch to another database, use that same command again:

USE DATABASE 'OtherDbName'

You can point the console away from any database. You may want to do this to avoid inadvertently executing commands against the wrong database.

To point the console away from any database, execute this SQL:

CLEAR CURRENT DATABASE

You receive no confirmation of this command. If you want to verify that the session points to no database, execute the following harmless SQL code to see if it generates a complaint about not pointing to a database, error # 7030. Strangely, the "SELECT DATETIME" command requires a database.

select datetime('now');

I do not know how to ask what database the console session currently points to. Please post if you do. When in doubt, call the USE DATABASE command to be sure.

Zulu Time in REAL Server (SQLite)

UTC time is the new GMT time, the time of day unadjusted for any time zone. Zulu time is a nickname for UTC time, as "Z" appears at the end to indicate a lack of time zone adjustment.

UTC does officially account for a leap second, when an extra second is squeezed into the year every once in a while. For most business purposes we can ignore this issue.

When using world clock software such as the US federal government's to look up the current time as Zulu time, you may find "UTC" or "GMT" or "Zulu" among the list of world cities. If no such pseudo-city is listed, use Reykjavík, as Iceland is in the same time zone as UTC and avoids Daylight Saving Time. So, Reykjavík time = Zulu time.

If you have users and computers in different time zones around the country or world, and they need to share data and coordinate with one another, you may want to store your datetime values in Zulu time. 

When a New York user reads "4:15 PM" they think the event happened during their business day, but if that data was written by a Los Angeles computer, the event actually happened 3 hours later, meaning 7:15 PM, or after business hours from a New York perspective. Adding further ambiguity is the lunacy of Daylight Saving Time. If you fail to consistently record the relevant time zone with each datetime, you have a real mess.

Human brains tend to confuse such time zone adjustments. It may be wiser to adjust all local times to Zulu time before recording them. In database and other software systems, you can display the recorded Zulu time back into the user's own local time zone.

In REAL Server and presumably any other SQLite engines, you can obtain the zulu time according to the database server's computer by executing this SQL:

select datetime('now');

For example, here in Seattle the current time is 16:05 (4:05 PM). That line of code above reports:
2010-07-25 23:05:14
which is Zulu time. (Normally the west coast is 8 hours behind Zulu, but Daylight Saving Time makes that 7 hours.)

Slap a "Z" on the end, and you have a standard ISO 8601 datetime:
2010-07-25 23:05:14Z
Optionally, you can replace the middle space character with a "T": 
2010-07-25T23:05:14Z

If you want just the date or time portion, as you would intuit, use this SQL:

select date('now');
select time('now');

If you really want the database server's local time, add a second argument 'localtime':

select datetime('now', 'localtime');
select date('now', 'localtime');
select time('now', 'localtime');

Find more info in the SQLite documentation.

2010-07-22

Installing Oracle Java 6 on Ubuntu 10.04

Some Linux distros pre-install Java, and some don't. Even when they do, the distro may not be various implementations of Java while I prefer Oracle's (formerly Sun's). After some googling, I found a way to successfully download and install Sun's latest implementation. In my case, today, that was Java 6 update 21 on Ubuntu 10.04 (freshly updated today).

I'll share the steps I took. Caveat: I'm a Linux newbie, so inform yourself with further research, and proceed at your own risk.

Phases:
  • Download Java installer from Oracle, and prepare it to execute.
  • Run the installer.
  • Verify install.
  • Add that Java implementation to the PATH so it may be found and used by your computer.
  • Install a plugin to enable web browsers to run Java applets.

Download

You may find it easiest to obtain Java here
But if you are more technically minded, go here
  1. Look for "Java SE" where 'SE' means "Standard Edition" aimed at regular desktop and laptop computers, as opposed to phones/handhelds and servers. 
  2. If you merely want to run Java, download the "JRE" where the 'R' means "Runtime". If you may want to write and compile your own Java programs, download the "JDK" where the 'D' means "Development". 
  3. Choose "Linux" if you have a 32-bit version of Ubuntu, or "Linux x64" if you have 64-bit Ubuntu. 
  4. Notice a link elsewhere on this page for "Installation Instructions". Open that link in a a separate browser window/tab for more info. For me, the link was: http://java.sun.com/javase/6/webnotes/install/index.html#linux
  5. Click Continue. 
  6. When asked for you to register your name, notice the option to skip that step.
In my case today, I downloaded "Java SE Development Kit 6u21". That means the 21st update to Java version 6 (technically known as Java 1.6).

You will have downloaded a .bin file. In my case, "jdk-6u21-linux-i586.bin". Next we ensure that the security settings for this file allow us to run the installer software contained inside. We do so using the command-line. 
  1. Choose Accessories > Terminal. 
  2. Type: chmod a+x jdk-6u<version>-linux-i586.bin

Install

Now we can run the installer stored in that .bin file. 
  1. Move the file to the directory where you want to install Java. For me, I chose my own home directory. 
  2. In the Terminal, switch to the place you chose to install. For me that was home: cd ~
  3. Run the installer. In the Terminal type: ./jdk-6u<version>-linux-i586.bin
  4. When the installer finishes, find the new directory named: jdk1.6.0_<version>.
Verify

Let's see if the newly installed Java works. 
  1. Change to the new "jdk" (or "jre" if you chose that installer) directory. 
  2. Within the "jdk" directory, change to the "bin" directory.
  3. Test your Java install by typing ./java -version to print a few lines describing the version of Java.
PATH

To run Java above, we had to switch to the "bin" directory. Instead, we should tell the computer where to find the Java install. To do that, we add that directory location to a "System Variable" (a.k.a. "Environment Variable") called PATH. The PATH variable is a list of all the directories the computer should check when trying to run a program from the command line. 

Changing the PATH should happen every time we login to Ubuntu. During login, Ubuntu reads several configuration files. We can add instructions for changing the PATH in one of those files.While I am not sure which of the various files is the ideal place to change the PATH, I have found one that works. The configuration file I used is named ".profile". The period in the front of the file name means the file normally hidden. To see this file in the command line, type ls -a where the '-a' means show all files including the normally hidden ones. You can also tell your File Manager to show these files by checking Edit > Preferences > Default View > Show hidden and backup files.
  1. Go to your home directory, and verify the file .profile exists.
  2. Make a copy of that file. You can do so in the Terminal by typing: cp .profile .profile_backup
  3. Open the ".profile" file in the a text editor such as Applications > Accessories > gedit Text Editor.
  4. Add these two lines (exactly, case sensitive) to the bottom of that file, and save:
    PATH=$PATH:/home/basilbourque/jdk1.6.0_21/bin
    export PATH
  5. Logout
  6. Login
  7. Test your work by changing to any directory in Terminal, and type: java -version

Browser Plugin

Your web browser may not yet be set up to run Java applets. You can test this easy by using the "Do I have Java?" link at Java.com.

I followed these instructions to install the browser plugin for Java.

I found my Firefox 3.6.6 plugins folder here:
/usr/lib/firefox-addons/plugins
Surprisingly, I found that folder to be empty. If you find any old Java plugins, delete them.

I found the Java plugin file here:
/my_user_name/jdk1.6.0_21/jre/lib/i386/libnpjp2.so

The directories nested in /usr are protected. So you need an 'SuperUser' administrator's password to make changes. If you installed Ubuntu, then your own password should work. Below you'll see that I used the 'ln' command to create a link file, but added the word 'sudo' in front. 'sudo' is a command that means "do the following as a superuser rather than a normal user".

So in Terminal I…

  1. Closed any open Firefox windows.
  2. Changed to the plugins directory by typing: cd /usr/lib/firefox-addons/plugins
  3. Created a symbolic link (like an Alias in Mac OS X and Shortcut in Windows) by typing: sudo ln -s /my_user_name/jdk1.6.0_21/jre/lib/i386/libnpjp2.so
  4. Typed in my superuser password
  5. Confirmed the creation of the link file by typing: ls -a
  6. Launched Firefox.
  7. Verified the plugin's presence by typing in the Firefox address bar: about:plugins
  8. Verified that the Java plugin works by visiting Sun/Oracle's page "Verify Java Version". 
That was a chore, but well worth the trouble. Java is a wonderful thing. For example, try this amazing stock market applet.

2010-07-17

Check for 'nil' when painting a picture in REALbasic

Here is some code for drawing a picture in a window in REAL Studio 2010 using a Canvas object. You may be displaying eye-candy, an advertisement, etc.

Originally I did not include the "IF( p <> nil)". That bit me when I changed the app to dynamically download an image over the net. Of course networks are not reliable. When network failure occurred my image was not loaded. The side-effect of not loading is display of error messages irrelevant to my users. The solution was simple, if the image does not exist (nil) that means it never loaded, so don't bother trying painting a non-existent image.


  // 'Paint' event handler on Canvas object. © 2010 Basil Bourque.
  // This source code may be used freely by anyone taking full responsibility for doing so.

  dim p as Picture = self.adImage


  // Paint image only if it exists. 

  // Non-existent means the image failed to load.
  if( p <> nil) then


    g.drawpicture p,0,0
  
    // Add a border
    g.forecolor = &cBBBBBB
    g.penheight = 1
    g.penwidth = 1
    g.drawrect (0, 0, p.width, p.height)


  end if


  // fin

To use "MouseUp" in REALbasic, use "MouseDown"

You may want to detect the user's clicks on controls other than buttons in your REAL Studio 2010 window. For example, you may display an advertisement in a Canvas object and want to ShowURL when the user clicks the ad.

To respond to the user's click, you write some code in the ‘MouseUp’ event handler. For example, the call to ‘ShowURL’ for the ad would go there.

There's one catch…
To enable that ‘MouseUp’ event handler, you must also put code in the ‘MouseDown’ event handler. This one line will do:

Return True // to enable MouseUp

2010-07-11

Overloading method names in REALbasic

It wasn't obvious to me that REALbasic allows overloading method names, where you use the same name on two or more methods but with different sets of parameters (arguments).

It turns out we can indeed overload method names. The REAL Studio 2010 IDE even helps out along the way.

Create a method and name it as you normally do. The method appears in the list. For example, "PhoneHome", a method to report problems at runtime. This method has two arguments, both String, one containing a message of the problem, and the other containing the name of the method.



After some use, we realize we commonly repeat code when reporting RuntimeExceptions being thrown. In each use we extract the Exception's ErrorNumber, Message, and Stack. Rather that copy-pasting similar code, we should move that code into a single method where we pass the Exception object rather than text. For simplicity it makes sense to use the same method name.

So we create a new method, but use the same name "PhoneHome". Immediately REAL Studio assists by adding the argument types to the listing display of method names.





Now we can call either method by the same name. The REALbasic compiler and runtime knows which one we want by looking at the type of the passed parameters.

When scanning the list of methods, we immediately recognize the display of parentheses and arguments as meaning a method is overloaded.

2010-07-06

Sharing code in REALbasic

You can share your REALbasic code between your REAL Studio 2010 projects, or with your colleagues. You can choose between 3 ways.


Cut and Paste

Choosing Edit > Copy and email is always quick and easy.

In addition, you can choose "Copy" in a context menu when your Control+Click (Right-click for PCs) on a method name in the project's lists. You code will be surrounded with "Sub" or  "Function" declaration lines including parameter types.


Export & Import

Select a class in your project's listing, then choose File > Export. Your class and all its related code are copied into a disk file. That file can then be imported into another project. On import, the file's content is copied into your project, after which you can trash the file.

You may export a class, a Window, a module, or a menu bar.

You may choose between exporting using REAL Studio's own native format, or in XML format. Both can be imported into another project. You may find it interesting to peruse an export in XML format. In theory, I suppose one could build a tool to generate these XML files thereby creating REAL Studio forms programmatically.


External Project Item

Export-import is certainly more convenient than copy-paste. But if you have some generic code that you use in multiple projects, making changes to that code becomes tedious when you export again and re-import repeatedly into the various other projects. Wouldn't it be nice if REAL Studio could refer to that exported file without actually importing? Well, it can.

Rather than choosing File > Import in the various projects, instead hold down the Option key (ALT key for PCs) while choosing the File menu. The "Import" menu item changes to "Import as external". This command tells REAL Studio to consider that external file to be a part of the project without actually copying its contents. When you do a compile or build in incorporating project, REAL Studio compiles that source code too. That source code may be sitting in an external file (outside the project file) but is nevertheless part of the project.

Later, when you revise the shared source code, merely replacing the external file effectively updates all the various incorporating projects. No need to import again into each of the projects.

As an alternative to using the File menu, you can incorporate the external file into a project by dragging the file into the project window while holding down Command+Option (Control+Shift on Windows).

While working in that incorporating project, you can even edit the external file. How convenient. One catch, of course, is that you should not try to edit the same external file from two different projects at the same time -- just as you would not have two word-processors editing the same document simultaneously.

Another catch is that you can only incorporate external files as source code. You cannot include a chunk of compiled REALbasic code into another project. However, you do have the option of encrypting the external source code file. Encryption enables you to sell or give away your software without disclosing the open source code, if you so desire.

Shortcut: The "Make External" menu item is a convenient shortcut for exporting a selected class' source code to a disk file, deleting the original source code in the project, and importing as external that newly created file. So you can instantly prep your existing source code for sharing with other projects and people.

2010-07-04

CSS font stacks

Continuing from my previous post about a CSS list of best monospaced fonts, I found this article by Michael Tuck coining the term "font stack". The CSS attribute 'font-family' lets you specify a long list of fonts. The web page uses the first font found. So go hog wild, and make a list, a "stack" of fonts in the typographic style your page deserves.

Always remember to include one of the CSS-defined fall-back styles. If none of the fonts you name can be found on the user's computer, each browser will use a default font assigned to ecah of these styles:
  • serif
  • sans-serif
  • cursive
  • fantasy
  • monospace
 Here are my revisions to that author's font stacks. The idea here is to name fonts for various platforms. Please post comments with your ideas including suggestions for other platforms such as Solaris, BSD, etc.

Georgia Stack

font-family: Constantia, 'Droid Serif', Georgia, 'Minion Web Pro', 'Minion Web', Minion, 'Lucida Bright', Lucidabright, 'Lucida Serif', Lucida, 'DejaVu LGC Serif', 'DejaVu Serif', 'Bitstream Vera Serif', 'Liberation Serif', 'Nimbus Roman No9 L', 'Century Schoolbook L', Norasi, Rekha, serif;


Garamond Stack

font-family: 'Palatino Linotype', Palatino, Palladio, 'URW Palladio L', 'Book Antiqua', Baskerville, 'Bookman Old Style', 'Bitstream Charter', 'Nimbus Roman No9 L', Garamond, 'Apple Garamond', 'ITC Garamond Narrow', 'New Century Schoolbook', 'Century Schoolbook', 'Century Schoolbook L', Likhan, Norasi, Rekha, Georgia, 'DejaVu LGC Serif', 'DejaVu Serif', serif;


Times Stack

font-family: Cambria, 'Hoefler Text', Utopia, 'Liberation Serif', 'Nimbus Roman No9 L Regular', Times, 'Times New Roman', serif;


Trebuchet Stack

font-family: 'Segoe UI', Candara, 'Bitstream Vera Sans', 'DejaVu Sans', 'Bitstream Vera Sans', 'Trebuchet MS', Verdana, 'Verdana Ref', sans-serif;


Verdana Stack

font-family: Corbel, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'DejaVu LGC Sans', 'DejaVu Sans', 'Bitstream Vera Sans', 'Liberation Sans', Verdana, 'Verdana Ref', sans-serif;


Helvetica Stack

font-family: Frutiger, 'Frutiger Linotype', Univers, Calibri, 'Gill Sans', 'Gill Sans MT', 'Myriad Web Pro', 'Myriad Web', 'Myriad Pro', Myriad, 'DejaVu LGC Sans Condensed', 'DejaVu Sans Condensed', 'Liberation Sans', 'Nimbus Sans L', Tahoma, 'Helvetica Neue', Helvetica, Geneva,  Arial, sans-serif;


Impact Stack

font-family: Impact, Haettenschweiler, 'Franklin Gothic Bold', Charcoal, 'Helvetica Inserat', 'Bitstream Vera Sans Bold', 'Arial Black', sans-serif;


Cursive Stack

font-family: Chalkboard, Casual, 'Comic Sans MS', TSCu_Comic, cursive;


Monospace Stack

font-family: Pragmata, Menlo, 'DejaVu LGC Sans Mono', 'DejaVu LGC Sans Mono', 'DejaVu Sans Mono', Consolas, 'Everson Mono', 'Lucida Console', 'Andale Mono', 'Nimbus Mono L', 'Liberation Mono', FreeMono, 'Lucida Sans Typewriter', 'Lucida Typewriter', 'Osaka Monospaced', "Bitstream Vera Sans Mono", Courier, 'New Courier', monospace;


Notes

The Droid font family was created for inclusion in the Android platform.

I tried to glean some additional Linux font names from this Linux Fonts Equivalents list, but several of those were for non-Latin languages. The "FreeXXX" fonts have many glyphs but may not be hinted; I'm not sure if these should be included or not. Please post your feedback if there are better Linux choices.

At least some implementations of Java (from Sun, Apple, and others) include a small set of "Lucida" family fonts. See a list in this documentation. Often these are available only to Java-based apps, not native apps. Note that the sans-serif (Lucida Sans) and monospaced (Lucida Typewriter) fonts lack a true italics version, while the serif font (Lucida Bright) has both bold and italics.

Obviously these stacks aim at web pages written in Latin-based languages. Hopefully folks share their stacks for other languages.

CSS for <code> tag. List of best monospaced fonts.

Here's the CSS code I use to specify the best monospaced fonts for displaying programming source code in web pages using the <code> tag.

code {
font-family: Pragmata, Menlo, 'DejaVu LGC Sans Mono', 'DejaVu Sans Mono', Consolas, 'Everson Mono', 'Lucida Console', 'Andale Mono', 'Nimbus Mono L', 'Liberation Mono', FreeMono, 'Osaka Monospaced', Courier, 'New Courier', monospace;
}

That collection hits the best fonts across Mac, Win, and Linux platforms. Post your feedback, such as suggestions for Solaris and other platforms.

The best monospaced font ever is Pragmata. Literally, it is without compare. The Italian designer took a different approach, making the glyphs tall and skinny whereas most other fixed-width fonts use a short and wide size. While that may mean more scrolling in your code editor,  reading and scanning lines is so much easier on the eyes. Pragmata has programmer-friendly features such as differentiated glyphs for Zero and 'O', exaggerated () {} [] glyphs. And this font has 'hints' for better rendering on-screen at smaller sizes.

Unfortunately, Pragmata is relatively expensive at about $108 US, €100. But that price gets you a license for 5 machines, when I read the terms at Fonts.com. That's 5 machines in your home/business, not your friends’ of course. If that still seems expensive, consider the countless hours a programmer spends staring at monospaced text in code editors, web pages, and email. Try it. Compare it.

For the unemployed and the tight-fisted, next best is the mono family within the DejaVu font set. Free of cost, and open source. DejaVu is becoming popular as the default font in various distros of Linux, but works well on your Mac and PC too. Menlo is Apple's adaptation of DejaVu Sans Mono, now bundled in Snow Leopard.

2010-07-03

CSS color names

Using color names is obviously easier than by number, gray vs rgb(128, 128, 128). Besides less typing, using names makes it easier to use the same consistently across multiple places in your CSS code.

Strictly speaking the CSS 2.x specs recognize only 17 names: The same 16 color names as HTML, plus 'orange' rgb( 255, 165, 000).

CSS 3 (not yet finalized) adopts the long list of color names defined long ago by X11

Virtually all browsers recognize these color names now. But those color names will show up as errors in CSS 2.x validators. An error may appear as this:
Value Error : background-color lavender is not a color value : lavender lavender
Here's the big tip… A list of X11 colors organized by color groups. Much easier to find your desired color than in the other alphabetical and numerical lists I’ve seen.