Goldilocks and the sandwich board…

There’s something in all of us that likes to be needed, to be wanted and adored. Whether that’s the short term kicks of a Tinder match or a pat on the back from your boss, or it’s…

Source: Goldilocks and the sandwich board…

Why it hurts – #kenlivingstone

Not a rant; more considered and measured than Mr Livingstone deserves.

A conglomerate of yodeling hippopotami

Ken Livingstone has come out with some extraordinary comments today about depression.

 

He was appointed to the Labour defence review, which caused much comment – including comments made by Kevan Jones, MP for Durham North.

  

In response to these particular comments Mr Livingstone said ‘I think he might need psychiatric help. He’s obviously very depressed and disturbed. He should pop off and see his GP before he makes these offensive comments.’

  

On LBC he was pushed to apologise, but apparently refused, because ‘He was rude about me, I was rude back to him, he needs to get over it’ and said he wouldn’t have said what he said had he known that Mr Jones had had depression.

 

The problem is, the comments he made were bad enough – ridiculing someone’s mental health as a response to political criticism is appalling. However, the comment that…

View original post 276 more words

A review of my music teaching this year

Some amazing music making is going on in our primary schools

Primary Music Matters

One of the best things about teaching is that the summer holidays gives you a chance to reflect how your year has gone and the opportunity to make improvements the following year. It is a real luxury that we get the time and space to do this.

I felt  dissatisfied and downbeat about how my school year ended. Things were not helped by a last week Ofsted visit – and no, they didn’t want to talk to me or even pop their head round the door when I was teaching!

It really brought home to me how isolated the job of primary school music coordinator is. Now I have wonderful colleagues who are supportive of the work I do but the ridiculous pressure they are under means that I am increasingly isolated. Twitter has been fantastically helpful in helping me overcome this isolation and I am grateful to the many…

View original post 1,240 more words

Simple programs

Like most programmers, I sometimes have to return to a language I have used for a while, and it’s like I’ve never written in it before! It takes a couple of hours to get my head in the game and remember what I’m doing. So, I thought, what if I write a standard simple program, and write it in every language I know. That would be useful in the future, as a reminder.

The program should accept the name of an input file on the command line. That input file contains my name, Tim. The code must produce a new version of the file, replacing Tim with a name passed on the command line.

[tjinkers@ebl-oel6vm1 file_reader]$ cat input.txt
This file belongs to Tim. Tim owns it
and any changes must be made by Tim.
If you change it without Tim's permission
Tim will get cross.

[tjinkers@ebl-oel6vm1 file_reader]$ ./file_reader.pl -f input.txt -c Tim -n David
[tjinkers@ebl-oel6vm1 file_reader]$ cat input.txt.out
This file belongs to David. David owns it
and any changes must be made by David.
If you change it without David's permission
David will get cross.

[tjinkers@ebl-oel6vm1 file_reader]$

In Perl this looks like:

#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Std;
our ($opt_f, $opt_n, $opt_c);
my ($line);
getopt('f:n:c:');
die "Please enter a file to process using -f \n" unless (defined $opt_f);
die "Please enter a new name using -n \n" unless (defined $opt_n);
die "Please enter the name to change using -c \n" unless (defined $opt_c);
die "Unable to open input file " unless (open my $infile, "", $opt_f . ".out");
while () {
    chomp;
    $line = $_;
    $line =~ s/$opt_c/$opt_n/g;
    print $oufile $line . "\n";
}
close $infile;
close $oufile;

In Python 2 we have

#!/usr/bin/python
import os
import re
from optparse import OptionParser
SUFFIX=".out"

def main () :
    global filename
    parser = OptionParser()
    parser.add_option("-f", "--file", dest="filename",
                      help="the file to update", metavar="FILE")
    parser.add_option("-n", "--name", dest="name",
                      help="the name to replace Tim with", metavar="NAME")
    parser.add_option("-c", "--fromname", dest="fromname",
                      help="the name be replaced", metavar="FROMNAME")
    (options, args) = parser.parse_args()
    if  not options.filename :
        print "You must specify the file to modify"
        exit(-1)
    if  not options.name :
        print "You must specify the name to replace Tim with"
        exit(-1)
    if  not options.fromname :
        print "You must specify the name to be replaced"
        exit(-1)
    fin = open(options.filename, 'r')
    fout = open(options.filename + SUFFIX, 'w')

    for line in fin :
        fout.write(re.sub(options.fromname, options.name, line))
    fin.close()
    fout.close()

main()

Java now – a bit more wordy!

import java.io.*;
public class filereader {
   public static void main (String[] args) {
      String p_f = null;
      String p_n = null;
      String p_c = null;
      String SUFFIX = ".out";
      int i = 0;
      while (i < args.length ) {
         // Process -f
         if ( args[i].compareTo("-f") == 0 ) {
            i++;
            if ( i < args.length ) {
                p_f=args[i];
            } else {
                System.out.println("No file name specified");
                System.exit(-1);
            }
         }
         // Process -n
         if ( args[i].compareTo("-n") == 0 ) {
            i++;
            if ( i < args.length ) {
               p_n=args[i];
            } else {
               System.out.println("No new name specified");
               System.exit(-1);
            }
         }
         // Process -c
         if ( args[i].compareTo("-c") == 0 ) {
            i++;
            if ( i < args.length ) {
               p_c=args[i];
            } else {
               System.out.println("No name to change specified");
               System.exit(-1);
            }
         }
         i++;
      }
      if ( p_f == null ) {
         System.out.println("No file name specified");
         System.exit(-1);
      }
      if ( p_n == null) {
         System.out.println("No new name specified");
         System.exit(-1);
      }
      if ( p_c == null) {
         System.out.println("No name to change specified");
         System.exit(-1);
      }
      File infile = new File(p_f);
      if ( ! infile.exists() ) {
         System.out.println("File " + p_f + " not found");
         System.exit(-1);
      }
      try {
         FileReader ifile = new FileReader(p_f);
         FileWriter ofile = new FileWriter(p_f + SUFFIX);
         BufferedReader buffer = new BufferedReader(ifile);
         BufferedWriter obuffer = new BufferedWriter(ofile);
         String line = "";
         while (( line = buffer.readLine() ) != null ){
            obuffer.write(line.replaceAll(p_c,p_n));
            obuffer.newLine();
         }
         buffer.close();
         obuffer.close();
      }
      catch ( IOException e) {
         System.out.println("A file error occured");
      }
   }
}

C++
I am no C++ programmer, a proper C++ coder will probably look at this code and laugh!

#include 
#include 
#include 
#include 
using namespace std;

int main ( int argc, char *argv[] )
{
   string filename;
   string ofilename;
   string fromname;
   string name;
   string line;

   if ( argc != 7 ) {
      printf( "usage: %s filename\n", argv[0] );
      return -1;
   }
   int i = 0;
   while ( i < argc ) {
      if ( strcmp(argv[i], "-f" ) == 0 ) {
         i++;
         if ( i < argc ) {
            filename.assign(argv[i]);
            ofilename.assign(filename + ".out");
         } else {
            cout << "No file name specified" << "\n";
            return -1;
         }
      }
      if ( strcmp(argv[i], "-n" ) == 0 ) {
         i++;
         if ( i < argc ) {
            name.assign(argv[i]);
         } else {
            cout << "No new name specified" << "\n";
            return -1;
         }
      }
      if ( strcmp(argv[i], "-c" ) == 0 ) {
         i++;
         if ( i < argc ) {
            fromname.assign(argv[i]);
         } else {
            cout << "No name to change specified" << "\n";
            return -1;
         }
      }
      i++;
   }
   if ( filename.size() == 0 ) {
      cout << "No file name specified" << "\n";
      return -1;
   }
   if ( name.size() == 0 ) {
      cout << "No new name specified" << "\n";
      return -1;
   }
   if ( fromname.size() == 0 ) {
      cout << "No name to change specified" << "\n";
      return -1;
   }
   cout << "File Name: " << filename << "\n";
   cout << "Output File Name: " <<  ofilename << "\n";
   cout << "Name: " << name << "\n";

   ifstream iptr;
   iptr.open(filename.c_str(), std::ifstream::in);
   if ( ! iptr ) {
      cout << "Unable to read " << filename << "\n";
      return -1;
   }
   ofstream optr;
   optr.open (ofilename.c_str(), std::ofstream::out);
   if ( ! optr ) {
      cout << "Unable to write to " << ofilename << "\n";
      return -1;
   }
   while ( ! iptr.eof() ) {
      getline( iptr, line);
      while ( line.find("Tim") < line.length() ) {
         line.assign(line.substr(0,line.find(fromname)) + name 
             + line.substr(line.find(fromname) + fromname.length()));
      }
      optr << line << "\n";
   }
   iptr.close();
   optr.close();
}

More languages to follow!

No Rota at St Mark’s!

Could we survive without rotas – or at least with fewer rotas? I can think of 11 rotas straight away that we need for a Sunday morning.

The Parish of Badshot Lea and Hale

St Mark’s Church in the Parish of Badshot Lea and Hale has grown by over 40% in the last year and the new people are mainly families with Primary School aged children. The ethos of St Mark’s is that every member is equal – in particular the children are fully included in the service and all the activities of the church are open to all on an equal footing.

Until recently there had been a rota for all the jobs – sidesperson, server, intercessions, reader, coffee making and so on. However, it tended to be only the more established members of the congregation who could commit to the rota – families preferred to remain flexible, and in particular most of the jobs were inappropriate to give to children.

So the congregation of St Mark’s are trying something new. They have made lots of cards with various jobs on them, for…

View original post 186 more words

Flower in an old mug

image

I used a tile drill to make holes in the base.

Trig blades

 

This blade, manufacturer in Pakistan, was part of a selection pack I bought of eBay. It looked promising, and started off OK, but on the very first shave I could feel the edge fading away from almost the start. By the end of the save it was like a 3 day old razor – and I don’t consider that I have particularly heavy stubble.

This is one to avoid in future.