Tuesday, 27 January 2009

 

#StagDo Pictures of the VASE of Drink. I was impressed :)


I'd had probably 3 or 4 shots out of the bottle before I emptied the rest of the 70cl into a vase, and topped up with coke. Nice. Photos by Jamie Dexter of Dextr.co.uk

See and download the full gallery on posterous


Sunday, 25 January 2009

 

#StagDo om nom++ Sunday Roast



Monday, 19 January 2009

 

SNOW! (View from my window again)



Saturday, 10 January 2009

 

Christmas Day - Take 2


Because I wasn't very well over the Christmas and New Year fortnight, Jules and I agreed to go out for a Christmas Lunch, have a few drinks and then home for Christmas Pudding and Brandy Butter.

So far, we're up to Christmas Dinner. We had a couple of drinks at The Orangery (very nice), we're at the Carvery (the only place we could guarantee turkey after Christmas) and we're just trying to decide what to do next.

Ruby_Gem (http://twitter.com/ruby_gem) said you can't go out for Christmas Dinner, but I guess this disproves that theory :)

Oh, and on this plate, the turkey is somewhere under the roast potatoes, peas, cabbage, apple sauce, cranberry sauce, gravy and of course Yorkshire Pudding :D


 

Setting up NTP on Debian

Introduction

What is NTP? It is a UDP protocol for correcting system clocks.

Why am I using it? I've got a couple of Debian based machines running on VMWare, and the clock keeps going out of sync. I want to have as little overhead on these boxes as possible, so I set up an NTP Daemon on the VMWare host, and then the NTP Clients on the VMWare Guests.

My Sources

I followed this guide, but it was a little unclear, so I figured I'd follow it up and add my notes to the mix.

Setting up the server

Firstly, I had to get the NTPd running on the server. The Host machine is running Debian, but if you aren't, then provided you can install an NTP server on the server, you'll be OK.

I installed ntpdate and ntp from the Debian repositories using the following apt command:
apt-get install ntp ntpdate
Next, I stopped the NTPd using this command:
/etc/init.d/ntp stop
I then ran the ntpdate command (which won't run while the ntpd is running) to bring the clock into sync with the upstream server:
ntpdate pool.ntp.org
If you've got a more local NTP server, use that in place of the pool.ntp.org.

Next, use the date command to ensure the clock is closer to being in sync.

  • If you've got a local NTP server, you should edit the file /etc/ntp.conf and either add to the server lines (if you also want to keep access to the existing pool of NTP servers) or comment out the existing server lines.

  • Add your server in the format (where the server's IP address is 111.222.333.444):
    server 111.222.333.444
  • Start the NTP daemon using the command:
    /etc/init.d/ntp start
    Finally, type the following command:
    ntpq -p
    This may take a few moments, but should return some sort of text like the following:
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
    11.111.11.11 222.222.2.222 2 u 21 64 377 0.603 65.748 7.470
    Setting up the clients

    Essentially, the steps here are exactly the same as with the server, except, where you point all of your NTP sources at a common IP address for the host machine.

    Labels: , , , ,


     

    Sending E-Mail Using Sendmail Without A DNS Server

    I was struggling with this issue, until I found this post.

    If you're building your server in a DMZ without a DNS server, your first step is to update the Smart Host entry (listed as DS on the sendmail.cf file or SMART_HOST in the sendmail.mc file) to show the following

    DSsmtp:[123.123.123.123]

    OR

    dnl define(`SMART_HOST',`smtp:[123.123.123.123]')

    Update: 2009-02-09

    While trying to implement this on a box, I've noticed that there's a slight addition to make. You'll also need to make this change in the submit.cf file if you're editing the cf files directly.

    If you want your e-mails to come from a specific DNS name, search for the line beginning Df (which will probably be commented out) and make your hostname show in there. (This hint found here)

    Labels: , , ,


    Friday, 9 January 2009

     

    Do you have slow SCP speeds? If so, try this

    A colleague pointed me at this hint recently which in turn was a hint obtained from another website, that the author was unable to credit, due to him having lost the link.

    Edit your /etc/sysctl.conf file and add the following text to the bottom:
    net.ipv4.tcp_window_scaling = 1
    net.ipv4.tcp_rmem = 4096 87380 16777216
    net.ipv4.tcp_wmem = 4096 65535 16777216
    net.ipv4.tcp_mem = 8388608 8388608 16777216
    As to whether this is appropriate guidance any more, I don't know, but I thought I'd share it to make sure it doesn't get lost in the ether.

    Labels: , ,


    Thursday, 8 January 2009

     

    PHP Object Orientation - a brief introduction

    This week, I attended PHPNW, which is a monthly meeting for PHP developers in Manchester. While I was there, I got talking to Adrian Hardy about Object Orientated PHP - something which has confused me for a while.

    Let me explain. Originally, PHP had no Object Orientation to it at all, but in late version 4, the developers started to add Object Orientated methods and calls to PHP. I never really saw the point of coding in an OO way, but we had a bit of a talk about how OO works, and I must admit, I'm a bit of a convert.

    So, for a first example, Adrian talked me through writing some code. Here's what we wrote (ish - I have my own coding standards, so have changed a bit from what he told me to write, but the fundamentals are there):
    class Person {
    private $name='';
    private $sex=FALSE;

    public function setName($name='') {
    $this->name=$name;
    }

    public function setSex($sex='') {
    $this->sex=$sex;
    }

    public function doWalk() {
    if($this->name!='') {
    if($this->sex!=FALSE) {
    echo "Hello, I'm {$this->name}, a {$this->sex}, and I'm going for a walk\r\n";
    } else {
    echo "Hello, I'm {$this->name} and I'm going for a walk\r\n";
    }
    }
    }
    }

    $body_one=new Person;
    $body_one->setName("Sam");
    $body_two=new Person;
    $body_two->setName("Bob");
    $body_two->setSex("Male");
    $body_one->doWalk();
    $body_two->doWalk();
    This should give us the text:
    Hello, I'm Sam and I'm going for a walk
    Hello, I'm Bob, a Male, and I'm going for a walk
    Of course, all this is very good, but there are three reasons I love the idea of OO, and the first is that you can extend a class, and the second is you can auto-populate your class with all it's data using a construct function. So, here's an example of extending the class "Person" (which, in effect copies all the functions and variables from the Person Class to the Man class), and using a construct function. This will return the same result as before, but with two extra lines at the end.
    class Person {
    private $name='';
    private $sex=FALSE;

    public function setName($name='') {
    $this->name=$name;
    }

    protected function setSex($sex='') {
    $this->sex=$sex;
    }
          if($this->sex!=FALSE) {

    echo "Hello, I'm {$this->name}, a {$this->sex}, and I'm going for a walk\r\n";
    } else {
    echo "Hello, I'm {$this->name} and I'm going for a walk\r\n";
    }
    }
    }
    }

    Class Man extends Person {
    public function __construct($name='') {
    if($name!='') {$this->name=$name;}
    $this->sex="Male";
    }

    protected function setSex($sex='') {
    if($sex!=$this->sex) {echo "Congratulations, you have changed your sex!\r\n";}
    $this->sex=$sex;
    }
    }

    $body_one=new Person;
    $body_one->setName("Sam");
    $body_two=new Man("Bob");
    $body_one->doWalk();
    $body_two->doWalk();
    $body_two->setSex("Female");
    $body_two->doWalk();
    Now looks like:
    Hello, I'm Sam and I'm going for a walk
    Hello, I'm Bob, a Male, and I'm going for a walk
    Congratulations, you have changed your sex!
    Hello, I'm Bob, a Female, and I'm going for a walk
    The last thing I like the idea of, is to auto load classes... so, in your index page, or default include, you'd include this code:
    spl_autoload_register('__autoload_me');
    ini_set('include_path', '.');

    function __autoload_me($strClass) {
    echo "Searching for: $strClass\r\n";
    $strFilename="./$strClass.php";
    if(file_exists($strFilename)) {
    require_once($strFilename);
    } else {
    return false;
    }
    }
    This spl_autoload_register can be included as many times as you want, and is called for each new class that hasn't already been retrieved. You don't need to call it __autoload_me, you could call it Class_Loading_DoHicky or Call_Classes_With_Me or whatever your coding standards say, but doing something obvious like __autoload_me means you'll never miss it :)

    That's it for now, I hope I've not made it too complicated :)

    Labels: , , , , ,


    This page is powered by Blogger. Isn't yours?

    Subscribe to Posts [Atom]