All posts by mactips

Create very unique signatures in Preview

You can make signatures in Preview that are pen and ink style drawings.

I don’t know if this has been posted yet, or if it is generally known, but I stumbled upon a neat feature of signatures in Preview.app. When you create a signature, if you you don’t hold up a piece of paper with a signature on it, and simply smile for a mug shot, Preview will create a signature that is a neat pen and ink style image of yourself, or whatever is in front of the camera. I’ve created several, that for the right client, can be used as a humorous alternative to an actual signature. I also used a screen capture of the signature on a document and made the image into a Facebook Profile picture.

[crarko adds: Well I didn’t know about it. Most folks use Photo Booth to do things like this, I’d guess, but I always appreciate a creative use of a program.]

Source: Mac OSX Hints

    

Custom margins in TextEdit

There is already an old hint about this topic, but it doesn’t really explain it very clearly, only in the comments.

Here’s how you can change the margins in TextEdit to your favourite size, so that you can use, for example, the whole space on a sheet of paper when printing.

First, save your document first as a Rich Text file (.rtf), if you have not already done this. To see the effect directly in your document, open it and enable under the Format menu the setting Wrap to Page for your document.

Next open up the TextEdit preferences, switch to the tab Open and Save and check on the option Display RTF files as RTF code instead of formatted text.

Open the document again and you will see the raw code that defines how the document look like. You want to look in the 4th row, where it says:
margl1440margr1440

This define …

Source: Mac OSX Hints

    

Automatically create Calendar events when receiving email

By Matt Swain I’m always looking for ways to automate the most repetitive tasks I find myself doing on my Mac. The other day, I realised that I spend a lot of time manually creating Calendar events by copying information from booking confirmation emails. This is exactly the sort of task that can be easily automated to save you a little bit of time and effort every day.

Here’s how you can set up a custom rule in Mail app that runs a short AppleScript to create a new event in Calendar app.

To illustrate how to do this, I’m going to use an example that I’ve set up for myself. I regularly receive booking confirmation emails from my local cinema that look like this:

All the information to create a Calendar event is there in the text, but it is annoyingly time consuming to do this manually. Let’s set up a Rule to process these emails automatically.

In Mail app, choose Preferences from the Mail menu, and click on the Rules tab. Create a new rule, and adjust the drop down menus to look like the screenshot below. The first section shows the conditions required to apply the rule to a message. In my case, I restrict the rule to only messages from “noreply@cineworldmail.com” in my “iCloud” account. When an email that meets these criteria is received, a series of actions are performed. First the message is moved out of my inbox into another mailbox, and it is marked as read.

The final action is the most complicated. It is a custom AppleScript that reads the email, figures out the name, date, time and location, then creates a Calendar event.

When you first choose Run AppleScript from the drop down menu, there will not be any AppleScripts available for you to run. First we have to create one.

To do this, open up AppleScript Editor. This is located in the Utilities folder in the Applications folder, or you can find it using Spotlight search or Launchpad. In the script window that appears, paste the following script:

— Triggered by Mail rule.
using terms from application “Mail”
on perform mail action with messages msgs for rule theRule
tell application “Mail”
repeat with msg in msgs
try
set msgcontent to content of msg
set msgid to message id of msg
set {movie, runtime, cert, bref, starttime, addr, screen} to my parseMsg(msgcontent)
my createEvent(movie, runtime, cert, bref, starttime, addr, screen, msgid)
end try
end repeat
end tell
end perform mail action with messages
end using terms from

This is the general format of all Mail rule AppleScripts. One of the benefits of AppleScript is that it is very close to normal English language, and you can get some idea of what a script does even if you aren’t familiar with AppleScript. The above script takes each email message that the rule matched, and runs a function called parseMsg on it to extract the event details. Then it runs a function called createEvent using those details.

Next, below this paste the following functions:

— Parse the email content to extract movie details.
on parseMsg(msgcontent)
set movie to extractBetween(msgcontent, “You are going to see: “, “Cert: “)
set cert to extractBetween(msgcontent, “Cert: “, “Running Time: “)
set runtime to extractBetween(msgcontent, “Running Time: “, ” minutes”)
set bref to extractBetween(msgcontent, “Booking Reference: “, “Date: “)
set datestring to extractBetween(msgcontent, “Date: “, “Cinema: “)
set addr to extractBetween(msgcontent, “Cinema: “, “Screen: “)
set screen to extractBetween(msgcontent, “Screen: “, “Number of people going: “)
set starttime to parseDateString(datestring)
return {movie, runtime, cert, bref, starttime, addr, screen}
end parseMsg

— Extract the substring from between two strings
to extractBetween(theString, startText, endText)
set tid to AppleScript’s text item delimiters
set AppleScript’s text item delimiters to startText
set startComps to text items of theString
set AppleScript’s text item delimiters to endText
set endComps to text items of second item of startComps
set AppleScript’s text item delimiters to tid
return trim(first item of endComps)
end extractBetween

— Trim all whitespace from start and end of a string
on trim(theString)
set theChars to {” “, tab, character id 10, return, character id 0, character id 8232}
repeat until first character of theString is not in theChars
set theString to text 2 thru -1 of theString
end repeat
repeat until last character of theString is not in theChars
set theString to text 1 thru -2 of theString
end repeat
return theString
end trim

— Parse date and time from the string given in the email.
on parseDateString(datestring)
set theDate to current date
set dateWords to words of datestring
set day of theDate to text 1 thru -3 of item 2 of dateWords
set time of theDate to (item 5 of dateWords) * hours + (item 6 of dateWords) * minutes
set monthList to {January, February, March, April, May, June, July, August, September, October, November, December}
repeat with i from 1 to 12
if item 3 of dateWords = ((item i of monthList) as string) then
set monthNumber to (text -2 thru -1 of (“0” & i))
exit repeat
end if
end repeat
set month of theDate to monthNumber
return theDate
end parseDateString

This is the core of the AppleScript, which parses the email to extract the event details. The way it works is to extract the text between two other pieces of text. For example, it extracts the text between You are going to see: and Cert: and sets it as the name of the movie. You will need to modify this to match the exact format of your email. A bit of trial and error may be necessary, so you may want to test the rule on emails you send to yourself.

Finally, paste the following function that creates the Calendar event:

— Create a calendar event for the specified movie.
on createEvent(movie, runtime, cert, bref, starttime, addr, screen, msgid)
set endtime to starttime + runtime * minutes
tell application “Calendar” to tell calendar “Home”
set theEvent to make new event with properties {start date:starttime, end date:endtime, summary:”Cinema: ” & movie}
set location of theEvent to screen & “, Cineword ” & addr
set description of theEvent to “Booking Reference: ” & bref & return & “Run Time: ” & runtime & ” minutes” & return & “Certificate: ” & cert
set url of theEvent to “message://” & “%3c” & msgid & “%3e”
end tell
end createEvent

You will also need to modify this to match the exact details in your email messages. Above, I set the name of the even to the title of the movie and I calculate the end time by adding the running time of the movie to the start time. I set the location of the event to the screen number and the cinema address, and I add a few details to the event notes like my booking reference number. Setting the url of the event to the email message id also provides a handy link back to the original email message from within Calendar.

You can find the full script here.

Now all we need to do is save the AppleScript somewhere Mail can see it. Choose Save from the File menu, and then press Command-Shift-G to bring up the Go to folder dialog. In the text field, type ~/Library/Application Scripts/com.apple.mail and press Return. Give the script a memorable name and save it. Now, when you return to Mail, your script should be available in the drop down menu next to “Run AppleScript”.

Source: Mac OSX Tips

    

Low-power mode for Maps.app

It’s possible to save power when using Maps to navigate in a car. It’s an obvious trick once you know about it, and easy too.

When you’re navigating with the Maps app, you’re probably used to it chewing through battery life. Even on a full charge my iPhone 5 doesn’t last more than 2-3 hours when navigating.

To eke out extra life, just press the Sleep button (top of the phone), once you’re on your way and are on a long stretch before the next turn/navigation point (i.e. on a freeway for 50 miles). The screen will blank, but the navigation will continue. The phone will briefly wake 10 miles from your next turn/navigation point, to tell you about it, and will wake 2 miles from it and stay awake until you get past it.

To switch back to non-power-saving mode, just swipe as usual to wake the phone.

To be honest this doesn’t save a huge amount of battery life in my tests, but it’s better than nothing. For long journeys,you really need a USB power sour …

Source: Mac OSX Hints

    

Hiding Software Updates

Since the introduction of Lion the system’s Software Opdate mechanism has been integrated into App Store.app and the Software Update Preference Pane has been removed and substituted with “App Store”.

If you constantly are being reminded to install software updates you don’t really want to install, you can right-click (Control+click) the name of the update and hide it, eliminating the reminder.

[crarko adds: I think this is probably known already to many of you, but if it’s not it can be a handy trick. I find the whole App Store method for Software Update a lot less pleasant than the old Snow Leopard mechanism where it was separate, but maybe I’m just old fashioned.]

Source: Mac OSX Hints

    

iOS: Change how Calendar events look in Notifications

Long frustrated with how calendar events look within the Notification Center I’ve discovered a way to change it.

As part of iOS 7.1 Apple improved on the ability to view calendar events by adding a list view button in the Daily view. I have noticed that if you toggle this to list view within the Calendar app then your calendar events within Notification Center will also show as a list.

[crarko adds: Is this actually new? I don’t remember having looked for this in previous versions of iOS.]

Source: Mac OSX Hints

    

10.9: Enable experimental network commands

Many advanced network configuration commands can be reached with the scutil command line tool. Launch Terminal.app and run:
ENABLE_EXPERIMENTAL_SCUTIL_COMMANDS=1 scutil –net, then type help and press the Return key to see the available options.

For example:

localhost:~ user$ ENABLE_EXPERIMENTAL_SCUTIL_COMMANDS=1 scutil –net
set “Automatic” selected
> help

Available commands:

help : list available commands
f.read file : process commands from file
quit [!] : quit

commit : commit any changes
apply : apply any changes

create interface [ | ]
create protocol
create ser …

Source: Mac OSX Hints

    

Paste an address and Contacts will parse it

I’m not sure how long this has been the case, but if you copy an address, say from a web site, and paste it into the first address field (street) in Contacts, Contacts will parse appropriately.

For example, try:

1234 Easy St
Pleasantville, CA 43402

When pasted into Contacts it will correctly place the City, State and Zip into the appropriate fields.

[crarko adds: OK, I’ll admit I don’t know when this was introduced either because I’d long ago stopped looking for it. Nice to know data detectors keeps being improved.]

Source: Mac OSX Hints

    

10.9: Run sysdiagnose with keyboard shortcut

The command-line utility sysdiagnose can be triggered by pressing Cmd+Opt+Ctrl+Shift+Period, and it may take a few minutes to complete. When ready, the output will automatically be revealed in a Finder window (or it can be manually retrieved from /var/tmp).

What sysdiagnose Collects:
A spindump of the system
Several seconds of fs_usage ouput
Several seconds of top output
Data about kernel zones
Status of loaded kernel extensions
Resident memory usage of user processes
All system logs, kernel logs, opendirectory log, windowserver log, and log of power management events
A System Profiler report
All spin and crash reports
Disk usage information
I/O Kit registry information
Network status
If a specific process is supplied as an argument: list of malloc-allocated buffers in the process’s heap is collected

Source: Mac OSX Hints

    

10.9: Add an Automator action to Calendar

Apple removed the option to add an action to Maverick’s Calendar app but you can use Automator to accomplish this.

I found that if you use Automator to add an action an Automator calendar will appear over in the Calendar side bar. Then just select the Automator calendar for the item you are adding.

[crarko adds: I had to play around a bit in Automator to figure out what to do here, but it looks like creating a Calendar Alarm action will do the trick.]

Source: Mac OSX Hints