Get yourself a Satellite developer

7

Posted on : 30-05-2009 | By : Japh

The new Satellite website is now live!

If you don’t already know, I recently started full-time freelance development. The idea is that anyone who needs development work done, wherever they are, can contact me to help out on their project.

Whether you are a freelance designer who needs some development done (or even some training), or a freelance developer who needs an extra pair of hands, or even a bigger business who needs to bring someone else in on a project…  I’m available for hire!

I would love to hear any feedback on the new website too, so feel free to leave any comments in that regard as well.

Custom default Gravatar in WordPress 2.7

8

Posted on : 02-04-2009 | By : Japh

If you’ve been using WordPress for a little while, and don’t really much like the default options you have to choose from when a commenter doesn’t have their own Gravatar, why not make your own?

Make yourself a little square image to use that matches in with your theme, and then insert the following line of code:

<?php echo get_avatar( $comment, 86, 'http://example.com/custom-default-av.png' ); ?>

Note: you must provide the full absolute URL for your image.

What this line does, is show a Gravatar for the user if they have one, and if not, show your custom one instead. The number “86″ is the pixel width and height you want the Gravatars to display at.

Remember that this will only work in WordPress 2.7+, or possibly in older versions if you have the Gravatar plugin installed (not tested).

Update: If you don’t know what a Gravatar is, check out the comments. The avatar’s shown beside each comment are automatically pulled in from Gravatar’s service, so you upload your avatar once, and it appears everywhere when you comment etc. Get yourself one here: Gravatar

Time-sensitive CSS

8

Posted on : 31-03-2009 | By : Japh

Have you ever wanted to load a specific stylesheet depending on what time it is? It is actually very easy to do!

View Demo

I’m using jQuery in this just because it makes it look a little simpler, it’s not much more complex to do without jQuery… but let’s face it, you’re probably already using jQuery anyway, so why not ;)

Make yourself a new file to put your javascript into, I’ve called mine “script.js”. Include the new javascript file by putting this line in your HTML <head></head> section with the following line:

<script type="text/javascript" src="script.js"></script>

Now open your “script.js” file, and put the following lump of code into it:

// This line depends on jQuery, and tells the browser to kick off this stuff once
// everything's fully loaded
$(document).ready(function () {
    // These two lines make set a Date variable with the current date and time
    var currentDate = new Date();
    var currentHour = currentDate.getHours();
 
    // Here we're creating a new <link /> to insert in the <head></head>
    var newCSS = document.createElement('link');
    newCSS.type = 'text/css';
    newCSS.rel = 'stylesheet';
 
    // This is where you can determine when to use which stylesheet.
    // If the current hour is before 9am or 8pm (or later), use "night.css"
    if (currentHour < 9 || currentHour >= 20) {
        newCSS.href = 'css/night.css';
    }
    // Otherwise, use "day.css"
    else {
        newCSS.href = 'css/day.css';
    }
    // This line actually does the deed, and attaches the selected stylesheet
    $("head").append(newCSS);
 
    // This line isn't necessary, it's just showing the actual time in the demo.
    $(".satellite").html(currentDate.toTimeString());
});

Read the commenting to understand what’s actually going on there, but that should do it! Easier than you thought, I bet :)

If you have any questions or suggestions, leave a comment!

Sending scheduled emails with PHP

5

Posted on : 07-03-2009 | By : Japh

Ok, so there are two main topics being covered here:

  1. Sending emails with PHP
  2. Running PHP scripts with a cronjob

Read the rest of this entry »

Tracking memory usage

3

Posted on : 06-02-2009 | By : Japh

Recently I received a warning from my host that I was WAY over my memory limit. I had some long running processes going, and a few cron scripts that altogether were using about 220mb out of my 120mb of allowed memory usage… oops!

Anyway, there’s currently no way from my control panel to see how memory I’m currently using, I have to run a command from a terminal, and certainly no way to tell usage over time. So, after looking at a thread my hosting provider pointed me to, I decided to have a play with the Google Charts API!
Read the rest of this entry »