Monthly Excel planner

December 19th, 2011

I’ve previously produced a weekly planner Excel spreadsheet, but recently I’ve needed to use a monthly planner with hourly time slots.

It is a simple one page monthly planner. The times from 6am-1am are along the top, and the days of the month from 1-31 are down the side. For the months with 28, 29, or 30 days long you can just cross out or delete the extra days. If you need a different time range it is very easy to edit as well.

monthly excel planner

You can either use this on screen, or print it out. With Microsoft Excel there is an easy option to specify that you want the planner to fit on a single A4 sheet of paper. In the ‘Page Setup’ window set the orientation to Landscape and tell it to fit to 1 page wide by 1 page tall. Here is the free download link:

Download monthly Excel planner – 9kB zipped

I’ve saved this as a Microsoft Excel 97 XLS file so it should work in all old or new version of Microsoft Excel or OpenOffice.

2013 Staff holiday planner spreadsheet

November 18th, 2011

At the time of writing it nearing the end of 2011 so some of you may be searching for my previous staff holiday planner for 2012. If you are planning very far ahead (or if you are reading this in 2012/2013) you might want my 2013 staff planner. This is my latest free spreadsheet that can help you track staff holidays, training, sick days and offsite days.

2013 staff holiday planner spreadsheet

It comes configured with formulas that can automatically track the total number of holiday days remaining (columns C&D) for each employee. If you don’t want to use this simply delete those columns.

The default formula subtracts 1 or 0.5 from the remaining holiday if the employee cells contain the words ‘holiday’ or ‘half. You can copy and paste (ctrl-c, ctrl-v) the coloured tags (holiday, half, training, etc) from the top left into the staff planning cells and the totals are automatically updated.

It is easy to customise the formulas if you want to factor in sick days for example. See the 2012 planner for more example formulas. Note that the 2013 calendar formulas count the entire row (which includes the last bit of 2012 and the first bit of 2014), whereas the 2012 calendar formulas just count the 2012 year. You can adjust the formulas to suit your requirements.

As always the week numbers are based on ISO 8601, and the top and left parts of the staff planner are frozen so you can always see them – this makes navigation easy. Here is the download link:

Download 2013 staff holiday planner spreadsheet – 23kb

As the staff holiday planner has over 365 columns you won’t see the whole year if you open it with an ancient spreadsheet package such as Excel 97. You’ll need to use a more modern spreadsheet package such as Excel 2007 or OpenOffice (which is free). One workaround if you are forced to use Excel 97 at work is for you to use OpenOffice at home to split the spreadsheet into 2, one part for 2013 H1, and one for 2013 H2.

Extending a leasehold, Section 42 and the LVT

October 4th, 2011

I recently completed a leasehold extension which involved issuing a Section 42 notice and applying to the Leasehold Valuation Tribunal. It was a long process but now that it is over I can share an account of what happened.

leasehold extension

If you have bought a property in the UK there is a high chance that you have bought a leasehold. A leasehold is like a very long term rental. Instead of renting for 6 months you are renting for 10s or hundreds of years. The ultimate owner of the land or property is the freeholder. If you own the freehold, or a share of the freehold you will never have to worry about extending the lease (because you own the land/property, and are not leasing it).

In this post I’m going to give real figures for the surveyor and solicitor costs for both sides, but I don’t want to reveal the actual property value or premium amount. I will however give re-scaled figures. I am going to use the diamond symbol ⋄ as my unit, and have re-scaled all the premium costs based on the property being worth 100,000 of this units at the time the process was started– so ⋄100,000.

You can quickly turn the premium estimates and valuations into percentages of the property price by dividing by 1000.

The rough lease extension process

In order to extend a lease you will have to pay your own surveyor and solicitor costs, as well as your freeholder’s costs.

If the lease is less than 80 years in length you will have to pay the freeholder 50% of the marriage value. The marriage value is the increase in property value as a result of extending the lease.

You can come to an agreement without invoking the Section 42 process if both sides are happy with this. But in many cases both sides don’t agree, so the statuary Section 42 process will need to be invoked.

Issuing a Section 42 notice to the freeholder will force him to give you valuation, and it mandates that the process and outcome follow a standardised set of rules. These include fixing the time scales by when each side has to respond, the terms of the new lease, and the right for the leaseholder to take the case to the Leaseholder Valuation Tribunal if no agreement can be reached.

If the LVT stage is necessary then each side will be responsible for their own costs for this stage.

Initial enquiries – July 2009

I’d owned my property for about 8 years and had been aware of the lease length slowly ticking down. It had got down to about 67 years before I first did something about it.

I sent an initial letter to the freeholder asking him for a rough figure as to what it might cost. He replied a week later saying that I would have to pay for his surveyor costs (£850+VAT) to get a proper valuation, but he guessed it might be around ⋄8600. This would not be for a 90 year statutary lease extension, this would be for a negotiated extension whereby the existing lease would be surrendered and a new 125 year would be granted.

There are several problems with going down the negotiated route.

  1. The freeholder can give you any valuation he likes. Even though he guessed ⋄8600 in his letter he could well come back with a figure of ⋄15000 later on. By which time the £850+VAT valuation fee has been paid. And this valuation is not necessarily valid for the S42 process – you may have to pay the freeholder’s valuation costs again if you then decided to abandon the negotiated route and go down the S42 route.
  2. The negotiated lease could contain clauses that are unreasonable.
  3. It is likely you would have to agree to a rise in the ground rent.

Forming a group – February 2010

I did nothing more until the next year when one of the other residents in my building sent round a letter asking if anyone was interested in joining him in extending their leases in a group to save on surveyor / solicitor costs.

This seemed like a good idea so I sent him my name. He had already contacted a surveyor and solicitor that he recommended we use. There were 4 people with 5 flats originally in the group, but one dropped out later. The core group was 3 people, with 4 flats between us.

Surveyor valuation – May 2010

The first step would be the surveyor’s valuation which would cost £587.50 each. I had to give him a £100 deposit to commit. By the end of March we had all committed and his visit was scheduled for May.

When he visited he looked at the existing lease and made some notes about it. Then he looked around the flat and took some measurements. After he’d been to all our flats we all had a drink together and he told us about the process and answered our questions.

Two weeks later we received his valuation. He estimated the cost of a statutary lease extension at ⋄7500. He recommended we put in an offer at ⋄5800. And he predicted that the freeholder might try to seek a figure of around ⋄9300.

Issuing the Section 42 notice – July 2010

Around the time the surveyor’s valuation was carried out I arranged for the solicitor to make an ordinary power of attorney (PoA) so a relative could act on my behalf whilst I was away in Japan.

In June the solicitor was given the go-ahead to issue the Section 42, and in July the notice was served – it was signed by a relative using the PoA.

Once the Section 42 is served the freeholder has two months to respond. And once the Section 42 has been served the freeholder can insist on 10% of your offer price being put on deposit with your own solicitor. As my offer was for ⋄5800 this meant I had to send a ⋄580 deposit.

A month later in August the freeholder responded disputing the validity of the Section 42 notice as it had not been signed by me personally. I had to send over a new signed Section 42 notice from Japan which had to be re-served on the freeholder. This unfortunately resets the two month period.

Valuation received from freeholder – October 2010

In October 2010 the counter notice was received from the freeholder. His valuation was ⋄11100, much higher that even the surveyor’s expectation of what the freeholder might ask for.

Negotiation

Now that the counter notice had been received there were three options.

  • Give up!
  • Come to a agreed price by negotiation.
  • Take the matter to the leasehold valuation tribunal. They can made the decision on the fair price for you.

An application to the leasehold valuation tribunal (LVT) has to be made within 6 month of receiving the counter notice from the freeholder.

That meant there was about 5 month of negotiating time left before we felt we needed to get the LVT application ready (best not to leave it to the very last minute!).

Over a month later my surveyor managed to get a copy of the freeholder’s surveyor’s calculations. But the freeholder’s surveyor remained fairly elusive and non-responsive for the next 4 months. Although both surveyors occasionally communicated little common ground was found. Much of the disagreement seemed to centre on what percentage to use for the ‘relativity’ in their calculation.

No offers or counter offers were made during this time. Occasionally I would email the surveyor for news, and after waiting 2-4 days he’d reply saying there wasn’t much to report.

The surveyor estimated that if this went to tribunal his costs would be around £1500. And we would have to pay for our solicitor to attend the tribunal as well – the solicitor never gave an estimate of his costs for attending the LVT.

Application to the LVT – March 2011

It reached March 2011 and the 6 month deadline was looming so we asked the solicitor to make the LVT application. 10 days later the LVT acknowledged that the application was in their system.

In April the LVT issued some written directions stating when the freeholder must send the draft lease for us to look at, and a suggestion that the hearing take place between June and August 2011.

Lease terms agreed – May 2011

In May the solicitor contacted us to say that the terms of the draft lease had been agreed. This is referring to the wording of the lease, not the premium. That was still very much unresolved!

An offer from the freeholder – May 2011

At the end of May, to our surprise, we received an offer from the freeholder. He would agree to settle for ⋄9300. This was much lower than his original offer of ⋄11100, but still a lot higher than my surveyor’s estimate of the fair value being ⋄7500.

Agreement – June 2011

In June the final premium of ⋄9300 was agreed. The agreement was signed by a relative using the PoA which had earlier on invalidated the initial S42. The money was transferred in July, and the final lease, and Land Registry documents were received at the end of August.

Leasehold extension timeline

Here is the timeline of events.

leasehold extension timeline

Here is the same timeline shown as a list.

  • 01/03/2010 Surveyor contacted
  • 31/03/2010 Surveyor given go ahead for valuation
  • 27/04/2010 Solicitor asked to prepare Power of Attorney
  • 04/05/2010 PoA ready
  • 11/05/2010 Surveyor valuation visit
  • 24/05/2010 Surveyor valuation received
  • 24/06/2010 Gave go ahead for solicitor to issue S42
  • 20/07/2010 S42 served on freeholder
  • 02/08/2010 10% deposit transferred
  • 18/08/2010 Freeholder disputes validity of S42
  • 23/08/2010 New S42 served on freeholder
  • 13/10/2010 Freeholder’s valuation received
  • 19/11/2010 Surveyor receives freeholder’s calculations
  • 07/03/2011 Asked solicitor to make LVT application
  • 17/03/2011 LVT acknowledges application
  • 15/04/2011 LVT issues written directions
  • 17/05/2011 Terms of draft lease agreed
  • 27/05/2011 Surveyor mentions possible offer to settle
  • 15/06/2011 Premium is agreed
  • 07/07/2011 Lease extension completion
  • 19/08/2011 New lease and Land Registry docs received

Lease extension cost breakdown

These prices include VAT. I haven’t included the £111.63 power of attorney, as this isn’t required in normal circumstances. I only had one arranged as I was going to be out of the country for a long time.

My surveyor

£587.50 – Valuation (based on 5 flats)
£600.00 – Negotiation (based on 4 flats)

My solicitor

£44.00 – Land Registry search for issuing Section 42
£60.00 – Issue the Section 42 notice (based on 4 flats)
£50.00 – Fee to ‘protect our position at the Land Registry’ for S42
£300.00 – Submit LVT application (based on 4 flats)
£300.00 – Dealing with new lease after issued by freeholder (based on 4 flats)
£50.00 – Land Registry fee for registering the title
£4.00 – Miscelaneous Land Registry search fee

Freeholder’s costs that I had to pay

£1057.50 – Surveyor
£1085.00 – Solicitor
£1.55 – Special delivery fee

Estimates vs valuation vs final price

This graph shows how the estimate, valuation and final price varied.

leasehold extension estimate vs final premium

Conclusions

The whole process took about a year and a half to complete and used £4139.55 in costs (surveyor/solicitor). The premium was another ⋄9300 on top of this (or 9.3% of the current estimated value of the property).

A lease extension is certainly an expensive and time consuming process.

It isn’t too complicated if you leave everything up to your surveyor / solicitor, but it may be best avoiding it in the first place by not buying a property with a short lease.

Ad Logger ‘click logging’ plugin for WordPress

October 4th, 2011

Ad Logger for WordPress is a new plugin for logging clicks on iframe adverts and other social network buttons. At the moment it can log Google AdSense / Amazon Associates adverts, and Facebook, Twitter and Google +1 social media buttons. It also has a ‘catch-all’ mode which will log any other iframe clicks.

Clicks stats in one place – You can get statistics for all these services individually but Ad Logger allows you to see all the clicks in one place. It will however give you different number; Ad Logger counts raw clicks, whereas your ad/social media provider will count valid clicks.

Raw click logs – With Ad Logger you can see the raw logs which will give you information that your ad/social media provider probably won’t allow you to see such as IP address, page referrer, and browser agent.

Reports – Ad Logger has an AJAX UI to allow you to move through the results easily. As well as seeing the log you can view reports showing the which browser, referrer, page, IP most of your clicks come from. And you can filter the results to show all the logs for a specific IP, page, iframe type, etc by clicking on the type icon, or the ⇓ arrows.

Click bombing protection – As it has access to the raw click logs Ad Logger can help you to combat intentional or accidental AdSense ‘click bombing’ by disabling adverts if too many clicks are registered. It can disable ads that you may have inserted using the Ad Injection plugin, or by dynamically hiding the div that you have put the adverts into.

Ad Logger’s main UI

Here is the main UI, from top to bottom you can see the yellow message bar which I use to highlight the latest updates, then the navigation buttons. To the right of the navigation buttons are the report links.
Next is the main log table – you can see it combines clicks from AdSense, Amazon Associates, Facebook, Twitter and Google +1. You can click on the type icon or the ⇓ arrows to filter your results.
Under the table you can set how many rows are shown at once.
Next are the boxes to select which iframes are logged.
Then the optional click blocking preferences.
Finally you can configure what information is shown in the log table, and what information gets stored to the database.

ad logger main ui

Example Ad Logger report

This is the type report and shows how many clicks occurred on each type of iframe. Here you can see that there were 27 clicks on Facebook like buttons, and 5 on Google +1.

ad logger type report

Filtered report

By clicking on any of the ‘type’ icons you can filter your results to just that type. Here I clicked on the Facebook icon and so am just seeing Facebook button clicks.

ad logger filtered

How does it work?

Ad Logger works by using JavaScript to monitor whether a click has ‘probably’ occurred. I say probably because this method isn’t 100% accurate. It is pretty good though. It notes when the mouse pointer has entered the iframe, and then listens for a ‘blur’ even which corresponds quite well to someone clicking on the ad/social button.

Ad Logger does not modify your original ad code, so hopefully won’t break your ad provider’s TOS. I can’t however guarantee this, so you have to make a judgement call as to whether you think it is safe for you to use.

Results are stored in a new table in your WordPress database. This table can be cleared of data at any time, and it will be automatically deleted if you uninstall the plugin. The plugin limits the size of the table to 100,000 rows (this will be configurable in a later release).

If you have configured click blocking then Ad Logger will use a cookie to count how many clicks have occurred. If the limit is reached then Ad Logger can then set another cookie which will prevent Ad Injection’s ads from being added to new pages, and/or it can remove the div containing the ads from the current page.

How much does it cost?

Nothing! £0, $0! You are however welcome to make a donation via the plugin UI if you find it useful. I have spent several hundred hours of my own time producing this plugin, which I have now released under a GPLv2 licence.

How do I install Ad Logger?

Ad Logger is available for free from the WordPress plugin repository.

The easiest way to install it by searching for ‘Ad Logger’ from the ‘Add New’ link in the ‘Plugins’ section of the WordPress UI.

Future planned features

Future planned features include being able to block adverts by IP address (which will work either standalone with Ad Logger, or in conjunction with Ad Injection), more awareness of other iframe types, and possibly the ability to log non-iframe events. E.g. other advertising/affiliate link clicks.

Panmunjom, DMZ and seeing the North Korean border

September 29th, 2011

Whilst on holiday in South Korea I went on a tour of Panmunjom and the demilitarised zone by the border of North and South Korea.

panmunjom dmz tour north south korea 4

There are lots of agencies running similar tours, and there are differences in what places you see on each tour. I booked about a month in advance via email for the ‘DMZ & Panmunjom’ tour run by the Panmunjom Travel Centre. They run several different tours, the one I went on was known as the ‘combined’ tour as it visited the DMZ and Panmunjom.

The day started shortly after 8am by registering at the Lotte Hotel in Seoul. The tour cost 120,000 Won (about £65) which I paid on the day, and after they checked my passport I was given direction to find the bus.

About 80% of the people in the bus were Japanese, and they’d separated the English speakers out and put us at the back of the bus so we could get English commentary. As the bus rode northwards the tour guide gave us some background on the Korean war and how the DMZ was created. She also explained about the security procedures that would take place once we reached the DMZ. On the bus was a lady who had defected from North Korea and we got to ask her questions before we reached the DMZ (she wasn’t allowed in this area).

panmunjom dmz tour north south korea 14

When we reached Camp Bonifas (named after a soldier who was killed by the North Koreans in 1976) a South Korean soldier came onto the bus to accompany us for the tour. He checked our passports and also had a look at what we were wearing. One of the other English speakers (an American) was singled out because he was wearing a t-shirt with an American theme. The tour guide explained that the soldier wasn’t happy about this. North Koreans don’t like Americans, so wearing this t-shirt would draw attention to him. Luckily they carry some spare clothes on the bus for people who are wearing the wrong kind of clothing. He was given an ill-fitting shirt which he had to wear whilst in the areas that would be in sight of the North Korean guards.

We drove through the DMZ and saw soldiers on the way, most of them lightly armed with just hand guns. When the bus reached the Joint Security Area (JSA) in the village of Panmunjom we got off and went into the Freedom House to watch a video about the history of the area.

Next we were allowed to walk to the front of the Freedom house from where we could see the North Korean side of the JSA. If you look at the top left of the photo towards the North Korean side, on top of their Panmungak building you will see another group of tourists. They are in North Korea and are on the North Korean version of the JSA tour. Neither we nor they are allowed to cross the border. They were waving and shouting at us, but we had been given instructions not to make any guestures, or say anything over the border.

panmunjom dmz tour north south korea 2

The blue ‘sheds’ straddle the border, and there is a small concrete block inbetween them which marks the border position. We were allowed to go inside the one on the left which is the MAC Conference Room where both sides can meet.

panmunjom dmz tour north south korea 1

Inside the conference room we were allowed to walk its full length crossing the line that marks the border. The border goes through the middle of the conference table. We were allowed to have our photo taken with the UN soldier who is in his ‘taekwondo pose’ but we were under strict instruction not to touch him – one lady got told off for trying to touch his arm while posing for a photo!

Back outside in the JSA we could see a North Korean soldier watching us through binoculars – they still wear old Soviet style uniforms. The UN soldiers and South Korean soldiers look quite distinctive. The UN soldiers look muscely, wear sun glasses and stand in motionless taekwondo poses. The South Korean solders are thinner, wear softer uniforms and casually walk around, many of them are young conscripts.

panmunjom dmz tour north south korea 3

This below shot shows the classic poses of the two sides. On our side two UN soldiers have positioned themselves so they are half covered by the conference rooms. This is to give them cover, and also to allow them to signal back to our side without being seen by the North Koreans. On the North Korean side two soldiers face each other, the idea being that if either of them tries to cross the border (a mere foot away from where they are standing) they other will shoot him. The North Korean soldier who is facing away from the camera is there to try to make sure no one else from North Korea tries to defect.

panmunjom dmz tour north south korea 4

We got back on another bus (a so called military bus – but it was just a bus, nothing unusual), and were acomponied by both our South Korean soldier and another military vehicle as we drove around some of the other sights in the JSA including the ‘Bridge of no return’.

The bus then drove to the ‘Imjingak Tourist Resort’. There are a selection of sights here such as a peace bell, memorial altar and this ‘freedom bridge’.

panmunjom dmz tour north south korea 5

We had lunch at a large Korean restaurant that seemed set up to receive coach groups. I’d requested a vegetarian meal in advance and so had a tasty vegetarian bibimbap.

After lunch we went to the Dora Observatory from where you can see the village of Kijŏng-dong, which the South Koreans call ‘the North Korean propaganda village’. The North Korean flag may only be a few pixels wide (towards the upper right) in my photo but it is huge and weighs 270kg.

panmunjom dmz tour north south korea 8

They have a rule here that you can only take photos behind the yellow line. The only way to get a decent photo is to hold the camera above your head and keep taking pictures until you get a good one.

panmunjom dmz tour north south korea 7

Next we went to the ‘3rd Infiltration Tunnel’, the 3rd such tunnel that the South Koreans had discovered. The North Koreans have dug many such tunnels over the years across the border. The tunnels were dug by hand and dynamite.

panmunjom dmz tour north south korea 9

You can take a small train down into the tunnel to have a look. No cameras are allowed in the tunnel so I only have a photo of the train. The actual tunnels are cramped and very roughly cut from where the rock has been dynamited.

panmunjom dmz tour north south korea 10

Our final destination before heading back was Dorasan Station. This station was built to connect North and South Korea but was only used briefly before the North Koreans closed the border.

dorasan station south korea 01

Now it is just a touist attraction. You can buy a platform ticket to go through the doors to Pyeongyang and walk on the platform.

dorasan station south korea 02

This is the very quiet platform of Dorasan Station looking in the direction that trains to North Korea would travel.

dorasan station south korea 03

After having seen the station we got on the bus for the final time back to the Lotte Hotel in Seoul. Overall the trip is well worth going on. It is expensive, but it isn’t possible to see all these sights unless you go with an organised tour. Before booking a tour make sure it visits the places you want to see as not all of them go to the same areas.

Include a different advert in each WordPress post depending on category

September 11th, 2011

I’ve had many requestes from people who want to include different adverts on each post according to the post category. One example would be a football website that has a different post category for each team. They might want different ads to show depending on the team. E.g. ads for Liverpool F.C. might not appeal to followers of Manchester United!

With Ad Injection there is no way to achive this directly in the UI, but by adding some simple PHP code to one of the ad slots you can do this.

1. In your plugins directory create a sub-directory called ‘ad-injection-ads’. e.g. /wordpress/wp-content/plugins/ad-injection-ads/

2. Create a text files in this folder for each of the categories that you want an ad for. The text files should be named [category nicename].txt The ‘nicename’ of the category is the category name with spaces and dots converted to ‘-‘ and apostrophes removed. e.g.

Liverpool = liverpool.txt
Manchester United = manchester-united.txt
A.F.C Aldermaston = a-f-c-aldermaston.txt
Bishop’s Stortford = bishops-stortford.txt

ad injection ad code box

3. Then put the code below (from the starting <?php to the closing ?>) into one of the ad box – shown above. The code will load the text file ad matching the category name when the post is displayed.

<?php
$plugin_dir = dirname(__FILE__);
$ad_dir = dirname($plugin_dir).'/ad-injection-ads/';
if (file_exists($ad_dir)){
    global $post;
    $categories = get_the_category($post->ID);
    foreach ($categories as $cat){
        // nicename: spaces and dots are converted to '-' and apostrophes are removed
        $full_ad_path = $ad_dir.$cat->category_nicename.'.txt';
        if (file_exists($full_ad_path)){
            $ad = file_get_contents($full_ad_path);
            if ($ad === false) echo "<!--ADINJ CATCODE: could not read ad from file: $full_ad_path-->n";
            echo $ad;
            break; // only show first category ad that matches
        } else {
            echo "<!--ADINJ CATCODE: could not find ad at: $full_ad_path-->n";
        }
    }
} else {
    echo "<!--ADINJ CATCODE: could not find ad directory: $ad_dir-->n";
}
?>

Some extra information:

  • This code will load one text file ad per post. If for example you had a post with the categories ‘Liverpool’ and ‘Manchester United’ it would load which ever ad it found first.
  • If will ignore categories that have no text file in the directory. If you have a post with the categories ‘Liverpool’ and ‘Latest News’ then it will always load the liverpool.txt as long as you don’t create a ‘latest-news.txt’.
  • This code will only work in ‘direct’ ad insertion mode. It won’t work in ‘mfunc’ mode.

Expansion ideas:

  • Show a default advert if no text file exists.
  • Create multiple text files for each category and then randomly select one (shown below).
  • Use different code for top, random or bottom ads. e.g. you could have liverpool_top.txt and liverpool_random.txt

Randomly picking one advert from a pool of ads

Here is a more complex example which allows each category to have a pool of text ads to choose from. It will randomly pick a file that contains the category nicename as a substring. If the category nicename is ‘liverpool’ the code will pick out any files in the directory containing ‘liverpool’, e.g. ‘liverpool.txt’, ‘liverpool1.txt’, ‘liverpool2.txt’. If you put this code into the ‘random’ advert and want a different advert to appear in each slot you should tick the ‘Re-select an ad for each position on post’ box in the ad placement settings of Ad Injection.

<?php
$adinj_filter_category_ads_filter;
if (!function_exists('adinj_filter_category_ads')){
function adinj_filter_category_ads($file) {
    global $adinj_filter_category_ads_filter;
    return strpos($file, $adinj_filter_category_ads_filter) !== false;
}}
$plugin_dir = dirname(__FILE__);
$ad_dir = dirname($plugin_dir).'/ad-injection-ads/';
if (file_exists($ad_dir)){
    $files = scandir($ad_dir);
    global $post;
    $categories = get_the_category($post->ID);
    foreach ($categories as $cat){
        // nicename: spaces and dots are converted to '-' and apostrophes removed
        global $adinj_filter_category_ads_filter;
        $adinj_filter_category_ads_filter = $cat->category_nicename;
        $filtered_files = array_filter($files, 'adinj_filter_category_ads');
        $random_file = array_rand($filtered_files);
        $full_ad_path = $ad_dir.$filtered_files[$random_file];
        if (file_exists($full_ad_path)){
            $ad = file_get_contents($full_ad_path);
            if ($ad === false){
                echo "<!--ADINJ CATCODE: could not read ad at: $full_ad_path-->n";
            }
            echo $ad;
            break; // only show first category ad that matches
        } else {
            echo "<!--ADINJ CATCODE: could not find ad at: $full_ad_path-->n";
        }
    }
} else {
    echo "<!--ADINJ CATCODE: could not find ad directory: $ad_dir-->n";
}
?>

Randomly picking many adverts from a pool of ads

This will pick a selection of adverts from an ad pool and display them all without duplicates. The use case for this could be if you want to display a selection of adverts down your sidebar. You might have a pool of 20 adverts, and this code can pick any number of those and show them in random positions, without duplicating any adverts. Name your adverts ‘widgetadpool1.txt’, ‘widgetadpool2.txt’, etc. Then modify the ‘$i < condition' in the for loop to select how many of the adverts you want to show.

<?php
if (!function_exists('adinj_adhtml_filter_ads')){
function adinj_adhtml_filter_ads($file) {
    return strpos($file, 'widgetadpool') !== false;
}}
$plugin_dir = dirname(__FILE__);
$ad_dir = dirname($plugin_dir).'/ad-injection-ads/';
if (file_exists($ad_dir)){
    $files = scandir($ad_dir);
    $filtered_files = array_filter($files, 'adinj_adhtml_filter_ads');
    for ($i=0; $i<10; ++$i){ // max num ads shown
        $random_file = array_rand($filtered_files);
        $full_ad_path = $ad_dir.$filtered_files[$random_file];
        if (file_exists($full_ad_path)){
            $ad = file_get_contents($full_ad_path);
            if ($ad === false){
                echo "<!--ADINJ RAND: could not read ad at: $full_ad_path-->n";
            }
            echo $ad.'<br />';
        } else {
            echo "<!--ADINJ RAND: could not find ad at: $full_ad_path-->n";
        }
        unset($filtered_files[$random_file]);
        if (empty($filtered_files)) break;
    }
} else {
    echo "<!--ADINJ RAND: could not find ad directory: $ad_dir-->n";
}
?>


Ad Injection 1.2.0.0 preview – WordPress ad management plugin

September 6th, 2011

Ad Injection (the plugin for injecting adverts into your WordPress blog) version 1.2.0.0 should be out in a week or two (mid-September 2011). Here is a preview of some of the new features – the screen shots are from the unreleased version so the UI may change slightly before release.

New ad positioning options

Ad Injection already has many options for selecting exactly how the top, random and bottom ads are positioned. But some people need more control, so 1.2.0.0 will have a load of new features.

ad injection placement settings

  1. With 1.2.0.0 it will be possible to have the top ad start at a position other than at the very top. You will be able to choose a paragraph for it to start, or a character position. If you choose a character position the ad will appear at the next paragraph after your chosen character. The character count is based on the raw number of characters in the content (which includes HTML tags).
  2. Ad Injection has had the option to select which paragraph the random ads start at for a long time. Recently I added options to start the ads ‘at or after’ a paragraph/character position as well. The new 1.2.0.0 will have options to start the ads from the middle of the post – particularly useful if you like a top, middle and a bottom advert. There are several different methods by which the middle position can be calculated.
  3. A brand new feature is to set a position to stop the random adverts. You can stop the adverts by paragraph/character count, in the middle of the post, or two thirds of the way down the post.
  4. These options were previously hidden away on the Ad Rotation tab. They all affect the ad placement settings so it made more sense to move them here.
  5. The bottom ad no longer has to be right at the bottom of the post. If you want it at the last-but-one paragraph, you’ll be able to do that.
  6. Another setting relevant to this section that was previously hidden away where you probably wouldn’t spot it.
  7. Instead of disappearing when you exclude all the home or archive ads, these sections will now fade away. This (I hope) makes it obvious that the options do exist, but that they are disabled.

Blogs with thousands of tags

I had been having intermittent reports that parts of the UI were not drawing on some blogs. I found out that this was caused on blogs that had large numbers of tags, but very little memory. The old Ad Injection would load all the tags at once (which on some blogs could be thousands).

A recent update to Ad Injection includes an update to load the tags in batches of 100, and the new 1.2.0.0 version will move the filters section futher down the screen, so if you do run out of memory you will (hopefully) still be able to use the most useful parts of the UI.

ad injection filters

Minor UI tweaks

You can see in this screenshot the tick boxes which will become transparent instead of invisible in Ad Injection 1.2.0.0. And on the right I’ve added the ‘days older than’ settings information to the summary. These are important settings so I think it makes sense to have the information easily visible.

ad injection global settings

New features :) / New bugs :(

This update will include major changes to the part of the code that does the insertion of advert into your post content. As such it may contain new bugs – but don’t worry I usually get bugs fixed pretty soon after they are reported. If you want to beta test the 1.2.0.0 version contact me via the feedback form in Ad Injection, or via this website.

If you have any comments on the soon to be released Ad Injection 1.2.0.0 please do get in touch.

You can download Ad Injection from the WordPress site, or from your blog by searching for ‘Ad Injection’.

How to edit PDF files for free

August 31st, 2011

I had a PDF form which I needed to fill in. The form was not editable, but I still wanted some way to fill in the fields on the computer rather than having to print it out and fill it in by hand.

A quick search shows that there are many other people wanting to do the same thing, but there aren’t many solutions that actually work. Many of the suggestions/solutions that I found online didn’t work at all. These were my requirements:

  • Add text to an existing uneditable PDF.
  • Save the PDF with the new text in place.
  • Ability to re-open the PDF and continue editing the newly added text.
  • I wasn’t interested in the ability to edit the PDF form itself – only the new text that I added.
  • The software should be free.
  • I didn’t want software with a time limited trial.
  • The software had to leave no watermarks on the PDF.
  • I wanted PC based software rather than web based – I don’t want to have to submit my PDFs to some company that I may never have heard of.

The software that I found that allowed me to fill in my PDF forms as per my requirements was called PDF-XChange Viewer.

How to install the PDF editing software

The easiest way to install PDF-XChange Viewer is to download the EXE installer from their webpage. You should be careful when installing, as by default it will change some of your computer’s settings and try to install a browser toolbar.

On the ‘Select Components’ screen I deselected everything except for the help file. I don’t want any extra menus added to Windows Explorer, browser extensions, or automatic update checking. This is a tool that I’m only going to use occasionally so I want it be unobtrusive when not in use.

pdf editor install 1

Then on the ‘Select Additional Tasks’ screen I made sure that the ‘Set PDF-XChange Viewer as default viewer for PDF files’ was unticked. I want to continue to use Adobe Reader for viewing PDFs.

pdf editor install 2

On the ‘Install the Tracker Ask Toolbar’ screen I unticked the top option. It would be easy to misread it if you are quickly clicking through the install, and think that this option is just to agree to the main licence terms. But read carefully and you’ll see that it is for agreeing to the licence terms for the Ask Toolbar and confirming that you want to install it. So untick it unless you want the Ask Toolbar.

pdf editor install 3

Finally when I started the tool for the first time I told it not to make PDF-XChange Viewer the default PDF viewer, and set the option for it not to ask me again.

How to add text to your PDFs

After carefully completing the install this is how to add text to your existing PDFs. I’m using a random uneditable PDF that I found on the internet.

First load the PDF into PDF-XChange Viewer. You should be able to figure out how to do that yourself!

The easiest way to write on the PDF is with the ‘Typewriter Tool. Go to Tools->Comment and Markup Tools->Typewriter Tool->Default Style to select it.

pdf editor typewriter tool

Then you can simply click anywhere on the document and start typing. You’ll see the Typewriter Tool cursor where the text will appear.

editing a pdf

To test that your changes get saved properly: save a copy of the PDF and then load it into Adobe Reader.

To test that you can re-edit your text additions: load the PDF back into PDF-XChange Viewer and try re-editing your text. You can double-click on your text to get the editing cursor back. And you can right click on any of your new text boxes to get the option to delete them.

Shibamata summer fireworks in Tokyo

August 24th, 2011

On Tuesday 26th July 2011 I went to see the summer fireworks display at Shibamata, north east of central Tokyo. From the station I had to walk through a traditional street before getting to the park where the fireworks were to take place.

shibamata fireworks tokyo 1

I made it to the park by the river just before the fireworks started. The fireworks were very impressive – they went on for about 40 minutes, and the promotional material said that they were going to us 7000 fireworks. That works out at nearly three fireworks per second! This display was even more impressive than the Yokosuka New Year’s Eve fireworks display that I saw at the start of the year.

shibamata fireworks tokyo 4

Here are some of my photos from the event. I took about 200 photos using my cheap handheld camera. Many of the photos were blurry, but when you take that many, you are bound to get some good ones.

shibamata fireworks tokyo 2

The above firework explosion reminds me of those images that they get from particle accelerators when two atoms smash into each other.

The below sparks looks like stars in the night sky, but it is the final parts of a firework fading away.

shibamata fireworks tokyo 3

shibamata fireworks tokyo 5

They had some very intensely coloured fireworks. Here are blues and reds.

shibamata fireworks tokyo 6

shibamata fireworks tokyo 7

And a load of multi-coloured fireworks all exploding at the same time.

shibamata fireworks tokyo 8

A lot of people try to frame their fireworks photos so that they don’t get the spectators in the shot – but I like the look of the sillouettes they make against the bright lights. On the bottom right someone is taking a photo using their mobile phone.

shibamata fireworks tokyo 9

These fireworks left bright streaks across the sky.

shibamata fireworks tokyo 10

In these final two you can see someone speaking on the phone whilst the display takes place. Though with the noise of the music and the explosions I don’t know how any audible exchange could take place!

shibamata fireworks tokyo 12

shibamata fireworks tokyo 13

The display was completely free (if you didn’t want a designated seating position) and professionally organised so if you didn’t get to see it this year, I can recommend it for 2012.

How to find a Leopalace flat in Japan

July 13th, 2011

Leopalace is one of the largest flat/apartment rental companies in Japan. If you want a real self-contained home (rather than a room with shared facilities in a guest house) they are a good option to consider as they are happy to rent to foreigners, and have information and telephone help available in English. Usually the flats come pre-furnished (chairs, table, TV, fridge/freezer, microwave) so you can move in without having to buy too much.

I’ve lived in three Leopalace flats, two in Takamatsu and one in Tokyo and have had very few problems. Sometimes you can hear your neighbours, but fortunately most people in Japan are quite considerate about noise. When appliances or facilities have broken (e.g. air conditioning or hot water) Leopalace arranged for someone to come round and fix them for free.

They do have an English language website, which you should read to familiarise yourself with their different types of contracts and flats. Unfortunately there is no flat search facility on the English language website so if you want to find the best flats you need to learn how to use their Japanese language site. Much of this post will be tips for using the Japanese language site.

Leopalace contracts

There are three main types of contract at Leopalace.

  • Chintai – long term contract where you pay month by month. For many flats this means two years with an option to cancel the contract with no penalty after six months.
  • Monthly contract – you can sign from 30 days to 24 months and you pay in advance.

There are two types of monthly contract, the monthly plan (minimum 90 days) and the short term plan (minimum 30 days).

Leopalace costs

Leopalace’s prices are more simple and transparent than a lot of other Japanese rental companies, but that doesn’t mean they are simple to understand.

When renting with many private landlords you have to pay charges like key money (could be 2 month rent), and a deposit (which could be another few months rent). You don’t need to pay either of these for small Leopalace flats, but for larger ones you may need to pay a deposit.

I’ve rented on both the short term and the chintai contract so I can give you some examples of the costs.

Short term plan (30 day contract)

This was for a very small flat less than 30 minutes (walking and train) from Shibuya.

  • ¥115,200 – 30 days rent.
  • ¥28,000 – administration fee.
  • ¥9,970 – key change fee (this isn’t the same as key money, this is a fee for changing the locks).
  • ¥1,600 – Leo-net internet.

With the short term plan there are no utility bills to pay (they are included) or cleaning fees (that is included in the rent too). The total cost for 30 days was therefore ¥154,770 paid in cash before moving in.

Chintai (2 year contract)

This example is for the same flat. If you move from a monthly plan to a chintai contract in the same flat you don’t have to re-pay the key change fee, but I’m including the fee here to give an idea of the maximum total cost. Each months rent is ¥90,000 – cheaper than the ¥115,200 you pay if you rent for just 30 days.

First up, here are the initial moving in charges which need to be paid in advance.

  • ¥90,000 – first month’s rent.
  • ¥520 – first month’s environmental fee (some fee needed by the council – maybe to cover rubbish collection?).
  • ¥90,000 – second month’s rent – you need to pay the first two months rent in advance.
  • ¥520 – second month’s environmental fee.
  • ¥9,600 – Leonet for first 6 months.
  • ¥28,000 – Insurance/life support – This covers fire insurance, and the ‘life support’ service they provide if something breaks. It does not cover earthquake damage.
  • ¥72,410 – Guarantee fee – you don’t need guarantors with Leopalace if you are a foreigner, and you don’t need to pay key money or a deposit. You do however need to pay this fee, the purpose of which I’m still not clear about.

There are some optional fees like an ‘anti-bacterial cleaning fee’ which are optional, and in my opinion not worth paying.

That works out at a grand total of ¥285,200 to move in.

Here are the standard monthly fees after the first two months rent are used up.

  • ¥90,000 – monthly rent.
  • ¥520 – monthly environmental fee.
  • ¥500 – bank debit fee (for collecting rent out of your bank account).

And in order to move out there is a cleaning fee.

  • ¥29,920 – cleaning fee

This contract is for two years, but it can be ended after one year with no penalty. If it is ended before one year the extra charge is ¥85,500.

You need to be careful to factor in the initial and final costs into your calculation. In the case of this flat if I average all the costs over one year here is the breakdown for each month.

  • ¥90,000 – rent
  • ¥520 – environmental fee
  • ¥2,333 – insurance/life support
  • ¥6,034 – guarantee fee
  • ¥1,600 – Leonet
  • ¥2493 – cleaning fee
  • ¥500 – bank debit fee

So the average for each month if you stay a year is about ¥103,480. If you stayed for two years the cost would be lower as the one off costs would be split over two years instead of one.

On top of this you have to pay your utility bills (electricity, gas, water).

Finding a flat with the Leopalace Japanese website

If you’re still reading then let’s have a look at Leopalace’s Japanese website. Even if you can’t read any Japanese you can start to decode it using Google Translate or Google Chrome.

A useful tip is to print out key sections of the site, and as you decode them write on your print outs what the buttons / fields are for what. By doing this you can soon start to find good flats.

Leopalace main page

leopalace front page

  1. Search for chintai contract flats.
  2. Search for monthly contract flats (you usually get the same list of flats for chintai or monthly, these options just affect the price you see).
  3. Search by area.
  4. Search by train line.
  5. Keyword box – most useful for quickly looking up the flats once you have the reference number.
  6. Map of Japan. The number 6 is over the Kanto region which contains Tokyo.

So for our example select ‘monthly’ (2), choose the train line search tab (4), and press on the Kanto region (6).

Then select the Tokyo area (東京都). You’ll then get a screen with loads of train lines and the number of available properties in brackets.

Search by train line

leopalace train lines

There are two ways to figure out which train line is which. Either see if Google Translate/Chrome turns the train line names into something sensible, or type the name of the train line you want into Wikipedia, and on the Wikipedia page you are sure to find the Japanese version of the name. You can then locate it on the Leopalace site.

Let’s have a look for flats near the Yamanote line (山手線). It is the one in the red box. Then press the ok button (2).

You’ll now get a list of stations that have flats near them. I’ll select Tokyo and Ikebukuro stations (東京駅 & 池袋駅).

Narrowing down the search

leopalace flat results

  1. The left tab is for monthly contracts. The right hand one (in orange) is for short term plan rentals.
  2. Select how many months you want. The price is cheaper as the contract length increases. For the short term plan there are two pull downs here – one selects the rough number of days, e.g. 30-39, and the one below it selects the exact number of days.
  3. Minimum and maximum price.
  4. How soon you want to move in. e.g. in two weeks, in a month, in two months. The earliest date you can move in will be at least 8 days in the future. This is because Leopalace need time to arrange the flat cleaning, utility services, and maintenance.
  5. Type of flat. L=living room, D=dining room, K=kitchen. Most Leopalace places are 1K. Meaning there is a combined living/sleeping area and a small kitchen area.
  6. Many flats (particularly if they are not vacant) have discounted prices. The discounts can range from 10% to 50%. You can get some good deals if you aren’t too fussy.

leopalace flat results 2

  1. Floor area.
  2. Walking distance from nearest train station (note – do check which station it is near to – it is not always the one you picked).
  3. Building age.
  4. Floor plans and images.
  5. 2nd floor or above.
  6. Separate bathroom / toilet.
  7. Internet enabled (this could be any type of internet – so I recommend you make sure it has Leonet instead).
  8. Leonet enabled – the best kind of Leopalace internet, with a Lan socket in the flat. I have another post about setting up Wifi with Leonet.
  9. Parking.

Don’t be too fussy with any restrictions or you might end up with 0 results. You probably want to tick ‘Leonet’) and then maybe one other. The numbers in brackets tell you how many results you will be left with if you apply the exclusion.

To find out exactly where the flats are paste the Japanese address (I’ve hightlighted some of them in red so you can see where they are) into Google maps. If you use the Japanese address Google Maps usually gives an accurate location. If you use the romanised form of the address it might not even match the address to the correct region of the country.

Leopalace flat details page

If you click on the flat image you’ll go to the individual flat information page. Here are some of the important areas of the page.

leopalace flat details

  1. Building/flat number. If you want to find the same flat again, or rent it, then it is very useful to have the flat number. You can put the number into the search boxes to quickly access it. With this number ‘32357-201’, the first part ‘32357’ is the building number. ‘201’ is the flat number. Using their usual numbering convention you can tell that this flat is on the 2nd floor.
  2. Prices for the various lengths of contract.
  3. Walking time in minutes from a station. The address is below so you can check which station they mean.

leopalace flat details 2

Further down on the same page are:

  1. The date when the flat is available from. If it is currently vacant and this date is only about 8 days away you’ll find that it will creep forward each day.
  2. The floor that the flat is on (2) and the number of floors in the building (3).
  3. Price details of the other charges – insurance, cleaning etc. Google Translate/Chrome do a reasonable job of translating these.

leopalace flat details 3

Then near the bottom of the page you’ll see a box listing any other flats in the same building that are also available. This can be very useful if you really like a building, as it will give you more options in case one flat becomes booked. You can also see if any of the flats have good discounts.

Signing the contract

If you visit a Leopalace office to arrange a flat or sign a contract I’d recommend you take a Japanese speaker with you. They do have English speaking staff in some offices like the Shinjuku one, but they might not be able to understand more complicated questions.

Although you don’t need a guarantor, they will want some emergency contact details. They may want one contact from your own country, and two from Japan. So come prepared with three sets of phone numbers, names, and addresses.

You should also allow 2-3 hours to arrange everything and sign the contract. There is a lot of paper work that needs signing, and a lot of details that you have to fill in multiple times on different bits of paper. Here is the image of all the paper work that we were given after signing a chintai contract. In there is a contract, Leonet information, life support document, a Leopalace manual, receipt, and probably more.

leopalace chintai contract

Over to you…

This post is certainly not a comprehensive guide to using the Leopalace website, but with the tips I’ve given you, some time, and maybe with the use of Google Translate/Chrome you may be able to find a good rental flat in Japan.