About Steve

By day Steve is a professional software test consultant and owner of iTest Solutions Ltd through which he provides professional services. Outside the world of work he enjoys: Physics, Astrophysics, Astronomy, learning how to build standards compliant websites and playing with mathematical ideas on the PC using tools like Mathematica . Away from the computer Steve enjoys discovering new musical artists of all levels and working with dedicated and passionate unsigned artists who are keen to retain some control of their future, their music and their talent.

Modelling Seashells

Introduction

I thought it would be fun to investigate the shapes of seashells and try to understand the factors that shape them.

In this post I’ve recorded what I’ve learned with examples for future reference. I’ve tried to make this post sufficiently complete that it could be used in the future as a reasonably comprehensive refresher in case I decide to come back to the subject and try playing with it further. In the course of thinking about this topic other ideas become important and the first part of this post summarises them (e.g. parametric surfaces, polar co-ordinates, ideas from Euclidean geometry). Where a particular subject requires it I’ve added a separate post to go into more detail and included a link to it in this post. Continue reading

404 Errors

Aside

I’ve been getting a lot of HTTP 404 errors recently – mainly from what apear to be search engine bots (they appear to be confirmed as bots via a reverse DNS lookup). these 404s seem to be coming from a series of attempts to crawl old pages that don’t exist on the site any longer. I’ve set up 301 redirects to address the specific instances that have cropped up so far – appraently this could have negative consequences from a SEO point of view though I don’t understand the details of the argument (the whole SEO malarky seems a bit like black magic and some smoke and mirrors thrown in). I’ll keep monitoring.

Another class of HTTP 404 errors seems fundamentally different in nature – they look like attempts to connect directly to plugins that have known vulnerabilities or attempts to connect direct to some of the important files on the site. I’ve taken different action on those and will continue to monitor carefully. An interesting learning opportunity those!

ERROR: PHP Not Running

Aside

I decided to tidy things up a little bit and update my local dev environment by upgrading my WAMP installation to the current version (upgrading MySQL,Apache and PHP along the way).

Ever wish you didn’t bother ?

What a performance. The WAMP stuff looked OK until I actually tried using it! Initially I ended up with a #1045 error on the root user when trying to use phpMyAdmin. Trying to sort that was a joke and a compelte waste of time. Thankfully it was my dev environment so I could easily trash the database and completely uninstal WAMP from the PC (registry, files, database the lot) followed by a quick re-instal of everything including creating a new dev database.

phpMyAdmin worked fine after that carry on – i.e. back to where I was an hour earlier!!

Now I had to re-install WordPress for my local development purposes and immediately encountered the “ERROR: PHP IS NOT RUNNING”. What!!!???? Yes it is! No matter what path direction I have I just couldn’t get WP to instal. I then had the idea of creating a virtual host for the site in the Apache httpd.conf file. This worked a treat and I installed and configured WordPress locally with a nice new version, copied allmy plugins, configured things the way I’ve got them on live and it’s looking good.

Only remaining problem I have is none of the pages in the menu or imported posts work on the local instal – I probably didn’t do something correctly related to “moving wordpress”. Permalinks are the same structure in my local dev environment as on the live box. I’ll worry about that later.

All in all this has been a major PITA and a lot of wasted time and effort.

Add Author Biog After Your Post

To add an author biog box after your post you will need to add some new structure into the single.php file and some CSS into your style.css file. Throughout what’s written here I’ll assume you’re using a child theme and using the Twenty Eleven theme for your WordPress site. If you’re using a different WordPress theme the main things will be the same but you will probably have to tweak the CSS a little – particularly around any element that has “float” or “clear” applied and you might also have to use or exclude “!important” declarations on elements. The best approach is just use this as is, see how it fits with your theme then start making changes 1 at a time until you get what you’re after.

Here goes:

Adjust your “single.php” file

1. Download your single.php file from the default twentyeleven theme folder on your server to make edits locally

2. If you’re running a web server on your local PC with a WordPress instal you will be able to test your changes locally and just upload to your live server at the end when you’re finished (e.g. WAMP)

3. Open your downloaded single.php file and add the following code snippet:

<?php get_template_part( 'content', 'single' ); ?> // *** Original code in the template as a position marker ***

<!-- ****************************** -->
     <div id="authorbox"> <!--author box added by me-->
          <div class="authortext">
               <?php if (function_exists('get_avatar')) { echo get_avatar( get_the_author_email(), '80' ); }?>
               <h4>About <?php the_author_posts_link(); ?></h4>
               <p><?php the_author_description(); ?></p>
          </div>
      </div>
<!-- ****************************** -->	                    

<?php comments_template( '', true ); ?>           // *** Original code in the template as a position marker ***



4. Test this code insertion to make sure it’s appearing in a location on your page that you’re happy with. don’t worry about how it looks, you’ll be styling the content next. the mission for now is to make sure it appears in a place you’re happy with. When I did this I was using the default Twenty Eleven theme so the location above is relevant for that template. I placed my code after the “get_template_part” and before the “comments_template” tag. You can change the location to suit your own needs but most templates are similar at this level.

Style your new author biog box

5. Now that you have the author biog box where you want it it’s time to add some style to it. You can make this as simple or elaborate as you want to.

6. Add the following CSS rules to your theme stylesheet (if you’re using a child theme this will be the stylesheet in your child theme folder):

/*Style author box*/
#authorbox {background:#fcf8d7; border:1px solid #e2dede; max-width:620px; margin:0 auto; margin-bottom:20px; overflow:hidden; padding:10px;}
#authorbox h4 {font-size:16px; color:#FFF; margin:0; padding:0; clear:inherit !important;}
.authortext {padding-left:10px;}
#authorbox img {margin-right:10px; padding:0; float:left; border:5px solid #e2dede;}
#authorbox p {color: #FFF; margin:0; padding:0px; font-size:12px;}
#authorbox h4 > a {text-decoration:none; color: #FFF;}
#authorbox a {font-weight:bold;}
#authorbox {-moz-border-radius: 9px; border-radius: 9px;}
#authorbox {background: #03f;	background: -moz-linear-gradient( #03F, #036);	background: -o-linear-gradient(#0f0f0f, #2B2B2B); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#0f0f0f), to(#2B2B2B)); /* Older webkit syntax */ background: -webkit-linear-gradient(#0f0f0f, #2B2B2B);}
div.authortext p a {color: #FF3;}



7. I mentioned in the intro that some of the CSS styling might have to change depending on the theme you’re using. On line 3 of the CSS snippet you will see a “clear” instruction. that’s one that is likely to need modification in your theme. I had to use it because of previous styling rules applied to the h4 tag in the Twenty Eleven theme (so I had to adjust those rules for this specific addition while leaving them in tact for the rest of the site). There might be similar little quirks in the theme you’re using. Just play around with the CSS to get what you want. I’ve used “max-width” to get a nice width on the biog box when the browser window is full size, when the browser window is reduced the biog box shrinks dynamically. This setting looks OK on iphones, ipads, tablets etc.

8. Change the colours, border radius, link colours etc to suite your needs. Strip the CSS right back to have a basic minimalist author box or make it quite elaborate with background images etc.

9. That’s it. You should now have an author biog box appearing after each post on your site in a location of your choice looking the way you want it to look.

Notes:

  • The code used here assumes the post author has a gravitar set up and that they have completed the user biog section in their user setup with something sensible. If they haven’t this will be a bit of a waste of time
  • You could replace the php “get_avatar” call with a simple image insert if you only have 1 author for your site and you don’t want to set up a gravatar
  • The biog box will only appear at the end of the full post – not in excerpts or in the post preview (on the front page if you’re using the Twenty eleven theme). that’s because you added the code to the single.php template file. You could experiment with other files/locations if you wanted the information to display on other pages etc
  • You can see the results of this in action if you open any of the posts on this site.
  • You might find this a bit of overkill and repetition if you are the only poster on your site. I’d probably agree with that. I use this site to experiment with WordPress and learn how it works so I’m less concerned with that sort of consideration and more interested in how to achieve a particular result. If you’re running some sort of commercial site or more professional blog then you might be right in thinking twice about implementing this sort of thing.



NOTE: In the Twenty eleven theme there’s already an author block included when a post is made in a multi-user site and the author has entered their biog data. You will find the code for this in the Twenty eleven theme file “content.single.php”. the div involved is “author-info” and there are vaious classesand default styling rules in the default style.css file. Instead of adding new HTML etc to your single.php file as I’ve done in this post you could just re-style the default div. (I found this out after having done the work because this feature didn’t appear correctly – mainly I suspect because only a single publishing author had been sued in my blog until I made a mistake and published using a different user).

Change Default Header Images in Twenty Eleven Theme

This post describes how to change the default headers in the Twenty Eleven theme and replace them with images of your choice. Throughout this post it is assumed that you’re working with a child theme – if not you may have to adjust some paths but the general procedure is the same. I have retained the original sizing of the Twenty Eleven images, namely: 1000 x 288px for the header images and 230 x 66px for the thumbnails. There are essentially 3 steps to switching out the default headers and replacing them with your own:

1. Create your own header images and thumbnails
2. Remove the default header images
3. Add your own header images

Step 1 – Create Your Own Images

1. All the usual caveats apply here regarding copyright on images you plan to use – make sure you either have it or have permission to use the images

2. Create a new image or resize an existing image to dimensions 1000 x 288px for the main header image

3. Using the image in step 2 above resize it to 230 x 66px for use as the thumbnail

4. Repeate steps 2 and 3 for the images you want to use as header images in your theme

This might take you a while depending on how many images you want to use, how complex you want to make them and how accomplished you are with your graphics program of choice (Photoshop etc). Once you’ve finished that side of it the rest is pretty quick as follows

Step 2 – Remove the Default Header Images

5. Out of the box the Twenty Eleven theme comes configured with 8 images named:

‘wheel’,'shore’,'trolley’,'pine-cone’,'chessboard’,'lanterns’,'willow’and ‘hanoi’.

You need to remove any of these that you don’t want. You can remove all of them or a subset. To do this add the following code snippet to your functions.php file in your child theme:

<?php
// REMOVE TWENTY ELEVEN DEFAULT HEADER IMAGES
function remove_header_images() {
    unregister_default_headers( array('wheel','shore','trolley','pine-cone','chessboard','lanterns','willow','hanoi')
    );
}
add_action( 'after_setup_theme', 'remove_header_images', 11 );
?>



In this code I’ve chosen to remove all of the default headers for completeness. If you wanted to retain some of them you you would just omit the file names of those you wanted to keep from the “unregister_default_headers” line.

I’ve called the function that does this work “remove_header_images” because that’s a reasonable description of what it does but you can call it anything you want. Just make sure that the name you give the function also appears in the “add_action” instruction at the end.

The parameter “11″ is worth noting. That sets the runtime priority of the action we’ve set up to remove the headers. The default priority is 10 so having a priority of 11 means runs after the default activities, ensuring that we allow the default header images to register and load before we try and remove them.

Step 3 – Add Your Own Header Images

6. Now that you’ve removed the default header images you can add your own. In your child theme folder create a folder to hold your images. I created a folder called “images” and use it to hold all the images for my child theme. You don’t have to do that, you can create as many folders in your child theme as you want and you can call them what you want it doesn’t matter, just make sure that in what follows the image paths point to the folder you choose to hold your header images.

7.Drop the header and thumbnail images you created way back in step 1 into the folder you created in step 7 above.

You should have a pair of images for every header image: 1 header + 1 thumbnail.

A quick note on image file naming conventions. I chose to adopt the following naming convention for my images:

headerimage_filename for the main header image and

headerimage_filename-thumbnail for the thumbnail image that appears in the setup panel

e.g. “aceofspades.jpg” for the main header image and “aceofspades-thumbnail.jpg” for the thumbnail.

That just made it easy for me to remember what was what. You of course, can choose your own approach or just follow mine.

8. With your images all in place add the following code snippet into your functions.php file:

<?php
//ADD NEW DEFAULT HEADER IMAGES
function new_header_images() {
    $child2011 = get_bloginfo('stylesheet_directory');
	define( 'HEADER_IMAGE', '/wp-content/themes/child2011/images/aceofspades.jpg' );
    register_default_headers( array (
        'image1' => array (
            'url' => "$child2011/images/aceofspades.jpg", // 1000 x 288px
            'thumbnail_url' => "$child2011/images/aceofspades-thumbnail.jpg", // 230 x 66px
            'description' => __( 'Ace of Spades', 'child2011' )
        ), // note the comma when using multiple images, you don't need this for the last image
        'image2' => array (
            'url' => "$child2011/images/band.jpg",
            'thumbnail_url' => "$child2011/images/band-thumbnail.jpg",
            'description' => __( 'Rock Band', 'child2011' )
        ),
        'image3' => array (
            'url' => "$child2011/images/batman.jpg",
            'thumbnail_url' => "$child2011/images/batman-thumbnail.jpg",
            'description' => __( 'Batman', 'child2011' )
        ),
        'image4' => array (
            'url' => "$child2011/images/beetleonflower.jpg",
            'thumbnail_url' => "$child2011/images/beetleonflower-thumbnail.jpg",
            'description' => __( 'Ladybird on Flower', 'child2011' )
        ),
        'image5' => array (
            'url' => "$child2011/images/darkangel.jpg",
            'thumbnail_url' => "$child2011/images/darkangel-thumbnail.jpg",
            'description' => __( 'Dark Angel', 'child2011' )
        ),
        'image6' => array (
            'url' => "$child2011/images/earth.jpg",
            'thumbnail_url' => "$child2011/images/earth-thumbnail.jpg",
            'description' => __( 'Home Sweet Home', 'child2011' )
        ),
        'image7' => array (
            'url' => "$child2011/images/eilidh.jpg",
            'thumbnail_url' => "$child2011/images/eilidh-thumbnail.jpg",
            'description' => __( 'Eilidh', 'child2011' )
        ),
        'image8' => array (
            'url' => "$child2011/images/einstein.jpg",
            'thumbnail_url' => "$child2011/images/einstein-thumbnail.jpg",
            'description' => __( 'Albert Einstein', 'child2011' )
        ),
        'image9' => array (
            'url' => "$child2011/images/figureonglass.jpg",
            'thumbnail_url' => "$child2011/images/figureonglass-thumbnail.jpg",
            'description' => __( 'Figure', 'child2011' )
        ),
        'image10' => array (
            'url' => "$child2011/images/flowers.jpg",
            'thumbnail_url' => "$child2011/images/flowers-thumbnail.jpg",
            'description' => __( 'Yellow Flowers', 'child2011' )
        ),
        'image11' => array (
            'url' => "$child2011/images/kites.jpg",
            'thumbnail_url' => "$child2011/images/kites-thumbnail.jpg",
            'description' => __( 'Passing Years', 'child2011' )
        ),
        'image12' => array (
            'url' => "$child2011/images/musicfreak.jpg",
            'thumbnail_url' => "$child2011/images/musicfreak-thumbnail.jpg",
            'description' => __( 'Music', 'child2011' )
        ),
        'image13' => array (
            'url' => "$child2011/images/redrain.jpg",
            'thumbnail_url' => "$child2011/images/redrain-thumbnail.jpg",
            'description' => __( 'Red Raindrops', 'child2011' )
        ),
        'image14' => array (
            'url' => "$child2011/images/unionflag.jpg",
            'thumbnail_url' => "$child2011/images/unionflag-thumbnail.jpg",
            'description' => __( 'Union Flag', 'child2011' )
        ) // the last image does not get a comma
    ));
}
add_action( 'after_setup_theme', 'new_header_images' );
?>

Notes:
(a) The function to add the new header images is called “new_header_images”. You can change this if you want though it’s a reasonable description of what it does. If you do change it, make sure you change the name in line 79 too.

(b) The variable $child2011 in line 4 is just a holder for the path information of your child theme. You can call it anything you want but if you change it make sure you also change it in the image paths from line 8 onwards. If you miss 1 of these you will spot it quickly enough because the relevant image/thumbnail wont appear.

(c) All image/thumbnail code blocks are separated by a comma except the last code block where there is no comma (see comments in the code snippet). This is important.

(d) The code in line 5 defines the default header image to be used if no other header image is set – courtesy of http://www.voodoopress.com

9. That’s it, you have now replaced the default Twenty Eleven theme header images with your own handmade images (including thumbnails). Here’s a snapshot of what my configuration panel looked like when I had finished:

Custom header images and thumbnails added to Twenty eleven WordPress theme



If you’re interested in changing the sizes of the header images there’s a great tutorial over on http://www.voodoopress.com


Check out this post: http://voodoopress.com/customizing-twentyeleven-lets-start-with-width-and-smaller-header/

Add Custom Content to Your RSS Feed

You can add custom content to your RSS feed. The custom content can be anything – text, markup, or even scripts. You can display the content before or after your post content, or in both places if required. A typical example of how this capability could be used is to include the addition of a copyright notice in the feed footer and advertisements before and/or after each feed item. There are lots of possibilities.

1. Add Content After The Feed Entry

To add some custom content to the end of your own feed, add the following code snippet to the functions.php file of your active theme:

<?php
//Add Custom Content to End of Feed
function insertEndContent($content) {
$content = $content . '<p>Place your end of feed custom content here</p>';
return $content;
}
add_filter('the_excerpt_rss', 'insertEndContent');
add_filter('the_content_rss', 'insertEndContent');
?>

Just edit the second line of the function to include the desired code, markup, or text content. This function works by appending the specified custom content to the post content. Then, to ensure that the added content is only included within your feeds, we are using WordPress’ add_filter() function to execute the code only for full and excerpted feed content.

2. Add Content Before The Feed Entry

By changing the code slightly you can insert custom content to appear before your regular feed content:

<?php
//Add Custom Content to Start of Feed
function insertStartContent($content) {
$content = '<p>Place your start of feed custom content here</p>' . $content;
return $content;
}
add_filter('the_excerpt_rss', 'insertStartContent');
add_filter('the_content_rss', 'insertStartContent');
?>

3. Add Custom Content Before and After Feed Entry

You can combine these snippets to include custom content both before and after your feed:

<?php
function insertContent($content) {
$content = '
<p>This content appears before the feed post.</p>' . $content . '
<p>This content appears after the feed post.</p>';
return $content;
}
add_filter('the_excerpt_rss', 'insertContent');
add_filter('the_content_rss', 'insertContent');
?>

NOTE: The code above adds your custom content before and/or after each entry in the feed. You will have to use CSS rules to style the content e.g. to place it on a line of its own above or below the feed entry etc. You can achieve this by using classes in the content markup that you add in.

An Excellent Resource for Independent Artists

Featured

If you’re an independent musician who values your creative freedom and control and who is keen to take a DIY approach to your music and everything connected to it then you could do a lot worse for yourself than visiting the fantastic Bemuso website which can be found at: http://bemuso.com

You will find all sorts of useful information about the music industry, how it works, how you can use it to your advantage and how you can take a DIY approach to safeguarding your creative talents and retaining some control. It’s a hugely tough game to make sustainable progress in even for the most talented. However, one thing that is absolutely beyond doubt is the simple fact that knowledge and preparation will NOT cause you harm. The information in the site will definitely help you understand the industry better.

Go ahead, check it out if you’re an unsigned artist, an independent artist, a promotor, a manager or just an interested individual.

DISCLAIMER: I’m not associated or involved with the site in any shape or form. I’m just a very grateful consumer of the information that has very kindly been made available free of charge on the site and feel it deserves promotion. Consider this a sincere thank you to the site owner.

[ratings]