Offline WordPress released

I finally got around to releasing my script I use for toting my private WordPress notebook around on my iPod. It’s essentially a PHP page that creates a static HTML page with a load of JavaScript to selectively hide and show posts as they’re searched for.

This is my method for getting the resulting file onto my iPod. I’ve included it here in case it’s useful to someone.

Things you will need

  • A jailbroken iPod/iPhone
  • MobileTerminal (from Cydia)
  • wget (from Cydia)
  • file:// Schema in Safari (from Cydia)

Setting up the alias

Open MobileTerminal and type the following:

iPod:~ mobile$ nano .bashrc

This will either open your existing .bashrc file or create one for you in Nano.

The following command will create an alias that makes a backup of your previously downloaded export page and then downloads the latest version.

alias wp='cd; mv export.html export~.html; wget http://www.domain.com/pathtopage --output-document=export.html'

Note that if your blog is behind a password you will need to add --http-user=name and --http-password=pass to the wget part of the alias.

Now close the file by typing CTRL-O.

To make sure your .bashrc file loads when you start up your iPod you now need to create a .profile. Type the following:

iPod:~ mobile$ nano .profile

Then add the following to that file:

source $HOME/.bashrc

Close the file by typing CTRL-O.

Now any time you want to download your WP data just load up MobileTerminal and type wp. To load your offline page in Safari you need go to the URL file:///var/mobile/export.html.

The best todo app on the iPhone/iPod

RTM on iPhoneI love Remember the Milk. I’ve been using it for about two months now, both for work and personal lists. RTM have recently released an iPhone/iPod app to integrate with their web app. It syncs your data for use offline and unlike Appigo’s Todo (which also syncs with RTM) it supports tags. True you do need to have a pro RTM account but at $25 per year it won’t break the bank. It’s certainly less than buying the awful, slow and crash-prone OmniFocus for iPhone along with either the desktop version of OmniFocus or MobileMe account you’ll need to sync it to. Oh and did I mention that it will eat your data?

Removing the 3 pixel gap in Hotmail email for Firefox

A while back I wrote a post about removing the 3 pixel gap in Hotmail. While that provided a solution for IE I've since discovered another fix that works in Firefox. It's the same problem as before; a 3 pixel gap is added beneath images, particular to images inside table cells. The problem seems to stem from the font size settings, obviously this shouldn't affect a table cell that does not contain text. Chalk it up to yet another That Shouldn't Make Any Difference But It Does™ This time the fix is to add style="line-height: 50%" to the TD tag. You should then end up with the following:

HTML:
<td style="line-height: 50%">
    <img src="image.gif" width="300" height="50" alt="" />
</td>

Apple ‘upgrades’

Hmm, reading up on the big Apple hardware announcement on Tuesday I have to say I'm disappointed. I was really hoping for an OS X powered netbook. Instead what we have now is a so-called pro laptop with a shiny screen. Oh and if you want a small form factor laptop with firewire then you're SOL because the MacBook only has USB2 in the new models.

Reading the various comments on TUAW the fanboy response of "if you want firewire buy a pro" is quite spectacularly idiotic. If your laptop is your only computer then fine, go pro. I however, already have a desktop, I don't need another all singing all dancing workhorse, and 15 inch laptops are not very mobile. The MacBook is too expensive to be missing such a key port. I don't mind that my Eee PC only does USB, it cost less than £300, it's not designed to be used solo. A MacBook is, or was.

I'm seriously questioning my commitment to using Apple computers. I've already given up waiting for a netbook for this round of my laptop upgrade cycle with the purchase of the Eee. Currently I work on a white 20 inch iMac, what do I do if that breaks? Suck it up and buy a shiny screened iMac? Nope, I remember the nightmare of shiny CRTs too clearly. What about a Mac Pro? I design websites, I don't operate mission control, 8 cores is overkill for my needs. And an £1800 starting price? Forget it. So it looks like either I join the dark side and get used to Windows or I switch to Linux. I've been using Ubuntu on my Eee and I'm impressed with it. It even runs Photoshop. Then there's always VirtualBox to run anything that isn't covered on linux.

How to setup SEO friendly URLs for WordPress on Zeus

Up until a year ago I'd only ever used Apache to host websites. At Oxeye Daisy we host on Zeus webservers. After a lot of fruitless searching on the internet for guides on how to setup SEO friendly permalinks for WordPress hosted on Zeus I stumbled upon the relevant code. I've finally got around to tweaking and commenting it. I thought I'd post it here in case anyone else is having the same trouble.

First you need to go to your WordPress admin page and set up the permalink structure in Options > Permalinks. I've set mine to /%year%/%monthnum%/%day%/%postname%/ but you may want something different.

The notes in the script assume the requested URL to be http://www.domain.co.uk/blog/2007/10/31/an-example-post/?color=red I've added the GET queries so you can see how they are handled, they're not used in WordPress. This URL is then translated into http://www.domain.co.uk/blog/index.php/2007/10/31/an-example-post/?color=red. Notice the index.php in the middle? That's the key bit to making all this work.

Save the following code in a file called rewrite.script and upload it to your web space. Note that you will need to uncomment some parts of the script depending on whether your blog is in a sub directory or the top level of your site.

The code is currently set to work with a sub directory of blog. It has only been tested on Namesco servers and it's set to ignore their specific hosting folders like webmail, controlpanel and tech_support.

CODE:
RULE_0_START:
# Get the document root path and put value into the SCRATCH array.
# This is the server path not the web URL.
# e.g. /content/DesignerPlus/i/n/domain.co.uk/web/
map path into SCRATCH:DOCROOT from /

# Get the URL without the domain.
# e.g. /test&colour=red
# e.g. /blog/2007/10/31/an-example-post/?color=red
set SCRATCH:ORIG_URL = %{URL}
set SCRATCH:REQUEST_URI = %{URL}

# See if there are any queries in our URL.
match URL into $ with ^(.*)\?(.*)$
# If there are...
if matched then
    # Set a var to path without the domain part.
    # e.g. /blog/2007/10/31/an-example-post
    set SCRATCH:REQUEST_URI = $1
    # Set a var to the passed queries.
    # e.g. colour=red
    set SCRATCH:QUERY_STRING = $2
endif
RULE_0_END:

RULE_1_START:
# This is setting a var to the server path and sub folders.
# e.g. /content/DesignerPlus/i/n/domain.co.uk/web//blog/2007/10/31/an-example-post
set SCRATCH:REQUEST_FILENAME = %{SCRATCH:DOCROOT}
set SCRATCH:REQUEST_FILENAME . %{SCRATCH:REQUEST_URI}

# Check to see if the file exists.
look for file at %{SCRATCH:REQUEST_FILENAME}
if not exists then
    # The file wasn't found so is it a folder?
    look for dir at %{SCRATCH:REQUEST_FILENAME}
    if not exists then
        # No folder either. So now check the URL for special hosting folders.
        match SCRATCH:ORIG_URL into % with ^/webmail|^/tech_support|^/controlpanel
        if matched then
            # If a special folder was requested end the script.
            goto END
        else
            # There were no files, folders or special folders so set the new URL.

# -- Sub directory -------------------------------------------------------------
            # If the blog is in a sub directory...
            # e.g. /blog/index.php/2007/10/31/an-example-post
            match SCRATCH:REQUEST_URI into $ with ^/blog(.*)
            if matched then
                set URL = /blog/index.php$1
            endif
# -- Sub directory ends --------------------------------------------------------

# or...

# -- Top level -----------------------------------------------------------------
            # If the blog is in the top level of the site...
            # e.g. /index.php/2007/10/31/an-example-post
#            set URL = /index.php%{SCRATCH:REQUEST_URI}
# -- Top level ends ------------------------------------------------------------
           
            # Go to the next rule.
            goto RULE_2_START
        endif
    endif
endif
# If files or folders were found end the rewrite script.
goto END
RULE_1_END:

RULE_2_START:
# Check for queries in the requested URL.
match SCRATCH:ORIG_URL into % with \?(.*)$
if matched then
    # If queries were found add them to the new URL.
    # e.g. /index.php/2007/10/31/an-example-post/&colour=red
    set URL = %{URL}&%{SCRATCH:QUERY_STRING}
endif

# -- Sub directory -------------------------------------------------------------
# If you only want to rewrite the sub directory uncomment this bit.
match SCRATCH:ORIG_URL into % with ^/blog
if matched then
# -- Sub directory ends --------------------------------------------------------
   
    # End the script.
    goto END
   
# -- Sub directory -------------------------------------------------------------
endif
# -- Sub directory ends --------------------------------------------------------
RULE_2_END:

Linux versions of mac applications

A couple of months ago I gave up waiting for Apple to release a slight, small notebook. The Macbook Air is too big. I didn't need a paper-thin laptop that still required a large bag to put it in. I needed a small thing I could throw in my backpack and not have to make the daily decision as to whether I really needed to take it with me. Cue the Eee PC 901. I bought the XP version as I wasn't sure how I'd find working with linux. After about a week of using XP I wiped it and installed Xubuntu. It's lighter than Ubuntu as it uses XFCE rather than Gnome as its desktop. As a total mac-head I needed to find some equivalent apps to put on my new toy.

The Easy Stuff

Some apps didn't need replacing, Firefox is available for linux and Photoshop runs brilliantly under Wine. And of course linux has a Terminal.

Text Editor

Mac: TextMate
Linux: jEdit

I've been using TextMate for a while now, it's probably my most used app, it's the only one I actually miss when using my laptop. jEdit is a reasonable substitute, it allows you to configure your own syntax colouring, so I copied my favourite TextMate colour scheme.

FTP

Mac: Transmit
Linux: gFTP

Initially I tried FileZilla but I had problems with it disconnecting from servers, it got painful having to navigate to the same folder over and over again each time I wanted to update a file. gFTP fixes this, plus it is quick to load and run.

Chat

Mac: Adium
Linux: Pidgin

Pidgin is available for both windows and linux. It supports MSN, AIM, Google Talk, ICQ and Bonjour among others.

Music Player

Mac: iTunes
Linux: Exaile

Exaile doesn't do everything, it won't sync my iPod for instance. It does play MP3s however and that's all I needed.

PDF Reader With Annotation

Mac: Adobe Acrobat
Linux: PDF Xchange Portable

This one's a bit of a cheat, being a Windows app it needs to be run under Wine. I searched in vain for a native linux app that handled annotation in a standard way; I need to be able to read my annotations on my mac as well as my Eee. PDF Xchange Portable runs very well under Wine.

Phorm: round three

Round three of the Phorm trials start tomorrow. If I were with BT / Talk Talk / Virgin Media I'd be seriously thinking of changing my ISP about now. Just the thought of all my HTTP traffic being monitored makes me twitch. After all, I am already paying for my ISP service, that surely should be enough. Greedy ISPs deserve to lose customers.

You can read all about Phorm here and find some useful detection scripts here.

Download and view local HTML files on an iPod Touch

I keep a personal WordPress as a notebook online along with a page that allows me to save the entire contents for offline viewing. I thought it would be useful to have this file on my iPod. I've written up my method here in case someone else might find it useful. This guide makes the following assumptions:

  • You have 2.* software jailbroken iPod
  • Using Cydia you have installed the following:

    • Mobile Terminal
    • sudo
    • wget
    • file:// Schema in Safari

Overview

The aim is to have a simple command that can be run from the terminal on the iPod to download the HTML file. Safari is then used to view the file offline.

Setting up the aliases

Create a .bashrc file in your home directory, this is where we will store the alias settings. We will use Nano for this:

iPod:~ mobile$ nano .bashrc

Hopefully your screen now looks something like the image below.

Nano

I'm making an assumption about the filename you wish to give your downloaded HTML file, change it if you wish. In Nano you need to type the following:

alias notes='cd; mv notes.html notes~.html; wget http://www.domain.com/page.html --output-document=notes.html'

If, like me, the page you wish to download is behind a password change the dlnotes alias to the following, supplying your own username and password:

alias notes='cd; mv notes.html notes~.html; wget http://www.domain.com/page.html --http-user=username --http-password=password --output-document=notes.html'

That's it. You can now save your .bashrc file by typing CTRL-o and answering yes to the prompt. Quit Nano by typing CTRL-x.

The iPod doesn't always load the .bashrc file so we need to create a .profile page again using Nano and add the following code:

source $HOME/.bashrc

Finally you need to reload your .bashrc file:

iPod:~ mobile$ source .bashrc

Whenever you want to grab your HTML page for offline viewing just open the terminal and type notes. Then view the file in Safari by typing in the URL file://var/mobile/notes.html, a copy of the old HTML file will have been saved too just in case. You can setup another alias to delete the backup in the same way above, the command would be:

alias delnotes='cd; rm notes~.html'

Air Sharing

If you use Air Sharing you may want your file to be saved in its directory and be available over a network. Below is a quick guide to finding where Air Sharing stores files.

Use Air Sharing to copy a file from your computer to your iPod, make its filename unique as you will need to search for it later on. e.g. moocow.html

The rest of the work is done in the iPod Terminal. So grab your iPod and open the Terminal application. Note that I've highlighted the commands you type as bold.

We can use the locate command to find the file. First you will need to update the locate database. This needs to be done as root. To change to the root user type the commands below. The password will be alpine unless you've changed it:

iPod:~ mobile$ su
Password:<password>
iPod:/var/mobile root# updatedb
iPod:/var/mobile root# exit

Next we search for the file you copied over with Air Sharing:

iPod:~ mobile$ locate moocow.html

Note that it may take a few seconds to search, there are a lot of files on your iPod. You should get something back that looks like this:

/private/var/mobile/Applications/94724F2A-847G-371D-8H36-3DF5E659C9D2/Documents/Air\ Sharing/moocow.html

So now we know that Air Sharing stores its files here:

/private/var/mobile/Applications/94724F2A-847G-371D-8H36-3DF5E659C9D2/Documents/Air\ Sharing/

Using this information you can adjust the alias above to download your files directly to the Air Sharing directory.

More B-52s…

Found these videos on YouTube, Planet Claire was their third encore. Whoever filmed that one must have been stood just in front of us.

The B-52s at the Birmingham Academy

The B-52s

Went to see the B-52s last night at Birmingham Academy. We learned several things; GPS hardware doesn't like those underpass road bits they like in Brum and that maybe it would make more sense to go on the train - if they weren't so shite that is.

We got to the place at 7pm and joined the line outside. As there was no supporting act there was a bit of a wait till the B's hit the stage at 9.15ish. They played a good mix of old and new songs, plus Love Shack and an encore of Rock Lobster. It was awesome :) Well worth enduring the headache inducing lights, particularly during Strobe Light, a good test of my migraine reflecting green glasses of power.