verbose remote ssh (with echo)

I usually manage website deployment with bash scripts that run remote commands on the servers

In order that I can see what is going on and debug any errors verbose output is useful.

Running "bash -ex" causes each line to be output as it progresses and halt on any error so that you don't miss it.

within the remote command "set -x" cuase bash to echo all commands

#!/bin/bash -ex
ssh -T user@server << EOF
set -x
echo foo > /dev/null
EOF

Read more

Export from Git for Drupal site releases

I'm used to how svn export works, and have used this in a number of release scripts.

Git doesn't quite have an equivalent

There is

git archive

Which creates a tarball rather than a set of files, and while you can export a subset of the repository you still get the full path in the tarball.

and

git checkout-index

Which creates a set of files (these can be locate outside the working copy) but requires a local repository.

Read more

Instance parameter for drupal field_create_instance($instance)

The code in chapter 7 of pro Drupal development has a bug.

The $instance array that you need to pass to field_create_instance() needs to be as below.

Note that the display array has the keyword, 'default' for the default display - ie a node on it's own page 'teaser' looks like the right value for teaser. Other view modes are possible too.

Read more

node_save tags by term name with auto addition of new tags

Drupal lets you add a taxonomy term to a node and if you use the GUI you can have a nice auto-complete widget that takes term name - and iof the term doesn't exist yet you get a new term created when you save the node.

I wanted to access the same functionality on node I am generating from external data.

The key is to create the term array with tid = 'autocreate' - this and the vocabulary ID are enough to trigger the taxonomy module to lookup the tid for you - and adda new term is required.

<?php
$node = new stdClass();
$node->type='mytype';
$node-title='foo';

Read more

Using PHP and curl with http PUT on string data

This wasn't obvious

There are various other posts on this - but mostly assuming you will put a file.

In my case I want to put the contents of a string so I needed to craete a temporary filehandle.

<?php

function put_it($url, $string) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_PUT, TRUE);
// create tempoary file handle
$oneMB = 1024 * 1024;
$fp = fopen("php://temp/maxmemory:$oneMB", 'r+');
fputs($fp, $string);
rewind($fp);
curl_setopt($ch, CURLOPT_INFILE, $fp);

Read more

RAID ext4 disk problems

One of those posts for myself in case I need to come back to this later

I have a new PC which is very fast apart from problems with disc access seeming slow (and the disks being physically noisy)

The following related links led me to try a solution

http://forums.gentoo.org/viewtopic-t-843292.html

http://marc.info/?l=linux-raid&m=128506852210452&w=2

/etc/fstab

UUID=317f7912-9956-41f1-9855-7bee69c950b3 / ext4 errors=remount-ro,barrier=0 0 1

NB adding barrier=0 here seems to have solved the problem

Read more

How to turn off notifications in Banshee

The music player banshee which is part of the default Ubuntu setup pops up a message each time a new track starts playing.

To turn this off

  1. Open Banshee
  2. Go to Edit, preferences, extensions
  3. Enable Notification Area Icon
  4. The Icon should now show up - right click on it
  5. Uncheck Show notifications
  6. Disable the Notification Area Icon again
    1. Very annoying - the option to turn off notifications is hidden on a menu you can't get to by default.

Read more

svn merges and excess merginfo properties

The main svn server I'm working on has finally upgraded to svn 1.5 - so easier merging is now possible - hooray.

But we've been seeing merges that should only affect one file resulting in property changes on lots of files/directories. This isn't especially harmful - but it is annoying and makes reviewing the merge harder because of the extra noise.

It turns out that this extra mergeinfo is likely because of earlier merges on subtrees http://blogs.collab.net/subversion/2009/11/where-did-that-mergeinfo-come...

Read more

Selenium test for computedStyle

I wanted to write some automated tests for CSS changes and bugs, these type of issues are quite prone to regression so re-running the tests has a large benefit.

It is possible to add new assertions to selenium via the user-extensions.js file

The following adds a test for computed style, this only works in firefox as far as I know - but some automation is better than none


//only works in firefox
Selenium.prototype.assertStyle = function(locator, text) {
var params = text.split('=', 2);

var propertyName = params[0];
var expectedValue = params[1];

Read more