Posts Tagged ‘Website’

lewiz.org post comment count (fixing Wordpress wp_hashcash)

Saturday, June 16th, 2007

I finally got around to upgrading my blog to the latest and greatest version of WordPress… 2.2 right now.

At the same time I switched away from the WordPress HashCash plugin I was using to prevent comment spam.  It’s actually done me pretty well over the last year or so.  I do get the odd spam comment, but nothing is perfect.

Where wp-hashcash has failed me though is in keeping the comment count associated with each blog post up-to-date.  For example, five minutes ago WordPress thought somebody had left a comment on my post about a new keyboard… I believe this to be a side effect of rejected spam comments.

Here’s a quick fix for the problem:

update posts set comment_count=(select count(*) from comments where comment_post_id=id);

Very quick, very simple.  Amazingly the stats on my WordPress database were not all that encouraging:
Query OK, 395 rows affected (0.06 sec)
Rows matched: 926  Changed: 395  Warnings: 0

So 395 of my blog posts had the wrong comment count… ouch!

Google Apps

Friday, May 18th, 2007

Google Apps are clearly amazing.

I think I’ll be getting some Google Mail love soon.

Firefox Web Developer

Friday, May 11th, 2007

After finishing off the basics of my image_location module yesterday, I’ve now decided to turn my attention to properly theming the website.

After spending an hour or two fiddling around with CSS files on the server (edit, reload, observe, wash, rinse, repeat) I decided to install the Firefox DOM Inspector and Web Developer extensions.

A quick Firefox restart later, enable one option and I have a view that CSS hackers would die for:

webdev.png


A big shout out to all of the Firefox developers out there!

Drupal image_location.module

Thursday, May 10th, 2007

After blogging about the need for a module for Drupal that handles Exif GPS data I started hacking.

I’ve whipped up a module that does exactly what I need.  It basically hooks in to the insert and update code for images, injects some data and allows the insert/update procedure to carry on as though the user has manually entered the latitude/longitude.

I’ve submitted a patch to the image.module guys so with any luck this may become a part of the image module.  For those that are interested head over to drupal.org/node/143071 for more details.

To do: Image Exif Location module for Drupal

Wednesday, May 9th, 2007

In the hopes of forcing myself to follow up on this, I’m writing it here.

I plan to write a very simple module for Drupal that extends the current Image module when the Location module is also present.

It will do one simple task: automatically filling the latitude/longitude information for a photo with valid Exif GPSLatitude and GPSLongitude information.

That is all.

CompSoc downtime

Thursday, February 8th, 2007

As a follow-up to the last post about /var filling up, here’s another one that’s equally as crazy.

In an effort to fix /var once and for all I scheduled some emergency downtime last night. The aim was to make the /var partition bigger. This got off to a pretty bad start when, in true Solaris fashion, I attempted to drop noisy down to single user by typing init 0. In Solaris this drops a SPARC system to the OBP (like the BIOS), and just reboots x86 machines. In FreeBSD runlevel 0 is equivalent to Solaris runlevel 5… shut the system down and then power it off.

So, at about 22:15 last night I switched the primary CompSoc server off. Hardly the fix I was looking for.

After a number of calls to Andy and Inti I had somebody switch it back on (bear in mind that the system is in Manchester and I’m near London)... in an attempt to minimise the downtime, I decided to do the fix as soon as it came back up. This time I got the right runlevel… init 1, but (as I realise now) all sorts of crazy stuff happens to FreeBSD’s serial redirection in single user mode. It appears to knock off serial support and output only to the video console. Again, not a lot of good for me.

Later on in the day somebody else rebooted it and after a number of attempts to get things working, I decided that I’d do the fix in full multi-user mode. This involved disabling logins, stopping almost all services, etc. More lsof was used to determine what was using /var; these were stopped and when there were no open filehandles I umount -f‘d /var.

I dumped the contents of /var to a different disk and set about updating the disklabel.

# /dev/ad0s1:
8 partitions:
	
  1. size offset fstype [fsize bsize bps/cpg] a: 1048576 0 4.2BSD 2048 16384 8 b: 8388608 1048576 swap c: 156296322 0 unused 0 0 # "raw" part, don't edit d: 1048576 9437184 4.2BSD 2048 16384 8 e: 52428800 10485760 4.2BSD 2048 16384 28552 f: 93381762 62914560 4.2BSD 2048 16384 28552

Above is the disklabel before the change… a is /, d is /var, e is /usr and f is /backup2. What I needed to do was grow d (currently just 512MB) by using some of the space from f, which was an unused backup directory. The obvious problem here is that /usr was in the way. My solution was to grow swap by 512MB, totally remove the d line, shrink f to around 8GB and rename it to d. This sounds a little complicated… it took me a while to get my head around it.

Prior to the change the on-disk layout was something like:

[ a (/) ] [ b (swap) ] [ d (/var) ] [ e (/usr) ] [ f (/backup2) ]

Now that I’ve made the changes the on-disk layout is more like:

[ a (/) ] [ b (bigger swap) ] [ e (/usr) ] [ d (/var) ]

The bsdlabel currently looks like:

# /dev/ad0s1:
8 partitions:
		
  • size offset fstype [fsize bsize bps/cpg] a: 1048576 0 4.2BSD 2048 16384 8 b: 9437184 1048576 swap c: 156296322 0 unused 0 0 # "raw" part, don't edit d: 16777216 62914560 4.2BSD 2048 16384 28552 e: 52428800 10485760 4.2BSD 2048 16384 28552
  • The beauty of this (as far as I was concerned) was that everything was still contiguous, no holes and no changing of slice letters. Next step was to newfs the new /var, mount it and restore the contents from the file on the other disk I previously mentioned. No major problems here, although I did manage to restore the contents of /var to both / and my personal home directory. Fortunately this mess was easy to clear up.

    So, with all of the files back, I rebooted the box. It didn’t come back up.

    After a lot of time talking Inti through the console (which I couldn’t get, because the machine was having none of single-user mode serial) we discovered that the only reason the system wouldn’t boot was because I hadn’t removed the /backup2 entry from /etc/fstab! D’oh! A rookie mistake (but one that I always make).

    Once we got this removed the system shot up. Allow a few more hours to get both bump and noisy up with LDAP working and we once again have a fully running CompSoc.

    It certainly didn’t go as planned, but I believe the end result is a good one:

    # df -h
    Filesystem     Size    Used   Avail Capacity  Mounted on
    /dev/ad0s1a    496M    383M     73M    84%    /
    devfs          1.0K    1.0K      0B   100%    /dev
    /dev/ad0s1e     24G     20G    2.0G    91%    /usr
    /dev/ad0s1d    7.7G    160M    7.0G     2%    /var
    /dev/da0       541G    190G    308G    38%    /data
    linprocfs      4.0K    4.0K      0B   100%    /usr/compat/linux/proc
    procfs         4.0K    4.0K      0B   100%    /proc
    devfs          1.0K    1.0K      0B   100%    /var/named/dev

    We really need to work on getting serial output from FreeBSD working properly, not to mention installing a new network card so that we can use the internal 10/100 interface for IPMI, which will allow us serial-over-LAN and full remote power capabilities.

    When I got home at 7PM I treated myself with a curry and an episode of Prison Break.

    Apologies to anybody that was affected by the downtime!

    del.icio.us

    Monday, February 5th, 2007

    So, I’m a slow starter with this one.

    I signed up for a del.icio.us account years ago; it didn’t really do what I wanted.

    Over the past week I’ve come to reevaluate this decision, prompted largely by conversations with Chris Gerhard, a big supporter of standard APIs and communication between sites, etc. (note how hard I tried not to say Web 2.0)

    For the past six months I’ve been using FoxMarks to sync my bookmarks between my desktop and laptop.  Admittedly, I don’t use my laptop that much these days, but it is handy to have everything accessible when I need it.

    What does del.icio.us offer over FoxMarks?  To be honest, not a lot… my bookmarks were all fairly well organised, and I could always find what I needed.  But the big drawback to Firefox Bookmarks was the pain of figuring out which category to file it under, not to mention the sheer number of clicks it takes to do this.

    Now that I’m getting started with del.icio.us I’m really hoping that my bookmarking habits will get better, if only because the task is so less painful.

    In the future I’d like to get some proper Wordpress-delicious integration going.  There are a whole raft of plugins available, but it looks as though most of the implementations have fallen a little short of what I had expected.

    It’ll be ready when it’s done.

    On why a personal blog is better than a blogs.sun.com blog…

    Tuesday, January 16th, 2007

    You clearly can’t get away with uploading/blogging about the good stuff.

    New blog coming soon…

    Wednesday, September 27th, 2006

    So… I’ve been working on switching www.lewiz.org away from Drupal to Wordpress. Vlad has already asked why, when I’ve made such a big deal about how great Drupal is. I know it might seem odd, but lately I have a lot less time to spare keeping things up-to-date. In addition I’m also hosting my image galleries on www.fajita.org, using the gallery2 software, so I no longer need a blog that has built in galleries.

    I still stand by Drupal for larger community projects, but for little me, that adds a few random thoughts every once in a while, I think Wordpress is a far more suitable piece of software.

    The big challenge has been to migrate my Drupal blog entries over to the Wordpress database. However, I’ve found some really handy scripts and spent a bit of time working things out on my own, and I’m happy to say that just a few minutes ago I managed to do a more or less full import of my current blog entries… the major change from previous attempts is that I have now imported data using the correct character set: UTF8 (Unicode), which means that the random bits of Japanese, Chinese and other language of the month show up properly.

    The main things I need to sort out now are:

    • categories for the blog entries
    • importing the comments properly (right now they all show up as being by “anonymous”, which is useless)
    • calculating the comment count for each entry (trivial; the entry tuple stores the associated number of comments, instead of doing a SELECT COUNT each time it is displayed)
    • figuring out how to handle the Drupal node attachments (all of the inline blog images are technically node “attachments”, which is something I’m not sure Wordpress supports natively; this will probably be the big problem to work around)

      Once that’s all sorted I should have it switched over and the old site (backed up/archived) and down to make way for the new Wordpress version.

      I might try and get things going tomorrow, if I can find the time :)

    folderblog EXIF info updates

    Wednesday, February 15th, 2006

    Okay, just as I was about to go out and grab myself some dinner I had an idea for a quick fix for the aperture field on my photoblog. I’m using folderblog to do this but I don’t think that the issue really lies there. Instead I think Bibble Pro exports “odd” (although valid) EXIF info.

    My idea was just to round the aperture to one decimal place… this works perfectly. I then decided that I should probably look at why the shutter speed is incorrectly calculated… it turns out that the EXIF stores the shutter speed (and aperture and probably other values) not as a single value, but two. Odd? Seems a little to me.

    Anyway, fb_exif.php was checking if one of these two numbers is not equal to one. But my EXIF info is slightly odd, so I reworked this to check if one number was larger than the other (i.e. less than 1s) and then rounded the resulting shutter speed to 0dp. Perfect!