The solution was very simple and I found the answer in this post about ubuntu and apache. Basically, AllowOverride is set to None for both / and /var/www/ by default on ubuntu, which is nice and secure but it caught me out on this occasion. Change the settings to AllowOverride All and create a symlink in mods-enabled to mods-available/rewrite.conf and restart apache – everything should then start playing nicely.
Category Archives: tech
Geshi and Serendipity for Code Snippets
About GeSHi
I thought “geshi” was a word but I just looked it up to link to it and it turns out its actually GeSHi (Generic Syntax Hilighter) which is a very humane way of pronouncing the thing. It is a very popular way to render source code on the web and was originally intended for phpBB. Geshi is great, it has lots of pre-made syntax highlighting rules so the odds are that it can probably already render whatever language you are coding in very nicely, however if it doesn’t then that’s fine too – it is an open standard and you can jump in and write your own.
Using GeSHi
Back to this blog, I added the “Markup: Geshi” plugin from SPARTACUS (the serendipity plugin repository) and added it as an event plugin. I had a lot of problems getting it working – putting it first in the list of event plugins eventually did the trick for me. You use geshi by adding geshi tags around the code you want to show, for example:
phpinfo();phpinfo();Styling GeSHi
Another problem I had initially was with the default resulting fonts, however these are easy enough to change and I now have colours I chose myself (illustrated in my posts about a SOAP server and PHP compilation) which is really quite easy to do. The plugin has files with all the language highlight in them and if you scroll down and look at the “color” entries towards the end of these, it is possible to just replace the red/green/blue defaults with colours that fit in with your look and feel (pink in my case, obviously!). For me the syntax files are in serendipity/plugins/serendipity_event_geshi/geshi – this is also a good place to look to see what languages you have that are supported.
I commonly use:
- php
- bash
- xml
- sql
A useful tip for styling is that the code block is placed into a div with a class named the same as the “lang” attribute – so for example I’ve got some of them resized by adding an entry to my overall css file.
Hope this helps someone, I remember having problems finding much info about using geshi in this way when I first added the plugin. If anyone is having problems feel free to post comments, I have this working on my serendipity installation so I am happy to try to help out.
Adding Markup to Comments in Serendipity
Another thing I’ve been missing is the ability to add markup in comments, such as images. Well, its back! I’ve turned on textile for comments on this site, there is a link under the comments box to a page that shows you the syntax, so feel free to add richer content to this site from now on :)
Debian Change Keyboard Layout
dpkg-reconfigure console-data
and then followed the online prompts. For reference (i.e. the next time I have this problem), the | (pipe) symbol on a US keyboard is mapped to the ~ (tilde) on a UK one.
Kubuntu Installation – Disk Partitioning
An error occurred while writing the changes to the storage devices.
The resize operation is aborted
To get around this I resized the main partition in Windows and created a new partition but left it unformatted. When I went back to the Live CD install I got the option “Use largest contiguous space” and that worked fine.
Hope this helps someone!
First Manchester Girl Geek Dinner
I’m based in Leeds, so it was about an hours drive over to Manchester. Thanks to the wonderful world of satellite navigation, I found the venue with no problems. The evening started with some mingling and drinks, and then we were all invited to take seats and help ourselves to the buffet, which was excellent. After the meal we had a variety of talks which were actually really good, I hadn’t been thinking of the talks as the highlight but they certainly were!
During the course of the drinks, the meal, and a few minutes after the talks (although it was a very late finish, 10pm or so, I didn’t leave until half past and then had to drive back to Leeds), I was able to meet and speak with an amazing selection of women of various ages, professions and backgrounds and had some interesting and valuable conversations.
Its early days for this version of this event and the plan is for it to be quarterly, I am looking forward to the next installment.
SVN Deployment and a New Site
PHP Women at PHP London
At this event I will be busy with phpwomen, wearing my t-shirt and generally making a noise and raising the profile of the group. If you are attending the conference then you are morally obliged to pop over to us and say hello, we like to meet new people. If you are extra nice to us we may give you a t-shirt! There will be women from the UK and also elsewhere in Europe and it’ll be great to meet those I haven’t met yet and also see some old friends from other conferences. An excellent way to spend Leap Year Day in my opinion :)
Logrotate Error on Ubuntu
/etc/cron.daily/logrotate:
error: error running shared postrotate script for /var/log/mysql.log /var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log
run-parts: /etc/cron.daily/logrotate exited with return code 1
What’s happening is that after all the mysql backing up and everything is done, ubuntu is trying to use the debian-sys-maint user to flush the logs, this is actually called in /etc/logrotate.d/mysql-server. On my system, we seem to have lost this mysql user.
The solution is to look for the password used in the /etc/mysql/debian.cnf file, mine looks like this:
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = xxxxxxxxxxxxxxxx
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
user = debian-sys-maint
password = xxxxxxxxxxxxxxxx
socket = /var/run/mysqld/mysqld.sock
basedir = /usr
Using the password, and some inspiration from this post on the Ubuntu Forums I recreated the user with the necessary permissions and password with:
GRANT RELOAD, SHUTDOWN, PROCESS, SHOW DATABASES, SUPER, LOCK TABLES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY PASSWORD 'xxxxxxxxxxxxxxxx'
This did the trick, as the nightly errors have now disappeared from my script. Hope this helps someone in a similar situation – if you can expand these notes then please add a comment and I will update this as needed – thanks :)
Filtering Tables in Joins in MySQL
SELECT *
FROM table1 t1
LEFT JOIN table2 t2 ON (t1.col_a = t2.col_a)
So far, so good, right? In this particular instance though I wanted to filter my results on a particular criteria so I added something like:
SELECT *
FROM table1 t1
LEFT JOIN table2 t2 ON (t1.col_a = t2.col_a)
WHERE t2.col_b <> 42
This is where it all started to go a bit weird. I wanted all the rows from the first table, plus anything from the second table that matched but didn’t have col_b equal to 42 (this is a rather contrived example I know but my real-world example was so complicated I’d still be explaining it if I started). The syntax above was causing a problem in the case that there was a single matching row in the second table which matched the criteria in the where clause. In this instance, the entry from the first table would appear once, and then immediately get filtered out by the constraint in the where clause.
What I actually needed to do was filter the second table before the join happens. So here’s the syntax:
SELECT *
FROM table1 t1
LEFT JOIN table2 t2 ON (t1.col_a = t2.col_a AND t2.col_b <> 42)
It turns out that you can use the ON clause when you join to include anything that you would usually put in a where clause to restrict the rows on the table that is being joined. Hope this makes sense and is useful to someone, add your comments if you have any!
