2010-10-15

pgWest 2010 conference topics for beginners

I'm new to Postgres by way of programming in REAL Studio and its bundled database driver. Postgres keeps looking better and better. So my interest was piqued when I heard about the annual conferences where both the creators and users of Postgres congregate, alternating east and west coasts of the US.

Nov 2-4, 2010 is the west coast conference, called ‘pgWest’. This time around it’s located in downtown San Francisco. Even as a newbie, I found a useful topic in all the time slots. Here's a list of my picks among the busy agenda:

There is also a mention but no information about a full day training session on Nov 5 by Bruce Momjian.

2010-10-13

Standard delimiters

After decades of programming experience, I only now learn that the ASCII spec defined delimiters. As an extension of ASCII, Unicode adopted these too.

  • Character 31 is for separating fields of data.
    – ASCII "unit separator" (US for short)
    – Unicode "INFORMATION SEPARATOR ONE"
  • Character 30 is for separating records of data.
    – ASCII "record separator" (RS)
    – Unicode "INFORMATION SEPARATOR TWO" 
If you need higher levels of hierarchy or grouping:
  • Character 29 is for separating groups of records.
    – ASCII "group separator" (GS)
    – Unicode "INFORMATION SEPARATOR THREE"
  • Character 28 is for separating groups of groups, that is, a document or file.
    – ASCII "file separator" (FS)
    – Unicode "INFORMATION SEPARATOR FOUR"
This blog and this Wikipedia page explain. Correctly using these delimiters is properly called ASCII Delimited Text.

These delimiters were defined way back in the 1960s! So why on earth has common practice been the perversion of Tab, Linefeed, Carriage Return, Comma, etc. for delimiting data? Perhaps because text editors are built as stripped-down word-processors for visualizing text on screen, yet are often used for viewing and editing data streams. Tab, Linefeed, Carriage Return, Comma, etc. characters where meant to control presentation of text, but delimiters are meant to identify chunks of data in a stream. Since Tab, Linefeed, Carriage Return, Comma, etc. can very well be present inside a valid text stream, it is silly to use these as delimiters.

There are two distinct purposes being served by these code points:
  • Text white-space
    Presentation of text characters on screen or on paper for display to humans, controlling placement of text in column position and lines, spreadsheet cells, and so on.
  • Information separators
    Identify meaningful chunks of information inside a data stream, and show a hierarchical relationship of those chunks.

Mixing up the two (text white-space vs. information separators) is like serving the plastic green frilly stuff found between butchers' trays inside your hamburger.

As for white-space, carriage return, linefeed, tab, form feed, and such were originally intended to control presentation of data in a printer. Unfortunately, their purpose has been bent into indicating end-of-line and end-of-paragraph. Unicode had the bright idea of defining two new characters just for those purposes, to eliminate the ambiguities. Unfortunately, I've never seen them used.

• U+2028  (decimal 8,232) = SEPARATOR, LINE
• U+2029  (decimal 8,233) = SEPARATOR, PARAGRAPH

2010-10-12

Postgres User Groups

I'm liking Postgres more and more. If you are interested in learning more about Postgres, you may find a user group meeting in your area.

In the Seattle and Bellevue area, there is SeaPug. If I could  draw, I'd make a logo: a Pug dog drinking Starbucks.

To find others groups, check this page.


2010-10-10

Colo and hosting

If you want to pay someone to host your server on the internet, there are 3 ways to go.

  • "Colo"
    Short for Co-located, where you own a computer, send it to a service company, and they install it in their racks. You own the computer box, they plug it into fast internet connections, uninterruptible power supplies with generator backup, and possibly behind firewall hardware. Some will sell you a computer from their inventory as well, new and/or used.
  • Rent-a-server
    Same as above but you rent their computer rather than provide your own. With today's low costs for computing hardware, this may not make financial sense.
  • Virtual Server
    You pay rent for a certain speed and number of processor cores, certain amount of disk space, and bandwidth and/or traffic. But it's all imaginary. You don't actually control a specific computer box, processor, or hard drive. Your virtual server is one of many others operating across a server farm, large arrays of computers. Some services let you shut down your virtual server but store your disk space while reducing the bulk of your cost. This is handy for test machines, or trial runs before launching your full-time servers.
In the first two categories, my professional contacts, previous research, and word-of-mouth leads me suggest the following companies to someone looking for a vendor:
Do your own research and shopping, but those vendors may be a good place to start.

2010-10-08

Zipping beyond the Mac

I distribute my cross-platfrom app to the world as simply a zipped file. That seems to be working well, except for two problems:

  • Older versions of Windows, even Windows XP, may not ship with a Zip tool. 
  • When creating the zip on my Mac using the Finder command File > Compress*, extra files or folders are included for Mac-savvy features. 
The first problem, I have no answer for. Except to say I've gotten no complaints from the public yet. So perhaps the problem is not widespread today.

The second problem is a problem only for the non-Mac crowd. On a Mac, the extra file/folders are invisible. But on Linux and Windows computers, the users see this extra crud and are likely to get confused. I have found 2 easy fixes.
  • Path Finder
    This excellent app from CocoaTech is a Swiss Knife full of diverse tools, handy for a range of geeks and programmers. It costs about forty bucks, and so worth it. Relevant here is the ability to create zips. By default it creates zips in the same Mac-savvy way. To strip that extra stuff in future zips, in Path Finder preferences, turn ON the two "Ignore" checkboxes.
    ☑ Ignore invisible file when compressing
    ☑ Ignore resource forks when compressing

  • YemuZip
    This free app from Yellow Mug does one simple thing: Create zips. Drag-and drop easy. With the option of stripping away the Mac-specific stuff. Perfect. Even includes a feature to check for updates.


* Older versions of Mac OS X: File > Make Archive

2010-10-06

Running Apache Tomcat on your Mac

  

Apache Tomcat is Apache's other web server. Also runs Java Servlets and JSPs. I prefer running Tomcat as a web server much better that Apache's more famous (and finicky) "httpd".

Tomcat is pure Java, so it runs very well on your Mac OS X computer. Apple builds Java into every Mac.

  • The current version 6 runs on many older generations of Macs as well as new ones. 
  • The still-beta version 7 will run only on Java 6, which requires an Intel Mac running Snow Leopard.
There is one big catch to running Tomcat on your Mac: By default, the permissions are set incorrectly on the downloaded files. When you try launching Tomcat you will get errors, complaining that you do not have permission to complete certain operations. The fix is so easy: just a drag-and-drop and a few mouse clicks. Here's how.

Download the free app (donations accepted) BatChmod. It has the best icon, by the way. This app is a very convenient gui wrapper around an otherwise very difficult arcane set of command-line instructions. You will be entrusting your system password to them, and do so at your own risk. They've been in business for years with no issues I've heard of. Tip: To detect any software phoning home without your permission, get the Mac app Little Snitch.

Download Tomcat. Version 6.0.29 is current nowadays. Grab the zipped one, as the tarred files may not work with Mac OS X' tar tools. You'll end up with a folder named something like "apache-tomcat-6.0.29". If you’re paranoid, hit the MD5 link, read the number, then drag and drop the downloaded zip file to a Terminal window after typing "md5 ", and compare your number to theirs. If no difference, you downloaded without corruption.

You can place the Tomcat folder anywhere you like. I avoid nesting too many folders because extremely long path names can cause problems. I suggest the top level of your home folder.
  1. Drag and drop your unzipped Tomcat folder to the BadChmod app. 
  2. Check all the checkboxes except "Clear xattrs".
  3. Click Apply.
  4. Enter your system password.
  5. Quit.

CAVEAT: I am not expert at these Unix permissions and related issues. Do all this at your own risk, and after your own research. I'm just sharing what works for me, but taking no responsibility for you.

This problem of Unix file permissions often occurs on downloaded files, but the effects are more obvious in Tomcat. I usually run BatChmod on anything I download, unless packaged as a .DMG file. 

Now you're ready to launch Tomcat.
  1. Open a window in Terminal app, found in Applications > Utilities folder.
  2. In the Finder, locate inside the "bin" folder inside the Tomcat folder.
  3. In "bin" folder, locate the file named "startup.sh".
    (Ignore the .bat files; those are for MS Windows)
  4. Drag and drop that "startup.sh" to your Terminal window.
  5. Press Return to run that shell script.
    (".sh" means "shell")
  6. See several lines of text appear in the Terminal window.
    (If you see about 5 lines of "Using " this-or-that, you are in good shape.)
Now test your web server.
  1. Launch a web browser, such as Safari, Camino, Firefox, Opera, Chrome, etc.
  2. In the URL address bar, type:
    localhost:8080
    Or if that seems to fail, type:
    127.0.0.1:8080
  3. Press Return to make the web browser hit your web site.
    If successful, you should see a web page displayed with the cute tiger Tomcat logo and the Apache feather logo.
To get rid of the need to add the ":8080" see my other blog post on port-forwarding.

To shutdown the web server, in that same Terminal window, drag and drop the "shutdown.sh" file. Press Return to execute, of course.

Tip: Press the Up-Arrow key to re-enter previously used lines in that Terminal window. Press Return to execute one of them. This is a handy way to easily repeatedly start and stop Tomcat.

If you got this far, lastly you replace Tomcat's default web site with your own. Replace the contents of:
Tomcat folder > webapps > ROOT

Note that we did not do any configuration settings in Tomcat whatsoever. I like that about Tomcat: For a single web site, Tomcat is ready to go out-of-the-box. You can do much more configuration if you wish as Tomcat is relatively flexible and full-featured as web servers go. You can change the port number. You can turn on logging to record who hits your web site and when. You can enable virtual hosting to serve multiple web sites. You can set up security restrictions controlling access to portions of your web site.

In passing, I'll mention another popular Java-based alternative to Tomcat: Jetty. If you want a bunch of additional functionality, beyond just web serving and Java servlets, for a big application server consider Glassfish. But for me and most folks I know, Tomcat or Jetty are the way to go.

Hope that works for you. Happy serving!

Use Google to search REAL Studio docs

I really miss the PDF version of docs for REAL Studio 2010. With PDFs, I can use Apple Preview or Adobe Reader to search through an entire manual to find occurrences not listed in the TOC or Index.

The REAL Studio team has chosen to move from PDFs to online wiki-based docs, for the noble reason of keeping the docs always up to date. Unfortunately, the price we paid is awkward search capability. Unless you are searching for an exact class name, the search utility at docs.realsoftware.com leads to frustration.

Then I remembered the wise man who taught me this nifty trick in using Google: Constrain a Google search to a single domain (web site). Simply add the word "site:" (with a colon) and the domain name. Then add on your usual search criteria.

For example, instead of googling this:
Shared Property
Put this into your Google bar and smoke it:
site:docs.realsoftware.com Shared Property