2011-06-14

Letting any Mac use a Remote Disc

Remote Disc is a Mac OS X feature where one Mac uses another Mac's CD/DVD drive as if it were its own, while connected over the network.

Any Mac can choose to share its DVD drive, via System Preferences > Sharing > DVD or CD Sharing. By default, only MacBook Air computers can be a client of Apple's Remote Disc feature.

But when a Mac has a faulty DVD drive, this feature would be handy as a workaround until the drive can be repaired. So can we get a non-Air Mac to be a Remote Disc client? Yes. This blog post explains that writing two settings via the command line in the Terminal app tells the Finder to look for Remote Disc servers on the network.

defaults write com.apple.NetworkBrowser EnableODiskBrowsing -bool true


defaults write com.apple.NetworkBrowser ODSSupported -bool true

Then restart your Mac. "Remote Disc" should appear in the sidebar of a Finder window.

2011-05-25

Work Music

soma fm → Streams. Ambient streams. Keeps the hands typing and the brain coding.

In AAC format, as well as the older MP3. iTunes-friendly links.

One stream in particular works for me: "Mission Control" where ambient music is ingeniously overlaid with the chatter patter of real NASA mission control personnel and astronauts -- sometimes live, sometimes recorded.

2011-05-21

Location of Postgres Logs on a Mac

For Postgres 9.0.4 on Mac OS X 10.6.7, I found logs here:

  /Library/PostgreSQL/9.0/data/pg_log

Accessing Postgres On The Command-Line on Mac OS X

I simply wanted to restart the Postgres server. I'm trying to enable SSL/TLS, and such settings are checked only when Postgres starts. Postgres is set to auto-start when the Mac boots, if you install using EnterpriseDB's free Mac installer.  But I want to restart Postgres manually, without rebooting the Mac.

You'd think restarting Postgres would be easy, but no. The pgAdmin program is not built to stop or start the Postgres server, at least not that I could find. The command line tool "pg_ctl" can check the status of a server as well as start and stop. That command even has a handy "restart" option that effectively does both the stop and start. But I cannot run that pg_ctl from my own command-line in the Terminal app. The command must be run as the 'postgres' unix user created by the Postgres installer.

So, the answer is simple, right? Run the command as "sudo", the superuser? That usually is the answer with Mac command-line limitations. But, no, not in this case. The command must be run as another user, not just with enhanced privileges. So a bit of googling might lead you to use the "su" command to act as another user, like this:
  su postgres
This fails though I don't know understand why. After much googling, I finally found the trick:
  sudo su - postgres
It takes the combination of "sudo" and "su". Also notice the hyphen with spaces.

Now I can (I mean 'postgres user can) run Postgres utility programs. The next problem is that those utilities are not found automatically from the command line. So instead of just typing "pg_ctl" in the Terminal, type the entire path to the program, such as:
  /Library/PostgreSQL/9.0/bin/pg_ctl

Tip: Rather than type, just find the programs in the Finder (or the very handy Path Finder app), then drag-and-drop to the Terminal app.

Yet another problem to solve. Some of those commands need to know where the Postgres "data" folder is. Again, you can drag and drop the path, or use Path Finder's Copy Path > Unix menu item.

So for example, to check the status of the Postgres server, run these two lines in the Terminal. Run them separately, one after the other.
  sudo su - postgres
  /Library/PostgreSQL/9.0/bin/pg_ctl status -D /Library/PostgreSQL/9.0/data

To avoid including the full paths, you can tell your Mac to include those folders when looking for programs. But that’s a topic for another day.

I'm using Postgres 9.0.4 on Mac OS X 10.6.7.

2011-05-17

I Wish Postgres Had…

Here is my wish list for Postgres features.

  • Feedback system
    I have yet to learn how to submit bugs & feature requests to the Postgres developers. So if anyone knows how I should relay this list, please post a comment to tell me.
  • Multiply String function
    It can be surprisingly handy to have a command that takes a string, repeats that string a certain number of times, and returns the result. One usage is padding a string with spaces, underscores, or periods, as seen in a book's Table Of Contents. The command could be added to this collection, and might look like this:
    Multiply( string, numberOfTimes ) --> String

2011-05-10

Postgres Server Settings

Postgres has hundreds of settings in its configuration. Nearly all of them have defaults appropriate to most of us most of the time. Here's a few you may want to consider changing.

These settings are found in the pgAdmin app menu Tools > Server Configuration > postgresql.conf.

• superuser_reserved_connections

Sets aside a few of maximum number of connections for use only by the Postgres superuser, usually named 'postgres'. Without this setting, if your server reaches its limit, you will not be able to logon as an administrator. That's not good, so turn this on and use at least the default of 3 connection slots.

2011-05-09

Tips On Creating Login Forms

This article in Smashing Magazine has a bunch of tips and techniques to consider when building Login forms and Account Creation forms. For example, for web forms they gives alternatives to those annoying Captchas such as the Honeypot-Captcha and timestamp analysis.