Knowledge Base

This is my personal knowledge base - a place to hold all the things I know (or need, or want, to know) and am likely to forget.

By making it public, I hope to:

  1. Refine my knowledge with the contributions of others; and
  2. Share the knowledge I gather with others.

The biggest challenge, at least in the short term, is developing the discipline to come here with everything I learn, and everything I want to learn.

And, in the short term, with my current obsession/compulsion being catching up with the Drupal community, it will disproportionately reflect that project.

Note that not everything here represents firm knowledge - research projects (things I'm learning about) will appear here, dynamically updated as I refine my understanding...

Thanks for your contributions.

 

 

Drupal

My knowledge about Drupal development and administration is documented here. In the short term, my investigations of the best development environment (source code editor/IDE, file system layout, CVS/SVN setup, etc.) for my work style will be the focus. Input is, of course, welcome.

 

Coding tips

Recipes for particular tasks when doing Drupal development.

 

Theming node add/edit forms

Here's the reference: http://drupal.org/node/101092

Will report back on my experience...

 

Development Environment

I'm transitioning from Windows to Mac, and still working at establishing the best development environment for my needs. What tools am I most comfortable with? I'm trying TextMate at the moment, based on several recommendations - will probably make another stab at Eclipse (too much memory-wise for my old Windows PC) as well. I also will be documenting my experiences with helpful modules like devel and coder, approaches to managing revision control (CVS/SVN), synchronizing production/test/development sites, etc.

Starting point: Developing for Drupal in the handbook at drupal.org.

References:

Drupal Eclipse

How to Successfully Incorporate Eclipse IDE into a Drupal Workflow

IDEs for Drupal and more

Maintaining Drupal sites using version control

Development tools

 

Eclipse

Now trying Eclipse as my Drupal development environment... Starting with Rob Loach's approach:

  1. Download and install the latest Eclipse Classic (3.3.2 at this writing).
  2. Next, goto Help->Software Tools->Find and Install..., check off the Europa Discovery Site, then open up Web and J2EE Development and install Web Standard Tools (required by PDT). Be sure to click Select Required to pick up other necessary stuff (XSD components at this writing).
  3. Next, PDT and JSEclipse (using the attached DrupalEclipse.xml, based on Rob's).
  4. Follow the configuration instructions at http://drupal.org/node/75242.
  5. Other preferences I'm using, which may be of general interest:
    1. General->Appearance->Label Decorations - enable CVS.
    2. General->Workspace, make sure Build automatically is off.
    3. JSEclipse, turn on Replace tabs with spaces.

Files - structure and maintenance

Maintaining my Drupal sites, both development sites on my computer and production sites on my webhost. Use of CVS & SVN, copying back-and-forth, etc....

 

SVN

As a first step, I simply want to use SVN to track changes in my local development environment. Simple step-by-step instructions are lacking on drupal.org, but Nick Sergeant's blog got me started:

  1. svnadmin create repos

References:

Nick Sergeant :: Blog - Painless Drupal revision control with CVS and Subversion on a sharedhost

 

Note: I did set up a repository and do an initial commit, but right now I'm more inclined to leave it to Time Machine... 

 

Komodo

Tips on using Komodo for Drupal development.

 

Source Code Control

There are currently issues with using both CVS (for updating/committing from/to drupal.org) and SVN (for maintaining local history). Track:

.svn and CVS metafiles confuse komodo

Bug 71475 - per-project SCC system prefs

MAMP

So, I've installed MAMP on my MacBook, quite a bit simpler than installing and configuring Apache/MySQL/PHP individually...

My question is - does MAMP PRO provide anything worthwhile to me (i.e., anything I can't accomplish via httpd.conf/php.ini/mysql command line...)?

 

Javascript

Useful hints and tips involving Javascript.

Javascript date parsing and formatting

Handy functions for parsing and formatting Javascript dates:

http://www.xaprb.com/blog/2005/12/20/javascript-date-parsing/ 

PostgreSQL

I'm doing my first project using PostgreSQL (I've always used MySQL in the past). Hints, tips, etc.:

First, I found a Mac OS X binary. At this writing the version of PostgreSQL is 8.2.3. The instructions say it is only tested on Mac OS X 10.4 (Tiger), but it works fine for me on 10.5 (Leopard).

To access a database from a shell:

psql -U username -h localhost -d databasename

To export a database to SQL, for loading onto another pgsql server:

pg_dump -C -O -h localhost -U username databasename >filename

To import from an export performed as above (I expected to use pg_restore, but no...)

psql -h localhost -U username -f filename

 

 

Testing browser string

Finally getting back to working on the old browscap module, and needed to ape a particular browser string. I found this article on configuring Safari and Firefox to accomplish this:

Spoofing the User Agent with Safari or Firefox

So, first I do the command using Safari's actual browser string, so I can easily revert to it later:

defaults write com.apple.Safari CustomUserAgent "\"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_2; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.1 Safari/525.18\""

 

Livin' in a Virtual World, ...

... or, How I Learned to Stop Worrying and Love the 'Net...

<to be fleshed out later... Basic idea - all the information in my life - financial, technical, personal - that would otherwise be on my computer or on paper should be out on the net. Tradeoffs - security risks (server intrusions on the net, physical intrusions in real life), integrity risks (net info presumably backed up, risk of businesses running the server going out of business - vs. risk of my own computer crashing, home burning down, etc.), convenience (info on net searchable, can be organized more flexibly - real-world info is literally at fingertips, not vulnerable to lost connections)...>

 

Mac

I'm transitioning from Windows to Mac OS X - as I learn how to best make use of the new environment, I'll drop hints & tips here.

 

Backups

I needed to establish backups. I have a 300GB external hard drive - but it was formatted with NTFS (thus unwritable by Mac OS X), and it contained many, many GB of music files. I had already imported the MP3s into iTunes on my MacBook, but Sarah has been using the external drive to sync her MP3 player through her Windows laptop (using MediaMonkey, a much better music library manager than iTunes, but which unfortunately won't sync to my iPhone). It would also be good to make it easy for her to backup to the external drive as well, and there's a file or two we'd like to share. The initial plan was to reformat as FAT32 and pass the USB cable back-and-forth, but FAT32 can only handle up to a 127GB partition. So, the plan changed to semi-permanently mounting the external drive on my MacBook - and, while I'm at it, sharing the music files directly from my iTunes Library rather than having them duplicated on the external drive (particularly since Time Machine is backing them up there anyway).

Note we have cable Internet through a wireless router, both computers link to the router directly.

So, the whole process - at least as best as I can reconstruct what I would have done if I'd known what I was doing, instead of struggling through trial-and-error-and-semi-helpful-forum-posts...

  1. Plug the drive into the MacBook, and reformat (through Disk Utility) as Mac OS Extended (journaled).
  2. Create a folder named Shared on the external drive. Two reasons not to share the drive from the root - don't want to share the Time Machine backups, and when sharing the root No Access does not seem to available as an option for Everyone (but it is available for the Shared folder). In Shared, create an alias Shared Music to point to the iTunes library folder. Create the SarahBackups folder, for the obvious purpose. Copy files to be shared into Shared.
  3. In System Preferences->Network, with AirPort selected click Advanced... Click the WINS tab, and enter MSHOME as the Workgroup (I tried using a custom workgroup, but the Windows system keeps defaulting back to MSHOME).
  4. In System Preferences->Sharing, check on File Sharing. Under Shared Folders, click the plus  (+) button and choose the Shared folder. Under Users, change Everyone to No Access. Select Guests and click the minus (-) button to remove. Click the plus (+) button to add users (me and Sarah) permitted remote access (Read & Write).
  5. Click Options... and select Share files and folders using SMB. Select the accounts which can log in to the share.
  6. On the Windows system, from Control Panel and go through the Network Setup Wizard:
    1. Yes, use the existing shared connection for this computer's Internet access.
    2. Description/name already filled in
    3. Workgroup name: MSHOME
    4. Turn off file and printer sharing (don't want to share anything from this machine).
  7. Now, here's the part I was missing (and it's quite likely step 6 would have been unnecessary if I had tried this first) - go to Start->Run and enter \\w.x.y.z\ (where w.x.y.z is the IP address you see in the Mac Sharing System Preferences). Click OK.
  8. A username/password prompt comes up - login using your Mac shortname and password. You get an Explorer window with - well, everything accessible to your account on the Mac, it seems... You can now right-click on the share and map it to a drive letter.

Now, at this point it turns out the alias to my iTunes folder (created in Finder with Make Alias) shows up on the Windows side as a 0kb file instead of a folder. Going to the shell, ls -l shows the attributes as -rw----r--@ (@ indicating extended attributes). I created a symbolic link from the shell (resulting attributes lrwxr-xr-x) - that seemed to do the trick.

Next, see about sharing the printer...

 

File permissions problem on MacBook

Having some file permission trouble on my MacBook - files that I cannot edit/mv/etc. although I own them and permissions are 755... So, how about good ol' su?

How to Enable the "root" account on Mac OS X

The Quick CLI Method (sudo passwd root) worked fine for allowing me to su - but the root account can't seem to do anything to these files either...

To more fully describe - I have installed MAMP, and under its htdocs directory I have the roots of my local (Drupal) websites. Pretty much everything has 755 permission (rwxr-xr-x), is owned by my account which has administrative permission, and is in the staff group. I can do what I want with files in, say, /Applications/MAMP/htdocs/pathauto6 - but trying to edit and save, or rename (mv), or chgrp, or chown files in /Applications/MAMP/htdocs/pathauto6/sites/default fails with "Operation not permitted". The root account has no more luck than my own account. What's up with that?

Well, I'll tell you - the "immutable" flag was set on the folder (default). This seems to be an obscure, under-documented Mac OS X feature that overrides normal file permissions. If I'd never heard of it before (and I wasted a ridiculous amount of time tracking it down), how did it happen? My best guess is it has something to do with copying files from an NTFS-formatted external drive, which I used to transfer files from my old Windows system to my new MacBook - perhaps Windows read-only permissions get translated to the immutable flag when copying?

 

Mac OS X defaults command

Full filesystem in Finder/Time Machine

The Mac OS X Finder by default only shows stuff regular people need to see - it doesn't show the entire filesystem. Time Machine follows Finder - which means that, although Time Machine backs up everything, you can't see and restore... oh, let's say /usr/local/pgsql/data. To make the entire filesystem visible under Macintosh HD, you need to go to the shell and say

defaults write NSGlobalDomain AppleShowAllFiles YES

Then, of course, reboot.

I'm going to have to find some time to track down what other neat things can be done with that defaults command. And, how to hide the extra stuff now showing on the desktop.

Disable .DS_Store files on network drives

Mac OS X drops little .DS_Store files in every folder you visit, including network drives. It can't be stopped locally, but to at least be more polite about other people's drives:

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

 

Web server-generated email under MAMP

Developing on my MacBook, with the MAMP stack installed, attempts by any of my local Drupal sites to send email out to a Drupal user (say, a new account notification) go into the local mail queue and get stuck there. /var/log/mail.log shows  "Operation timed out" errors from Postfix, whether sending to an account on my webhost or my Gmail account. telnet to port 25 (using a couple different hosts) also fails with "Operation timed out".

And... now I feel like an idiot, because I had this problem a few years ago with Comcast - my ISP (now RCN) is blocking port 25. Solution:

  1. Edit /etc/postfix/main.cf
  2. Add relayhost = smtp.rcn.com

Took a few tries with telnet [mail|smtp].rcn.[com|net] 25 to find the right server, but I'm all set now...

 

iPhone silenced

Everything was just fine on my way home last night - earbuds in, music flowing, phone call clear as a bell... But last night I tried making a couple of phone calls from home - no sound of ringing, no audio in (or out, so I was told) until I put the call into speaker mode. Panic! But Googling "iPhone sound" turned up the answer quickly - plug in the earphones and unplug them again. Apparently it sometimes misses that you've unplugged the earphones.