sed and awk are two powerful but often overlooked data processing tools, and if you know how to use them effectively you’ll be well ahead of many sysadmins and developers. sed sed is an in-place stream editor, that is, it accepts input from a file or STDIN, manipulates the data stream in some way, and […]
Category: Programming
grep
grep is a useful utility that finds fixed strings or patterns of text in a given file or standard input. Used in conjunction with error logs or debugger output, grep can help a programmer identify errors in an application code base or filesystem; to help with this, grep understands regular expressions, what it calls “extended” […]
The Drupal Database: Querying From the PHP filter
If you have a multi-site Drupal 7 install, or simply another database living alongside your Drupal database, sometimes you may want to pull a few records from the other database for display on your Drupal site. Displaying data from the Drupal database is pretty easy since you can just use Drupal’s built-in db_query function: (If […]
Python: MIME/SMTP
Send a MIME-encoded email in HTML and plain text using Python’s smtplib (Python 2.x). Just call ‘mailer’ with a return address, list of recipients, message subject and body.
Perl File Change Notifier
This notifies users by email (sendmail) when a particular file changes on a Unix-style filesystem. This was originally written for a page that was being modified by multiple people in the wiki software shipped with Apple’s OS X Server. This worked all right as a hack, but if you need extensive content management or granular […]
Python LDAP Lookups
An example of a Python LDAP lookup, Python 2.x. This one uses the on-campus LDAP service at UC Davis, so just change the LDAPServer and searchBase for another LDAP server. Or you can print the results a little more nicely:
Fixes for Drupal Webform
I was seeing a couple of errors in the Drupal Webform module, and this page describes the fixes I used to eliminate them. This applies to version 3.x so if you’ve upgraded to 4 I doubt this is relevant anymore. As described at http://drupal.org/node/1462986. To fix this I found #webform_component in the theme_webform_display_select() function in […]
Linux Command Line Tricks
Here are some Linux command line tricks I use on occasion for search and replace. This presumes the use of GNU utilities, so commands and results will vary on different platforms. Some cheat sheets: Sed | Awk | Perl | Bash See also the sed/awk and grep pages. Replace A with B in all files […]
Drupal Development
Notes on Drupal development using Devel and some of its children. Install and Enable the Devel Module Devel can be downloaded from Drupal.org or by using the drush pm-download devel/drush pm-enable devel commands. Drupal Development with Devel Among other things, devel allows you to see inside the Drupal objects and arrays containing the different properties […]
Drupal 7 File Descriptions
I needed to increase the maximum length of the Drupal 7 file description field that appears when you enable the File module and allow uploads in nodes. By default, the file description field restricts input to 128 characters. The Drupal 7 File Description Field This is set in file.field.inc in the File module in core […]