Saturday, December 20, 2014

How does flying affect my CO2 emmissions

Using very rounded numbers for simplicity and a not very scientific approach, it does still make you think.
In 2000 the world's greenhouse emissions were 34 billion tons of CO2-equlivalent per year and the approximate population of the world is 6 billion.
So roughly we can say that the average emissions per person is 5 or 6 tons of CO2-equivalent per year.

Average person's emissions = 6 tons

A typical round-trip intercontinental flight (whatever that is) emits about 2 tons of CO2 per passenger.

Average round trip = 2 tons
So one trip per year is something like a third of the average person's carbon emissions.

Please read the excellent (and free) book Sustainable Energy without the hot air from David JC Mackay 2009

Saturday, December 13, 2014

Powershell help - The three most important commands in the Windows PowerShell

Just starting out with the Windows PowerShell and I think the most important command are:

  • Get-help - first line support, what do I do?
  • Get-command - found the command, How do I use it?
  • Get-member - What does this do? List it's members.


It accepts wildcards and is not case-sesitive.
get-help *service* 
will list all topics that have object in the topic.

You can find more info about the topic by asking for help on the name of the specific.
get-help start-service
This help text is very useful but there's even more.

The full help can be found by using the verbose parameter, full
get-help start-service -full


get-command -noun service 
This will list all the commands with the word service in the name.

You can also look for a verb, e.g.
get-command -verb get


To use this we need to use the pipeline command which is:
Basically, without explaining pipelining, the output from the first command is filtered into the second.

So. I have found that the command I am interested in is get-service.
I want to find the members of that service. So I pipe the command into the get-member command.
get-service | get-member
 Running the above we find the Properties and Methods for the command get-service

And one other thing:


If you're unsure what a command will do, then add the -whatif parameter and let PowerShell tell you what will happen.

stop-process -name * -whatif 

Sunday, November 2, 2014

Use iBooks to read Kindle books on a Mac

Amazon has a lot more computer books than the iBook store so I've ended up with quite a few in Kindle over the years. I don't have a Kindle device, just the app for the Mac.
I don't like it. I never have liked it. It just irritates me. For a long time we had to use it because Apple in their infinite wisdom thought iBooks should only exist on the iOS devices but that changed a couple of years back so why am I not reading my Kindle books in iBooks?
Answer Digital Rights Management - DRM. The things that prevents copying even if you're coping it for yourself.

But there's a way around it.

1. Install Calibre

This is an open source e-book management thing. It has the power to export e-books to other formats but it won't cope with DRM. We need to get rid of the DRM.

We need to add a free and open source plugin to Calibre but we install it in a slightly different way. For me it worked very easily and quickly.

2. Go to Apprentice Alf's page to download the tool. You'll need the Tools not the Alternative tools.

To download, be sure to press the Grey button and un-tick the tick box.

3. Ok now unzip the file somewhere.

4. Start Calibre.

5. Add the plug in.

  1. Select Preferences from the menu-bar.
  2. Select Change Calibre behaviour from the dropdown.
  3. Choose Plugins from the panel.
  4. Select the button: Load plug-in from file.
  5. Navigate the the unzipped files you downloaded.
  6. Open the DeDRM_calibre_plugin.
  7. Select the file.
  8. Choose Add etc and that's it.
No Add books into Calibre and will be DRM free. You can export to Epub and then add to your iBooks library.

The plugin is made by Apprentice Alf I think and there are all sorts of posts on the blog about this

Sunday, October 19, 2014

Where is the fullscreen button in Yosemite? The Mac fullscreen button has gone.

Another one of the minor tweak improvements from the Yosemite release is to have one single button function for enlarging the page. They have moved the full-screen button to the green button - the old LED button on the top left. Good thinking.

Saturday, October 18, 2014

How to use special character in a Mac like umlaut, acute, tilde and circumflex

The Grave characters: À È Ì Ò Ù à è ì ò ù

Press the following two keys:  option ` and then the character we want.

The Acute characters: Á É Í Ó Ú á é í ó ú

Press the following two keys: option e and then the character we want.

The Circumflex: Â Ê Î Ô Û â ê î ô û

Press the following two keys: option i and then the character we want.

The Tilde: Ã Ñ Õ ã ñ õ

Press the following two keys: option n and then the character we need.

The Umlaut: Ä Ë Ï Ö Ü Ÿ ä ë ï ö ü ÿ

Press the following two keys: option u , and then the character we need.

Friday, September 5, 2014

How to use Interupts in the Raspberry Pi

Just found this.
Now we can do hardware interrupts with the raspberry Pi. A world better than polling.

How to connect Raspberry Pi to Mac using ethernet cable

Just a note because I did this once, then tried again and could quite remember it.

The default IP address of the Pi is

The default IP address of a home network is in the range: 192.168.0.nnn.

Open the Network preferences and set the IP address, subnet mask and DNS server as shown below.

The Airport WiFi is unchanged on my range and the Pi can share the internet via the Mac.

I have done this on Snow Leopard and Maverick. All good. The same should work on Windows I should imagine.

Use Ping in a terminal console window to check the network connection.


Monday, August 25, 2014

Raspberry Pi - header pins and BCM pins

This image is taken from Meltwaters Raspberry PI Hardware.

import Rpi.GPIO as GPIO

#Set the GPIO to use the BCM device numbering

#Set the GPIO to use the Rasperry Pi board header numbering.

BCM spec

The spec for the BCM2835 can be found here.

Sunday, June 22, 2014

What is the End of line key in OSX

This has been bugging me for years. What is annoying is that I have not bothered to find the keyboard shortcut for this. How can I be so pathetic.

At work for years it's been Windows and their low-tech, low quality plastic keyboards that are easy to be snobbish about and look down on. But there are two things straight away that I miss when on my Mac keyboard: the 'go to the end of the line' key, and the '#' (I'm using a UK keyboard so I'm not sure if the key is visible on other culture keyboards). I've known the '#' for a long time but not the other.

  • # - Option and 3 together
  • end of line - cmd and right arrow
  • start of line - cmd and left arrow
  • next word - option and right arrow
  • start of page - cmd and up arrow
  • bottom of page - cmd and down arrow
Ok, so here's other ones for text selection:
  • Select text to start of line - put SHIFT with the above line selection (SHIFT + CMD + LEFT ARROW)
  • Select text to end of line - as above but with right arrow.
Try up arrow and down arrow too. They work as expected.

ha! Finally got my act together. I've been using it all day.

Saturday, May 24, 2014

Removing duplicates in a javascript array

I was looking at this today and discovered grep.

$(function () {

    var myOriginalValues = [1, 3, 7, 3, 3, 9, 2];
    var res = [];

    $.each(myOriginalValues, function (i, el) {
        if ($.inArray(el, res) === -1) res.push(el);

    // Now a grep version
    var grepVersion = function(arr){
        return $.grep(arr,function(v,k){
            return $.inArray(v, arr) === k;

    var arr = ['tree',2,4,5,4,1,1,3,3,5, 'tree', 'hat']
    var x = grepVersion(arr);


Javascript This keyword

This is a variable that is available when you use functions, and depending on how the function was invoked This can be different things.

// This - will be global scope
function myFunction() {
    console.log('This is a lot of stuff:');

// This - will be the myThing object
var myThing = { name: 'john', age: 21};
myThing.doStuff = function(){

// This function outputs:
// { name: 'john', age: 21, doStuff: [Function] }
// john

(function doTheFunctions(){