stockprice.sh

I was looking for an excuse to play with spark, and cooked up a little shell script that pulls historical stock data. It's still a little rough, but it's got some basic validation, and it's good enough for me to use it for the time being.

I might improve on it here and there, but you should feel free to mess around. I'm sure there are others that provide this functionality and much more, but I wanted to write it myself from soup to nuts.

Markdown to MindMap v1.0

Brett Terpstra created something I've been thinking about making for a while (and I'm 100% positive he did a better job that I would have): a service that takes plain text lists and formats them as OPML to paste into mind mapping software. It sounds like he cooks ideas in approximately the same way I do.

Re-Enabling Folder Actions in Mountain Lion

I'm not a big Folder Actions user; a lot stuff that Folder Actions is designed for, I accomplish with some shell scripting & cron jobs, or Hazel.

I was surpriesd to find that when I tried to set up a new Folder Action in 10.8.2, it wasn't available; "Folder Actions Setup…" wasn't an option in the "Services" menu for any folder. Apparently, it's a pretty common problem for Mountain Lion users. Here's how I fixed it.

  1. Create ~/Library/Scripts/Folder Action Scripts/ & drop the folder action script you want to add in there.
  2. Strangely, open System Preferences → Keyboard → Keyboard Shortcuts, and click the "Reset to Defaults" button.
  3. Scroll up to the "Files & Folders" section, and make sure that the "Folder Actions Setup…" listing is checked.

My guess is that if you were like me and had some custom keyboard shortcuts when you upgraded from 10.7.x to 10.8, it borked up the Keyboard Shortcuts upgrade, which in turn borked up the Services menu. Dumb.

Source: topsites://

Concentrate

You know what's awesome? The Internet. There's so much cool stuff to learn and there's funny dog pictures, and there's schadenfreude. Sometimes it's just too much to bear.

A couple years ago, my Reddit addition was getting pretty bad, and I needed a break. I used an old and simple trick where I modified my /etc/hosts file to point reddit.com to 127.0.0.1, and stuck a simple webpage on my localhost that read, simply, "Get Back to Work" in big bold black letters on a light grey background. Since Reddit was effectively replaced with that page, I didn't go back to Reddit for more than a year. Lately, I've been back a bit, but when I feel the urge getting too strong and, I've been using a helper to keep me on-task.

Concentrate is a little application that sits in your menubar. You can use it to define tasks, and set those tasks to block access to websites, applications, open applications automatically, etc. It's a great help. My primary "Work" activity is pretty simple: block Reddit and open OmniFocus. Nothing more to it. It's set to a period of two hours, and that's usually enough to get me past the task I'm trying to put off. Great, great app.

Print to Evernote

I missed having the "Print PDF to Yojimbo" option in the standard OS X print dialog. This solution is a hell of a lot cleaner than the solution I'd been using.

Tip: If you don't have a ~/Library/PDF Services/ folder, you'll have to create it or the AppleScript will fail.

MLB Standings Geeklet (2012)

I hoped that I could get the MLB Standings Geeklet updated before the 2012 season started. Unfortunately, I haven't been able to. A lack of available time, and MLB's changes to how the stats are served means that I lack the temporal funds to spend on this project.

If I see a good alternative, I'll pass it along.

Update (June 1, 2012): I enabled the Geeklet on a whim a couple weeks back, and it was working fine! I guess the MLB team websites hid the standings until the season started, this year.

Banning a Site from Top Sites on Safari

We came across an issue with one of our web apps where users running Safari on OS X were spawning hundreds of unterminated sessions. It was killing our servers. It only took a couple minutes of investigation to figure out that the culprit was the Top Sites grid when a user opens a new tab. Now the question became how to stop it.

Since this is a Software as a Service installation, we couldn't exactly muck about in code to kill unterminated but inactive sessions. Someone proposed (and temporarily implemented) a method that blocks based on user agent string. Not a very user-friendly solution, but it keept everyone else running while we figured out a better fix.

My idea was that I knew if you went into edit mode on the Top Sites page, and clicked the "X" on one of the thumbnails, that site would never come back onto the list again. I figured that if we could just write to the list, it should be easy to permanently keep the web app off Top Sites. I just didn't know where to do that.

A couple hours of defaults read commands, and a few trips to Google turned up the best solution I could come up with. It's not exactly as clean as I'd like, but it seems to work well enough for us, until we can get our vendor to limit the number of concurrent sessions per user.

I created a shell script which we can push out to the user computers. The script does the following:

#!/bin/bash

# This script is to ban a URL from appearing in the Top Sites in Safari
# since Top Sites was spinning up hundreds of unterminated sessions per user.

killall Safari                  # Kills Safari                          

echo "Removing Safari Caches"
rm -rf ~/Library/Caches/com.apple.Safari/Caches.db
rm -rf ~/Library/Caches/com.apple.Safari/Website\ Caches

echo "Clearing Top Sites List"
defaults write ~/Library/Safari/TopSites.plist TopSites '{ }'

echo "Banning URLs from Top Sites"
defaults write ~/Library/Safari/TopSites.plist BannedURLStrings -array-add http://yoururl.com/watever/
defaults write ~/Library/Safari/TopSites.plist BannedURLStrings -array-add http://www.yoururl.com/whatever/

I don't like that I can't politely quit Safari from the commandline without installing some additional software. Additionally, I'm not really clear why I have to add the URL both with and without the "www." when Safari doesn't seem to have to do that when it automatically adds to the Banned URL Strings array.

Finally, I'm not too cool that I have to clear the whole Top Sites array before making the edits. While I don't have anything pinned there, I can see a situation where someone uses Top Sites as a quick way to get to their favorite sites, and any change there might be a big deal.