Skip to content

Instantly share code, notes, and snippets.

/** @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

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.

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.

@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
@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
Multiple Step Forms
===================
This module implements a techniques that can make your Drupal forms easier to
implement and easier to use: [breaking a form into multiple steps][1].
[1]: http://www.appnovation.com/create-multiple-step-form-drupal-6
<?php
/** @file
*
* Allow users to save their progress and resume forms.
*
* @author Thomas Sutton <me@thomas-sutton.id.au>
* @copyright Bouncing Orange
* @created 2010-11-01
*/
@thsutton
thsutton / response-header.js
Created November 6, 2010 09:17
Get the value of an HTTP response header in JavaScript
/**
* Read the value of a header in the current document.
*
* This uses a [single] XMLHTTPRequest to do a HEAD of the current document
* and fetch HTTP response header values. Note that the implementation is
* rather stupid in that it spins waiting for the XMLHTTPRequest to complete
* if it hasn't been called yet.
*
* @param name string
@thsutton
thsutton / enumerator-filter.hs
Created December 15, 2010 09:42
A first attempt at making an enumeratee equivalent to the filter function for lists.
import Prelude hiding (sequence, map, head, filter)
import Control.Monad.Trans (lift, MonadIO, liftIO)
import Data.Enumerator
-- | Enumerator analogue of 'Data.List.filter'.
filter :: Monad m => (a -> Bool) -> Enumeratee a a m b
filter pred (Continue k) = do
x <- head
case x of
project="$0"
if [ -z "$project" ]; then
project="project"
fi
mkdir "$project"
cd "$project"
# Create the new cabal-dev sandbox and install snap
cabal-dev install snap