AppleScript Move Mail Message

August 8, 2011

I upgraded to OS X Lion and the AppleScript I was using to move a selected mail message to another mailbox broke. Here is the offending script:

tell application "Mail"
 move selection to mailbox "@action"
end tell

It looks simple enough, so I don’t understand exactly why it stopped working. I searched around and found something to try in the Mac OS X Hints section of Macworld.

I modified the script a little bit and came up with this:

tell application "Mail"
    set _msgs to selection
    set _mailbox to "@action"
    repeat with _msg in _msgs
        tell application "Mail"
            move the _msg to mailbox _mailbox
        end tell
    end repeat
end tell

I made two more like this one for my @reply and @waiting mailboxes. These all get processed with a keyboard shortcut via FastScripts.

Comments

Pretty Permalink and No Comment

June 4, 2011

I made two changes to this here website. I changed the permalink structure and removed the DISQUS comments platform.

What happened is this. Gruber linked to this article article about hashbangs which led me to this Cool URIs article by Tim Berners-Lee. That influenced me enough to change my permalink structure. The default permalink structure for Jekyll is /:year/:month/:day/:title.html. That means for this post, the URI would be http://kevrodg.net/2011/06/04/pretty-permalink-and-no-comment.html. After reading the Berners-Lee article, I decided I want the permalink structure to be :year/:month/:day/:title. As it turns out, Jekyll has this style built-in. It’s called pretty. Now, the URI for this post is http://kevrodg.net/2011/06/04/pretty-permalink-and-no-comment/. I guess this will help future-proof the permalink. Something else which would help is for me to stop messing around with the site’s structure.

As for the DISQUS comments, I decided that I don’t want any comments on my site. To date, there were no comments made on any of my posts, so it’s not like I had a bad experience with them. I have a few reasons why I don’t want comments, but the main one is that this is my site, and I intend it to be all mine. It will have my thoughts and opinions, and I want to control everything that appears here. I don’t hate sites that have comments. I actually enjoy reading an article and then seeing what other people have to add to it. I just don’t want it for my site. Anyway, that’s how I feel about it now.

No Tracking Here

February 6, 2011

I’m on a bit of a privacy kick lately and I’ve decided to remove the tracking components from my site. I was at one point using Google Analytics, but dropped that in favor of Sean Inman’s Mint. I have since removed Mint from my site. A nice side benefit from this is that I was able to switch my site’s server type back to static. It’s cheaper that way.

It was fun for a while to see how the few people who were coming to my site got here, but I don’t really care to know. I think it will help me to write more for myself as well, as I won’t be influenced by the more popular posts. And on top of that, there will be one less thing for me to obsess over.

However, if I enable comments on a post, I’ll still get a sense of which ones are more popular. That’s assuming that anyone chooses to add a comment. I don’t see this as a privacy violation though, because the commenter is willingly submitting information, whereas with tracking scripts, the visitor may not know information about them is being recorded.

A Breakdown of Sweet Mac Setups

December 31, 2010

Shawn Blanc runs a series on his website that showcases Sweet Mac Setups. It’s for people who “wish to geek out over workspaces, software, and hardware.” People like me. My setup was profiled in June of 2009.

I wanted to find out what are the most popular ways to setup a Sweet Mac Setup and I went through all of them to gather some figures. I chose to capture data only for the setups that used a laptop connected to an external display. Why? Because that’s how I have mine setup. By my count, there are 18 such setups in the series.

There are three things of which I was interested: clamshell mode, keyboard location, and laptop stand. For clamshell mode, I wanted to know if the lid is open or closed, and what is the location of the laptop relative to the external display. For keyboard location, I wanted to know if the keyboard is sat atop the desk or on a keyboard tray. Finally, I wanted to know if a laptop stand is used. The following are the details of my research:

Clamshell Mode
Open on the left 12
Open on the right 4
Closed on the left 1
Closed on the right 1
Keyboard Location
Keyboard on Desk 15
Keyboard on Tray 3
Laptop Stand
Stand 13
No Stand 5

The most popular Sweet Mac Setup is clamshell mode open on the left of the external display, keyboard on the desk, and a laptop stand. However, the correct setup (mine) is clamshell mode open on the right, keyboard on a tray, and a laptop stand. I must mention that this is my current home setup. At work, the correct setup is clamshell closed on the right, keyboard on the desk, and no laptop stand.

What’s in Your Simplenote?

August 26, 2010

Minimal Mac

With the new release of Simplenote, I thought it might be fun to list just a few of the notes I have in mine with the hopes that others will share theirs as well.

Sound fun?

Yes, here is a sample of what is in my Simplenote:

  • A list of Pale Ales I want to try.
  • A list of books I want to read.
  • A short guide about my intended dress style for work, swiped from Put This On.
  • A snippet of the Quinoa recipe from Salt & Fat.
  • Miscellaneous technical notes, e.g., the steps needed to configure a Cisco 7925G WiFi phone out of the box and on to the network.

Safari Extensions Obviate NNW

June 10, 2010

Two Safari extensions have obviated my need for NetNewsWire: greader-bgtabs and Google Reader Styles.

My flow for reading articles when I’m on the desktop is like this. I open NetNewsWire and use keyboard shortcuts to open all the new articles in Safari in the background. Then, I go to Safari and read the articles.

Some people are happy simply reading the articles inside NetNewsWire, either in the integrated browser or in the stylized view pane. That’s cool. And, if that’s how you like it, then NNW will work well for you. Since I’m only using NNW as a launcher, it’s superfluous to have it running all the time.

My issues with the Google Reader website are, 1) it looks pants, and 2) when you press ‘v’ to open items, they open in the foreground. The two extensions I’m using alleviate both issues. Now, the Google Reader website looks good and pages open in background tabs.

I’m all for only using those applications that you really need. And, until recently, NNW was the best option for a good feed reading workflow.

Link List Post with Jekyll and Applescript

March 13, 2010

In the previous post, I mentioned that I hacked together a somewhat automated process to create a linked list style post. The following AppleScript is what I came up with:

on displayErrorMessage(s)
    display dialog (s) buttons {"OK"} default button "OK" with icon caution
end displayErrorMessage

tell application "Safari"
    try
        set pageURL to URL of document 1
        set pageTitle to name of document 1
        set selectedText to do JavaScript "getSelection();" in document 1
    on error errorMessage
        displayErrorMessage("Can’t create a new post because of an error getting information from Safari.") of me
        return
    end try
end tell

property LF : ASCII character 10

set modTitle to text returned of (display dialog "Modify the title:" with title "Modify Title" default answer pageTitle buttons {"OK"} default button 1)

tell application "System Events"
    set the clipboard to "[" & pageTitle & "]" & "(" & pageURL & ")" & LF & LF & ">" & selectedText & LF & LF
end tell

do shell script "ruby ~/bin/newlink.rb " & quoted form of modTitle

Here is a breakdown of how the script works.

on displayErrorMessage(s)
    display dialog (s) buttons {"OK"} default button "OK" with icon caution
end displayErrorMessage

tell application "Safari"
    try
        set pageURL to URL of document 1
        set pageTitle to name of document 1
        set selectedText to do JavaScript "getSelection();" in document 1
    on error errorMessage
        displayErrorMessage("Can’t create a new post because of an error getting information from Safari.") of me
        return
    end try
end tell

This first section, which I copied from the New Post from Safari script included with MarsEdit, grabs the URL, Title, and selected text from Safari and assigns them to the indicated variables. This is the essential part of the process, and if this was all the script did, it would be a big timesaver. But, I wanted to see if I could get more out of it.

set modTitle to text returned of (display dialog "Modify the title:" with title "Modify Title" default answer pageTitle buttons {"OK"} default button 1)

This bit of code will open a dialog box asking to modify the page title. Some page titles are lengthy, and this bit allow me to shorten it up to what I want.

tell application "System Events"
    set the clipboard to "[" & pageTitle & "]" & "(" & pageURL & ")" & LF & LF & ">" & selectedText & LF & LF
end tell

This part copies a Markdown formatted link to the clipboard. It includes an href to the article as well as a blockquote of the selected text.

Now that I’ve got what I want to include in the link list in the clipboard, the next step is to create a new post in the Jekyll system I have setup. Thanks to this bit of Ruby code, compliments of Alex Payne, a shell script call to the Ruby program will create the file with the necessary markup.

do shell script "ruby ~/bin/newlink.rb " & quoted form of modTitle

The next step is to paste in the clipboard data and type any other comments I have.

It may seem like a lot of effort, but it only takes a few seconds to generate the link list item. I’m sure there is a more efficient way to do this, and I’m looking forward to figuring one out.