July, 2004

28
Jul 04

Cotic Soul and Fox Talas thoughts

Now I’ve been out properly, here are some thoughts on my Cotic Soul. I’m not at fully going for it stage, but I’ve ridden enough terrain now to know how the bike is performing. My perfect bike ride would be a day in the hills with plenty of flowing singletrack and some technical bits (I’m not really into fully mental technical stuff or drops and jumps). I’m not particuarly tall and ride a medium (17.5”) frame. I could get away with a small one, but I wanted something that I would be happy to ride a decent distance on and that would mimic my old Orange P7 to a certain extent.

On fast, bumpy fireroads the bike feels great. It’s much more comfortable than my old P7 on this sort of stuff, despite still using well pumped up 2.1 tyres. A large part of this is due to running the fork at 125mm on the rocky fast stuff, but whole ride position just feels right at speed.

Singletrack is where the bike excels. Despite the bike being relatively long for my height, it’s a bit of a charger on tight trails. I find it easy to chuck it around


28
Jul 04

For sale: 7′ 2″ mini-mal

Chances of this working must be pretty slim, but here goes:

I’m selling my current surfboard so that I can fund a smaller one! It’s a mint condition (no dings or scrapes) 7’ 2”/20.75”/2.75” mini-mal that I have used as my first board on everything from sloppy beaches to Scottish reefs. Excellent board to learn on, progress to from a full longboard or just for catching more waves. Handles tiny to head and a half high waves and is a brilliant no wind/offshore/very light wind option for kiters (with or without a kite!). Shaped by Ray Finlay from Legend Point Surfboards in New Zealand. I’m selling it for a paltry £275 including FCS fins, board bag and leash.

Big thanks to the guys at Tunnel Vision, who were easily the most helpful and friendly Cornish place I could find when I was buying my new board – couldn’t see the board I wanted in Scotland!


16
Jul 04

Little bastards and biking escapism

If you are offended by bad words, please stop reading this post now – I implore you.

Bastards. Fucking little, cock-sucking, animal shagging cunts. Last night I was to go biking with Dave in the Pentlands. It had already been a bad day and I felt ill with a cold that everyone seems to have just now, but it was topped off by Dave telling me that the top of the passenger side door had been bent about 3 inches away from the car. Bastards. In fact, the door was actually open, but nothing had been taken. This all but confirms to me that the flat tyre I had a few weeks ago was let down rather than a puncture. Bastards.

We headed up to the Pentlands anyway, with me a figure of calmness. Surprisingly, I was charging – I’ve not ridden that fast for a long time. Climbing hills hard was an awesome way to vent anger, I was charging and we had a great wee ride. When we got back to the car it was time to deal with the door and start thinking about new places to park my car (my flat is pretty cheap, but it’s right next to a really shitty part of Edinburgh), but mountain biking, as sport so often does, provided the perfect escape from yet another little annoyance.


5
Jul 04

Beinn A’Ghlo mountain biking, Blair Athol

Dave and I headed up to Blair Athol on Saturday to do this classic mountain bike loop (here’s another account). Desipte getting up early we somehow didn’t start out until 10.45 – spending £20 in Sainsbury’s probably didn’t help. We should’ve had some awesome photos, but Dave’s camera batteries ran out about one photo into the ride – bugger.

It’s a reasonably committing route – 35ish miles offroad in relatively remote terrain – so you need to take plenty of food and clothes. The scenery in the Grampians is great (a bit like the Lammermuirs on acid) and the route is very worthwhile. Plenty of bumpy fireroad with some fast descents broken up with a couple of sections of excellent highland singletrack. No great navigational challenges, but make sure you stay next to the stream/gorge as you leave Fealar Lodge. We got teased up the hill and ended up in a bog for a couple of kms. In the middle of this Dave got his gloves soaked filling up his water bottle and then grabbed an electric fence “to see if it was on”. It was. :)

We rode the route anti-clockwise – riding it that way meant we got the superb steep singletrack down to the Allt Garbh Buidhe, although I guess the other way would mean the other section of singletrack would be wicked too. Time to start looking for some routes with more of that sort of singletrack. 25 miles of that stuff would be amazing. It had rained a fair bit before we did the route, and there were some heavy showers during the day so there was some lying water around, but neither that nor crossing the Allt Garbh Buidhe was a problem.

Fitness-wise this was a real milestone for me. I’ve been out a couple of times mid-week with Andy and Stuart, but this is the first decent distance proper bike ride I’ve done since I broke my back. Although I’m still far from peak fitness, it’s approaching a much more reasonable level now. It felt great to be back out in the hills getting some miles in, I’ll have some more of that please. I just need to try to stay calm and not go too mad too soon – overtraining is a bitch, I know that from experience.


2
Jul 04

Running PHP in WordPress posts

To display photos from the gallery section of this site in posts, I use PHP to call a function that grabs the details from a database. WordPress doesn’t natively allow you to do this due to the obvious potential security issues so I searched for a plugin to allow me to do it. I found Stevarino and also Pascal’s Hack, but I couldn’t get them to work (despite some help – big thanks Pascal!) so I just started from scratch with my own. Thanks to Stephen and Pascal for demonstrating how to apply filters to stuff in WordPress – I still have much to learn about the workings of WordPress. Spookily we came up with pretty damn similar code.

This is version 0.1, I can’t stress this enough 0.2 0.2.2, an early version – I developed it enough to get it working for my needs and then stopped. It hasn’t had any testing beyond that. In the winter, when I fancy using my computer more, I’ll try to improve it all. Not promising awesome support or anything, but feel free to leave comments and stuff as I do intend to maintain the code at some point. Obviously you should think about who has access to your blog and the code you’re going to be running when using this plugin.

Using WordPress 1.2, copy this code to a file named “runphp.php” and upload it to your “wp-content/plugins/” directory, then enable it in the admin panel. Use <phpcode>echo "hello mum!";</phpcode> to run some php.


<?php
/*
Plugin Name: Run PHP
Version: 0.2.2
Plugin URI: http://mark.scottishclimbs.com/archives/2004/07/02/running-php-in-wordpress-posts/
Description: Allows PHP to run in posts by using custom HTML style tags
Author: Mark Somerville
Author URI: http://mark.scottishclimbs.com/
*/

/*
run_php
This function runs and outputs PHP code that exists within <phpcode></phpcode> tags.
*/

function run_php($data) {
$tag = "phpcode";
$taglength = strlen($tag);

//html_entity_decode doesn't work! These lines change ' and " instead. Maybe other entities needed?
$data = str_replace(array("&#8216;", "&#8217;"), "'",$data);
$data = str_replace(array("&#8221;", "&#8220;"), '"', $data);
$data = str_replace("&Prime;", '"', $data);
$data = str_replace("&prime;", "'", $data);

while($phpstart = strpos($data, "<".$tag.">")) {
$phpend = strpos($data, "</".$tag.">");
$phptrueend = $phpend + $taglenth + 3 + $taglength;
$before = substr($data, 0, $phpstart);
$after = substr($data, $phptrueend);
$phpcodelength = $phpend - ($phpstart+2+$taglength);
$phpcode = substr($data, $phpstart+2+$taglength, $phpcodelength);

//remove the <br /> and <p></p> tags that WP adds to the code
$phpcode = str_replace('<br />', ' ', $phpcode);
$phpcode = str_replace('<p>', '', $phpcode);
$phpcode = str_replace('</p>', '', $phpcode);

ob_start();
eval($phpcode);
$data = $before.ob_get_clean().$after;
}
return $data;
}

add_filter('the_content', 'run_php');
?&gt;

Changelog

0.1
Initial release, scrappy.
0.2
Fixed problem that meant PHP could only be on one line.
0.2.1
Fixed an HTML entity problem with &Prime; (really need to get html_entity_decode working!)
0.2.2
Fixed another HTML entity problem with &prime; (still really need to get html_entity_decode working!)

Problems with Textile or Markdown?

Jeff suggests that you try changing the last line to:
add_filter('the_content', 'run_php', 5);

Dev note – I couldn’t get html_entity_decode to work at all and ended up just searching for single and double quotes. There are almost certainly some HTML entities that will screw things up. Has anyone had any luck with html_entity_decode?

Regarding html_entity_decode – a recent user contributed note (14/11/04) for html_entity_decode on the PHP documentation sheds a little light on the subject. The function doesn’t work with numeric encodings (which is the first type of error I encountered) and also doesn’t work with UTF-8 encoded text (which I use). I’m going to have a think about character sets and PHP versions to see what the best overall solution is.


1
Jul 04

The trick is to keep riding

As you might know, I get a real buzz out of improving at sports. I love it.

Staying injury free is the best way to improve.