Web design, programming, graphics, and pretty much anything else I care about.

Retrieving custom field formats in Drupal template files

This is part of CCK:

('field_cckfieldname', $node->field_cckfieldname[0], 'machine_name_of_custom_format')

You send it the name of the field you are referencing, the data, and the name of the format you want. If you don't include the format, it uses the default for that field. It returns fully-formatted HTML. Example,

<span class="date-display-single">Friday, October 16, 2009, at 8:00 pm</span>

Node reference URL widget not checking user access?

I seem to have a bug in the Node reference URL widget module (http://drupal.org/project/nodereference_url). It is not checking to see if the user has the correct permissions to create a node of the type being referenced. The link to create a node should not appear if they do not have access.

On this line

if ($field['referenceable_types'][$object->type] && user_access('create ' . $object->type . ' content')) {

I replaced $object->type with $target_type and it seems to work fine.


WebFM icons

WebFM uses multiple methods for determining what type of file it is dealing with, and thus, what icon to display. When inserting a file into the database it used the php function mime_get_content to determine the type of file. If this function does not exist WebFM uses its own function to determine the mime type. This function is in the webfm_mime_types.inc file. Basically, it just goes by the file extension.

Emacs, stop leaving ~files everywhere

Put this in the ~/.emacs file to stop creating backup files (~)

(setq make-backup-files nil)

Emacs php-mode

To get php-mode (with colorization) to automatically be invoked for *.php and *.inc files, put the following in the ~/.emacs file:

(load-library "php-mode.elc")
(setq auto-mode-alist (cons '("\\.php$" . php-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.inc$" . php-mode) auto-mode-alist))
(add-hook 'php-mode-user-hook 'turn-on-font-lock)

Finding files to download using Google

Sometimes people will leave the directories of their websites open, and you can easily find what is in them using Google.

Use the following search text

-inurl:htm -inurl:html intitle:"index of"

This will search for those open directory listings, and all you need to do is add your search parameters.

For example

-inurl:htm -inurl:html intitle:"index of" mp3 U2


-inurl:htm -inurl:html intitle:"index of" mov "Shrek 2"

How to find out what tcp/ip port is associated with what Windows process

Ever look up port information on a Windows computer and thought "what service or application is using that?"

Use the NETSTAT command with -o.

netstat -ao (-a will display all connections)

The result will give you a table that includes the protocol, local address (with port), foreign address, state, and PID. The PID is the windows process id. You can then use task manager to look up the PID and see what it is associated with.

Repetitive Defects in Printer Output (print quality problem)

Repetitive vertical defects in printer output is an indication of a problem with one of the revolving parts of the printer that is in contact with the print area of the paper, such as a roller or drum. The most common offender is in the toner cartridge, but other parts could also cause a problem. The key is knowing the distance between the defects.

This will tell you which part is the problem, because the distance indicates the circumference of the part.

HP Laserjet 4000 and 4050

Creating Custom Keyboard Shortcuts in Mac OS X (10.3 +)

Starting with OS 10.3, Apple added a feature for users to create custom keyboard shortcuts to execute menu commands.

Go to System Preferences -> Keyboard & Mouse -> Keyboard Shorcuts

You will see a full list of the keyboard shortcuts already defined, with customized ones placed at the bottom. Editing a shortcut is as simple as clicking the box where the shortcut is displayed, and typing in a new key sequence.

Mac OS X Keyboard Shortcuts

These are the most useful of the keyboard shortcuts available in OS X. There are more, such as commands that are specific to menus or certain windows, but this list has mostly the universal ones. You can also create custom keyboard shortcuts. I have instructions for doing so -> Creating Custom Keyboard Shorcuts in Mac OS X

At Startup