I had a recent requirement where I needed to temporarily replace the homepage of a website running Drupal with a simple HTML page. I wanted to do this without doing lots of changes to the site templates so I needed a solution that was easy to turn on and off and would still retain the Drupal site as it was. I found the simplest solution was to add a rule to the DirectoryIndex rule in the sites .htaccess file. Here is the rule I used.
Searching all files in a directory and sub-directories for a particular term is really useful and comes in handy in all sorts of situations. It is available on all Linux systems and the basic syntax is as follows.
grep -r -i pattern directory
The -r flag is used to recursively search underneath the given directory and the -i flag is used to ignore case. The pattern is a normal regular expression, which can be changed to an extended set by using the -E flag.
I have talked before about running Selenium tests in PHPUnit but I have only recently come to properly automate things. Getting a Selenium server to start and stop in a script is relatively easy and can be done in a simple script. My original script for running a directory of PHPUnit tests was as follows.
I was at a meeting of the Manchester Web Performance Group the other day where Tom Taylor gave a talk about some of the performance testing tool he uses at Laterooms.com. He used a ruby script to set up some preferences in Firefox which then ran Selenium to open some web pages and test them with YSlow. The results of the YSlow inspection are then sent to a Show Slow server where the results can be graphed over time.
When Mike Bell approached me several months ago and said we should do a Drupal camp in the north west I was completely on board with the idea. So for the past few months I have been working with Mike and a group of people from the North West Drupal User Group (NWDUG) to create such an event. The result was DrupalCampNW2012, which was held from Friday 23rd to Sunday 25th November. The venue was the new University of Salford campus buildings in MediaCityUK.
I recently saw an implementation of a Twitter wall that used node.js to run searches on Twitter and post the results on a webpage. I had been wanting to create something using ReactPHP so I thought this was a good opportunity to have a go. ReactPHP, if you haven't heard of it, is an event-driven, non-blocking I/O that is essentially the PHP equivalent of node.js. The major difference is that ReactPHP is written in pure PHP with no extra components, whereas node.js is a collection of different programs, interfaces and languages.
I spent what seemed like an eternity today trying to figure out something in a form I was creating on a Drupal site. I was building a multi step form with previous and next buttons, both of which were submit elements like this.
Adding an alias to your system is a good way of saving time when remembering complex commands. You can reduce a command down to a quick two letter command that is easy to remember.
The alias command can be used to assign an alias on the fly. You can create an alias to 'ls -lah' by typing in the following into the command line.
alias ll="ls -lah"
Now, when you type 'll' you will actually run the command 'ls -la'.
Running a simple syntax check over your files is a good way to save time. This can be when testing code but best practice is to not to even commit code that contains syntax errors.
You can syntax check a single file using the -l (lowercase L) flag with the PHP executable like this.