"There’s nothing in the middle of
the road but yellow stripes and dead armadillos."
Jim Hightower

Sunday 22 October 2017

Saving PDFs from Apple Mail

I should have remembered how easy Apple makes things rather than starting off on a more complicated path.

I have a number of email invoices from an online shop that I want to store locally. I know that Spotlight indexes the email and I should be able to easily find these invoices going forward, but wanted to group the invoices with some other files - scanned receipts and documents.

I had been able to use the Mail option 'File | Save as a PDF' on each message, but there were 100 or so messages and I thought this would be tedious and spent a day investigating Automator and Applescript.

Long-story short, I had assumed (... breaking rule #1) that Mail would aggregate all the message if I tried to save more than one. It doesn't - just saves out each file as a PDF in turn.

So the easy solution is to save the file to a folder and then get Hazel to rename, tag and sort the files from there.

Saturday 31 August 2013

Using Applescript in an Apple Mail rule

Just spent a few hours trying to figure out how to correctly fire a script from a Mail rule.

I was originally using this syntax from here as it seemed to be posted most places and used the handler construction that is similar to the one used by Hazel, but couldn't get the script to work.

on perform_mail_action(theData)
   tell application "Mail"
      set theSelectedMessages to |SelectedMessages| of theData
      set theRule to |Rule| of theData
      repeat with a from 1 to count theSelectedMessages
         — Process the current message
      end repeat
   end tell
end perform_mail_action

I eventually found this page with the following syntax that works perfectly - I should have known that Apple would provide an example script!

For reference "/Library/Scripts/Mail Scripts/Rule Actions/Sample Rule Action Script.scpt." is repeated here:

(*
Sample Rule Action Script
Copyright © 2003–2013 Apple Inc. All rights reserved.
You may incorporate this Apple sample code into your program(s) without
restriction.  This Apple sample code has been provided "AS IS" and the
responsibility for its operation is yours.  You are not permitted to
redistribute this Apple sample code as "Apple sample code" after having
made changes.  If you're going to redistribute the code, we require that
you make it clear that the code was descended from Apple sample code,
but that you've made changes.
*)
(*
This script is an example of how to write an AppleScript that can be
attached as a rule action. See Mail Help for details and Mail's 
AppleScript dictionary for the full terminology for the 'perform mail
action with messages' handler.
If you attach this script to a rule action, and the rule
matches an incoming message, a dialog box will display, showing
the name of the rule that matched and the subject of the message
that matched. One dialog per matched message will appear.
This is also an example of how you can write scripts that appear in the
Scripts menu and can pass in parameters for the selected messages and/or
mailboxes in Mail's main viewer window.
*)
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
set theText to "This AppleScript is intended to be used as an AppleScript rule action, but is also an example of how to write scripts that act on a selection of messages or mailboxes." & return & return & "To view this script, hold down the option key and select it again from the Scripts menu."
repeat with eachMessage in theMessages
set theSubject to subject of eachMessage
try
-- If this is not being executed as a rule action,
-- getting the name of theRule variable will fail.
set theRuleName to name of theRule
set theText to "The rule named '" & theRuleName & "' matched this message:"
set theText to theText & return & return & "Subject: " & theSubject
display dialog theText
set theText to ""
end try
end repeat
if theText is not equal to "" then
display dialog theText buttons {"OK"} default button 1
end if
end tell
end perform mail action with messages
end using terms from

Wednesday 25 January 2012

Cross Country Trains: e-Tickets

I have just found out how ridiculous the e-Ticket and collection policy is for Cross Country trains.

I need to pre-pay for my daughter and her friend to travel back from school to her mother's home at the weekend. I will not be travelling with them as school is 100 miles south and my ex-wife lives an hour's drive away. They are 17, but do not have a credit card.

I can enter their details - Name & Railcard Number, when booking the ticket and I can email them the e-Tickets from my (valid) email address for them to print and take with them.

However, the tickets are not valid without my credit card.... This isn't clear in the payment system (see below) and is only made definite _when_ you receive the email after you're paid for the ticket...

25-01-2012 22-09-27

It is completely reasonable that they (a) have their rail cards to justify the reduced cost and (b) - perhaps, some other form of ID (though the Rail Card should cover both aspects) but not that my credit card has to travel with them!

I was told by customer service, when I called them as soon as I received the email notification, that as the advance tickets are non-refundable and non-transferrable; I have to write off the cost of the tickets or give my credit card to my daughter and friend when they travel. To do this, I would have to pay for two Special Delivery postages and be without my credit card for a week.

I have registered a complaint and am interested to hear their justification for the requirements.

Tuesday 24 January 2012

Transferring Photos From An iPhone To Your Mac Wirelessly

I had some pictures on my iPhone that I wanted to copy to my work laptop, but had to get them on my MacBook to start with.

Plan A was to wirelessly sync my iPhone with the Mac and then email the files to my work account.

However, the Camera Roll on the iPhone is not synchronised with the Mac or iPhoto by default. You can use Photo Stream, but that locks the pictures in and doesn't allow you to delete the images easily.

There are several apps on the App Store that allow you to sync with DropBox, but it seems that the DropBox application does it natively for you, so I save my £1.99 and did it the free way!

Friday 13 January 2012

How beautiful is this?

Saw this article today on how they’d created a garment from the silk of the Golden Orb spider. The colour is amazing.

Image from Wikipedia

Wednesday 30 November 2011

Moshi Monsters and Apple's Parental Controls

I have a 8 year old that wants to access the Moshi Monsters site using Safari from a desktop locked down with parental controls on an OS X Lion Server.

Moshi Monsters seems to be predominantly a Flash based site that causes the parental controls software some problems. Several other people have found the same problem.

When we first tried to access the site, it was properly blocked and asked for permission. Once it had been added to the list of allowed sites, I thought it would all work.

However, once you log in to your pet, it gets locked at the "Loading" screen, but there isn't any further warning from the parental controls software.

If you look at the source code for the page, it is trying to load information from c.mmcdn.net and I wondered if this was causing the site to be blocked.

I thought if I added this as a bookmark, then the page would load correctly, but it didn't... After a bit of head scratching, I ran nslookup for 'c.mmcdn.net' from a Terminal window and it returned the following alias entries:

> c.mmcdn.net
Server: 127.0.0.1
Address: 127.0.0.1#53
Non-authoritative answer:
c.mmcdn.net canonical name = c.mindcandy.cotcdb.net.
c.mindcandy.cotcdb.net canonical name = orig-10005.mindcandy.cotcdn.net.
Name: orig-10005.mindcandy.cotcdn.net
Address: 94.127.74.140
Once I added 'c.mindcandy.cotcdb.net' and 'orig-10005.mindcandy.cotcdn.net' to the list of bookmarks, the page loaded correctly.

I doubt this is a permanent fix as the Moshi Monster site may change its hosts, but at least it is a temporary work-around!

Monday 26 September 2011

How do you know a rear brake light bulb has failed on a Land Rover Discovery 3…?

Simple, the car tells you.

The dashboard says:

  • Parking brake fault
  • HDC fault – Module not found
  • Transmission fault

And the car very helpfully drops the car on to the lowest suspension setting (i.e. the bump stops). This can be especially useful when you’re many miles from home. Mind you, someone will probably point out that it doesn’t make that _much_ difference to the ride quality.

My experience with BMW and Mercedes was that they simply told you that you had a bulb failure.

Interestingly, the Service Desk at the dealer (Guy Salmon in Coventry) didn’t recognise the faults as indicating a bulb failure either and referred me to Land Rover Assistance, as the earliest time they could help was the middle of the next week.Guy Salmon didn’t seem hugely concerned that I had a car that I couldn’t drive.

It must be a regular fault, as the ever cheerful Chris (from LR Assistance) had a very good look at the rear light bulbs when he showed up – 3 hours later. A visual check - with me pressing the brake pedal, confirmed his suspicions very shortly.

The whole experience did get quite close to farcical when Chris didn’t have any replacement bulbs with him and had to drive me to Halfords (for me) to buy a replacement set.

An amusing note was that during the conversation on the way to Halfords, Chris and I agreed that it was pretty poor design where a bulb failure takes out the whole car. When I asked if it was also an issue with the Discovery 4, the response was “… well, they’re fitted with LEDs now and they shouldn’t fail”, which neatly provided an illustration of the difference between an Incident and a Problem.

As an ex-Mechanical Engineer, I am dismayed that this wasn’t picked up during basic FMEA. Perhaps Land Rover have not come that far from British Leyland and 1987 where a sister company had passed a design where one fuse protected the headlights and the headlight washers…

So, for example, if the headlight washer motor had frozen up early on a cold, dark winter’s morning as you were happily motoring along the M1 with 3 lanes of solid traffic in your posh new Jaguar XJ40 and you were thinking “… my lights are looking a little dim, I’ll clean them up with my very clever headlight washer…”, you’d find out that the motor was frozen solid when all the headlights went out completely.

Funny how the engineers didn’t spot that in thousands of miles of Artic testing.