Bash script to find most common 404

Mar
04
2010

Following Kevin Hankens post on why you shouldn't ignore Drupal 404 errors, I decided to go through yesterdays error_log on our live apache server (the one which hosts www.pponline.co.uk, www.sportbusiness.com and www.mychild.co.uk alongside around 40 other dupral sites).

MySQL: Count occurrences of string

Feb
17
2010
Tagged in , , &
Drupal and MySQL

Today I needed to quickly find out a list of node's which did not contain a certain token (one we use on PPOnline to insert adverts into articles). There were meant to be 2 of these tokens per article but we had noticed some only had one. Some didn't have any at all!

Now, this might already exist as a neat function somewhere, but I couldn't find it. So I wrote this little query to find the number of occurrences of a substring in a larger block of text.

I did look into using the SUBSTRING() and SUBSTRING_INDEX() commands, however I couldn't see a way of efficiently using them to find any number of occurrences. So I settled on the following…

Generate Entropy for GnuPG

Jan
22
2010
Tagged in , &
GnuPG Logo

Has anyone every tried to generate a GPG (or GnuPG) key? I have… and I received this error…

Not enough random bytes available.  Please do some other work to give
the OS a chance to collect more entropy! (Need 284 more bytes)

Drupal, ImageCache & Performance

Nov
14
2009

A while ago we started having issues running a website. Bandwidth. Upon investigation, we saw that the majority of bandwidth was being use by image files and of those, lot was from the ImageCache folder. It was also causing a lot of excess server load by consuming Apache processes. Something needed to be done.

Drupal Autocomplete in Vim

Aug
18
2009
Tagged in , &
Vim Logo

I recently stumbled across a handy tutorial on configuring a Drupal dictionary in Vim for autocomplete. I also remembered helping a friend out with a similar problem, Drupal syntax highlighting for Nano. I then combined the two and have a simple to follow tutorial for generating your own drupal 6 dictionary for vim autocomplete!

Patching can cause permission denied errors

Aug
11
2009
Tagged in , , &

I just updated this server to PHP 5.3. As all my sites are Drupal 6 it seems I have a few issues ahead which mean I need to patch Drupal to stop PHP complaining about deprecated stuff…

So I headed over to the post on drupal.org which is discussing 5.3 compatibility in Drupal 6 (which I personally think SHOULD go in) to grab a patch. I applied the patch with no problems. I refreshed a page and got a white screen so I checked the logs only to see…

Vim Tips: Replace 0px with 0

Jun
23
2009
Tagged in , , &

I like little wins. I was just looking through the CSS file for this site and noticed that - for some reason - I'd used 0px instead of   a LOT of times. Most values need numbers (10em, 10px, 10% and 10pt are all very difference sizes) however 0 is one of the few valeus which is the same in all cases (0px, 0pt, 0% and 0 are all zero!). This adds up to wasted data and bandwidth; admitedly not a lot, but still Every Little Helps!

So I fired up Vim. Initially, I just did:

Indenting in Vim

May
27
2009
Tagged in , &

Ever had that situation where you've enabled :set paste and pasted in hundred of lines of code into vim only to see it all fully left aligned? I just did… And bugger going over each line and manually indenting it! Want know how to indent a visual block of text?

How to use "sed" to find and replace

May
26
2009
Tagged in , , &

After Worldpay recently changed to use the RBS system, I was tasked with finding every instance of select.worldpay.com/wcc/purchase in our forms and replacing it with select.wp3.rbsworldpay.com/wcc/purchase. There appeared to be thousands of files and I wasn't going to do it manually…

PHP's display_error, not always a good thing!

May
19
2009
Tagged in , &

I just hit an interesting issue while trying to upgrade a Drupal 5.18 site to Drupal 6.12. I went to the update.php page and noticed an error at the top implying the url_alias table was having issues due to Drupal 6 expecting a language column which wasn't present in Drupal 5. "No problem" I thought, "That'll get fixed during the update!". This was the beginning of a long learning curve through the new <a href="http://api.drupal.org/api/group/batch/6">Batch API</a> system!

Backing up a Drupal Database: Redux

Apr
27
2009
Tagged in , , , , , &

Back in November last year, I wrote a script which handled backing up a drupal database. There were quite a few comments and I've taken some on board and developed the script on a little further to be more "generic".

One of the main complaints/suggestions about my previous snippet was the hard coded nature of it. The follow script offers far more configuration through the command line itself.

I'm a lazy linux piper

Mar
11
2009
Tagged in , , , , &

This morning I updated a site to the latest release of Drupal 5.16. Nothing special there at all. I've done that many times as has (hopefully) mabye other drupal devs… However, I'm a bit of a newbie when it comes to SVN. Didn't I mention this drupal site was in an SVN repository? ;-)

So, I've svn copy'd the trunk to an "update_to_5.16" branch, checked out this branch and done a cvs up -dP -r DRUPAL-5-16. Everything is going according to plan so far. Next I run svn status to get a list of files which I need to mark as added or deleted (or to list anything else which has gone wrong). What happens next is I get a list of hundreds of CVS Template files which have been added to the CVS folders. For example…

Free Kasha Wallpaper

Feb
24
2009
Tagged in , , &

My friend over at Kasha Music has just released a REALLY nice free wallpaper. It's based on a starfield background with Kasha's face screened over the top. It's really effective!

How to import users into Drupal using Devel

Jan
15
2009
Tagged in , , &

The first test is a valid email address test. The second test is if an account exists for that email address. The third is if the username, generated by the "user" part of the email address, exists. If there are any issues, the "error" is logged into and array and printed at the end.

As the function goes along, a user is saves with the user part of the email address as their name, a random 6 character password and the email address as the contact address. In this example, it also give the user role number 3, which was our "subscriber" role.

Neat commenting in Vim

Jan
12
2009
Tagged in , , &

I am a bit of a "neat geek" when it comes to coding. Things should be indented neatly and should have well laid out comments! Why? Well… It's easy to do and in 6 months time when you look at your code you will appreciate it! It will also me even more appreciated by another developer in less than 6 months time ;-)

Finding the largest files in a folder

Jan
06
2009
Tagged in , , &

I just needed to find the largest files in a folder (in an attempt to find out why it was so bloody huge!) and have ended up with the following handy combination of commands…

find /path/to/folder -size +1M -print0 | xargs -0 du -h | sort -nr

New Dr who is Matt Smith

Jan
03
2009
Matt Smith as Dr Who

The new Dr Who appears to be Matt Smith!

Whoa! He is so young! Almost depressingly, he is only 11 days younger than ME. Yes… The new Dr Who is younger than me.

I think he could be good. When the replaced Christopher Ecclestone with David Tennant I was a little wary and wondered if he could pull it off - which he obviously did. This guy looks (from the clips) like he should fit the character perfectly!

Lighttpd book

Dec
30
2008
Lighttpd Cover

As many readers might know, I use Lighttpd a lot. I really like it for many reasons. Its fast, free, easy to configure, very light-weight (handy if you're running a cheap VPS or a low end server)… This is very apt for me because almost EVERY website I make now is a Drupal site (why would you use anything else?!).

Drupal is, inherently, a rather large web app - mainly because of its ability to do nigh-on anything. This means one needs to be a little careful about what you do with your resources. From my experience, Apache (which is bloody brilliant) can tend to get a little "bloated". I know there are ways of slimming it down and improving it, but I also like playing with new toys too! This is when I moved over to Lighttpd

OpenSuse 11.0 Issues

Dec
12
2008
Tagged in , &

After about 4 days of using OpenSUSE 11.0, I'm not overly impressed with it in comparison to RedHat Enterprise 3/4/5, CentOS 5, Fedora 9 and Ubuntu 8.x (other distro's I've used). OpenSUSE has some annoying habits and default/unusual configurations…

Free Christmas Wallpapers

Nov
30
2008
Tagged in , , &

As part of my RSS reading, Smashing Magazine is rapidly becoming something I look forward to reading. Every month they do a roundup of desktop wallpapers which include a calendar and are, in some way, seasonal. This month is no exception! They have a fantastic selection of christmassy wallpapers for you to chose from and they're all free!

Follow Me

Recent comments

Answers 2 days ago
Replies.... 1 week ago
Or in 1 week ago
A few tweaks 1 week ago
Nice 1 week ago
Thanks a million 1 week ago
Syndicate content