Skip to content

Instantly share code, notes, and snippets.

@thsutton
thsutton / custom-breadcrumbs-pathauto.patch
Created October 28, 2010 06:08
Handle <pathauto> more usefully in custom_breadcrumbs 1.5
This patch applied to Custom Breadcrumbs 1.5 and affects the way it processes
breadcrumb links when the user specifices `<pathauto>`: rather than cleaning
the whole path with *pathauto* (and thus killing any slashes), it passes *each
component* through.
Note that this is a bit of a hack: a robust implementation would clean the
substituted values as the path is being built. As it stands any `/`s in the
substituted values will remain in the output.
diff --git a/htdocs/sites/all/modules/contrib/custom_breadcrumbs/custom_breadcrumbs.module b/htdocs/sites/all/modules/contrib/custom_breadcrumbs/custom_breadcrumbs.module
@thsutton
thsutton / .gitignore
Created October 26, 2010 13:34
An example Snap Framework web-app which displays data from a PostgreSQL database accessed with Takusen.
.DS_Store
._*
/dist/
*.log

Munge a form field into a multiple select (and back!)

This is a sample Drupal module that modifies an existing form field to display it as a multiple select without having to modify the handling code. As far as the form's "owner" is concerned, the user enters a comma-separated list of values.

The goal is, as you can probably tell from the $form_id, to turn a profile field into a multiple select of values from elsewhere. This is probably less than ideal, but I can't figure out a better way to achieve this.

A simple PHP wrapper for MAMP

MAMP is a pretty crappy environment, but it beats the shit out of building a decent environment myself and is marginally more convenient than working on a Linux VM. This little script makes it more useful (for me) by providing a fake php command in the $MAMP/Library/bin directory which calls the real php from the version you've configured MAMP to use.

Just put the accompanying script in the $MAMP/Library/bin directory and make it executable, then make sure that $MAMP/Library/bin is in your $PATH before /usr/bin (and any other directory containing an executable called php).

Then any invocation of php will be executed with the correct version (as far as MAMP cares, anyway!)

Future improvements include using the "next" php in $PATH if MAMP is not running.

/** @file
*
* This code implements wraps and exports the OpenSSL hashing functions to Lua.
*
* To use this code arrange for it to be loaded by your Lua interpreter either
* by compiling it in or loading a shared library. You'll need to pass various
* flags to your compiler to get it to use the OpenSSL libraries, etc. I used
* something like this:
*
* gcc `pkg-config openssl --cflags --libs` -c lhash.c