Scripting LittleSnapper
I hate clutter in my Dock… I also hate being slowed down looking for things. You can imagine these two positions are at odds with each other quite often. I don’t use the Dock in Mac OS X as a place to launch apps so much as I use it as a visual reminder of the things I can do, but don’t on a regular basis.
Like LittleSnapper for instance. I use it maybe once a day, and for pretty much the same thing — I open it up, I snap the current web page and then proceed to tag it, rate it and upload it to my ember Pro account — but I don’t keep it open. I quit LittleSnapper when I am done and cary on with the rest of my day. This kind of usage doesn’t warrant a coveted position in my Dock, but if I have to search for the app (Spotlight, Google QSB, QuickSilver) or dig for it in Finder, the inspiration to snap that web page may well pass.
So what does a magna nerdulosa like myself do to address this situation? I automate! AppleScript to the rescue!
The first thing I want to do is launch LittleSnapper and I do that by tossing a little bash in AppleScript using the following:
tell application "LittleSnapper" to activate
And now LittleSnapper is ready to have it’s buttons pushed*:
tell application "System Events"
tell process "LittleSnapper"
click menu item 1 of menu "Capture" of menu bar 1
end tell
end tell
It’s as simple as that! The full script will:
- Luanch LittleSnapper
- tell LittleSnapper to go into the “Capture” menu
- click “Snap Web Address from Safari”
You can then cary on with tagging, annotating or whatever else tickles your LittleSnapper fancy.
Now what?
For me the next step is to save the script in ~/Library/Scripts/ add a hot-key combo to it using Red Sweater Software’s FastScripts.app. You could also use this in LaunchBar, QuickSilver, Butler, or any other means you may use to run AppleScripts.
Full Script
-- This script launches LittleSnapper
-- <http://realmacsoftware.com/littlesnapper/>
-- and tells it to snap the current web page
-- By Adam Merrifield <http://www.seydoggy.com>
-- r4 10-08-09 08:12 (removed delays)
tell application "LittleSnapper" to activate
tell application "System Events"
tell process "LittleSnapper"
click menu item 1 of menu "Capture" of menu bar 1
end tell
end tell
Download
Get it fresh from CodeCollector.net
Notes
References
EDITS
r4 10-08-09 08:12
I’ve removed the delays I once needed before each section. The modifier keys I was using (specifically ⌥) in my hot-key sequence were being passed to LittleSnapper and causing LittleSnapper to prompt me to choose a new image library. Taking ⌥ out of the sequence negated the need for the delays.
r2 09-30-09 11:42
While there is technically nothing wrong with the original script, the bash line — do shell script "open -a LittleSnapper" — throws an error in console and some part of that line looks as though it will not be supported for much longer. So I have changed this line to the slightly more verbose tell application "LittleSnapper" to activate
I have also split the 1 second delay into two 0.5 second sections, one at the front end and one before system events. It seems FastScripts.app really is fast and is getting ahead of itself when executing the script with hot-keys. That causes issues for me but may not affect you, depending on what you use to run your scripts.
[tags]applescript,automation,littlesnapper[/tags]
iMac G3 Web Server – Part 1
Recently an old iMac G3 of mine made it back home after a lengthy stint at the in-laws (introducing them to computers a few years back). My initial thoughts were to take her to the great recycling depot in the sky, but then I got to thinking. “What could a web designer/developer use a seriously underpowered G3 chip be useful for?”
And you all chant in unison… a web server!
So this is just a document of the stuff I went through to get from point a to point b. It’s not so much instructional, but if you wish to follow along, by all means, have at it.
Serve with Mac OS X… maybe not.
So I got to fiddling around with this old bubble of a machine and thought initially that I would just try to use the services provided in the Mac OS (the iMac was running 10.4 at the time). This proved to be so painfully slow that I decided to dig up an old copy of OS X 10.2 (it was called Jaguar back then, in case you forgot) and install it. While this was a tad faster, those services that were installed were sorely out of date.
Since it was clear that I was going to have to get into the command line to install MySQL and update and configure the PHP that was there, and since the the whole desktop environment was going to be redundant by the time this thing goes into service… why use the Mac OS at all?
When in Freeville, do as Linus does
That’s when I decided that Ubuntu Server was the way to go. There are a ton of worthy Linux distro’s out there but I decided to go with Ubuntu because their PowerPC ports are pretty much up to date with with the core development. I could have used Debian but trying to track down the latest stable PowerPC build was like trying to finding a hot date at a Star Trek convention.
I just so happened to have an Ubuntu Server 8.1 iso laying around, so just as a proof of concept, before tying up anymore of Ubuntu’s precious bandwidth, I tried the install out to be sure that all would work on the old PPC box. And it did.
Fast forward to the Jaunty Jackalope
So I got my hands on the latest stable build of Ubuntu Server for PowerPC, Ubuntu 9.04 (which can be downloaded here) and got to work.
The install was pretty straight forward, I just followed the steps as each prompt appeared. All in all it took about an hour on the old beast. One helpful hint: it seems the install will fail repeatedly if you don’t have the machine connected to the internet. I just ended up plugging in to the spare ethernet port of my Mac Pro, but I am assuming any connection would do.
I have a package for you
I wasn’t really sure what packages I was going to need in the end, so I installed most, if not all of them. But at the very least I knew I was going to need a LAMP stack *, ssh and possibly DNS (though unlikely that I would bother to set it up). If you plan to make your own server you might as well take the time to research the options since installing and configuring them at install will save you the hassle later.
Bong!
Once the install was done I was prompted to reboot. So I did. If your a total nerd like me you’ll get excited to hear that familiar Mac “Bong!” yet moments later get nothing but a black screen, white text and a login prompt… I can almost hear echos of Joshua (WOPR) in his computerized voice asking me, “Would you like to play a game?”
With everything done right in the install I was prompted with**:
`ubuntu login: `
I entered my username, in my case “adam”, and hit return:
`ubuntu login: adam`
Entered my password, •••••••••••, and hit return:
`password: `
Up pops a bunch of info like last login, software details, load and memory usage etc… and the all important command prompt:
`adam@ubuntu:~$ `
The root of the solution
Here is where I am about to do a no-no… if I ever planned to run this machine in the DMZ (beyond the safety of my internal network and out side my router) I would NEVER do this. However, I want to have pure, unadulterated, God-like power over this machine and I do not want to sudo (“superuser do”) it every step of the way.
Those of you familiar with Ubuntu know that they disable root login by default. But this cripples what various apps can do in various directories over ssh — namely ExpanDrive, MacFusion, various FTP clients and from what I can tell some TextMate bundles (though I probably have them configured wrong) — and I don’t want to always have my head stuck in the terminal.
So, to enable root login I had to set a root password (since the install never prompted me for a root password). This is done with:
`adam@ubuntu:~$ sudo passwd root`
I then entered my own password for adam@ubuntu, •••••••••••:
`[sudo] password for adam: `
And the the new root password twice:
`Enter new UNIX password: `
`Retype new UNIX password: `
And success:
`passwd: password updated successfully`
Now I am able to switch to root:
`adam@ubuntu:~$ sudo su root`
And after entering the password I just created I am now presented with:
`root@ubuntu:~# `
Now with that out of the way I can proceed with causing some real damage…
More to come
In following posts I will talk about my ssh setup, configuring apache and working with my in my new server environment.
Notes:
- * LAMP stands for Linux-Apache-MySQL-PHP/Perl/Python and is a generic acronym for a stack of applications that provide the kind of web services need to run web applications and dynamic web content.
- ** I set my server name up to the default “ubuntu”. Yours may read different.
[tags]server,linux,ubuntu,imac,g3,terminal,root[/tags]
MacFusion – Snow Leopard Fix
I’ve been playing around with ssh while I configure my Ubuntu Server (more details about that soon) and figured I would get my head out of the terminal for a bit. So I downloaded ExpanDrive again (used it a while back) only to discover that it’s since been upgraded… a paid upgrade… and my old serial no longer applies. I wasn’t enamoured with “mounting” remote servers as hfs volumes enough to pay for this app a second time so I decide to move on to the free alternative; MacFUSE + MacFusion.
The only hiccup I encountered was that MacFusion didn’t seem all that happy about launching an ssh connection under Mac OS X 10.6 Snow Leopard. I could connect with no issues in terminal but not in MacFusion. A quick visit to the MacFusion Google Group revealed this temporary solution, which is basically:
- quite MacFusion
- set up MacFUSE to get betas (under System Preferences)
- and remove this file in Terminal:
rm /Applications/Macfusion.app/Contents/PlugIns/sshfs.mfplugin/Contents/Resources/sshnodelay.so
To get the nitty-gritty, please read the full post at Racker Hacker.
[tags]snow leopard,mac osx,terminal,ssh,server,macfuse,macfusion[/tags]
FastScripts; My Favorite New Trick
I know it’s pricey for what it does and it’s definitely a tad on the geeky side but I absolutely had to support Red Sweater Software’s efforts for their little gem of an app, FastScripts. At first glance it’s little more then a way to organize, access and instigate your AppleScripts but it’s only once you tap into what that truly means that you start to realize what FastScripts is allowing you to tap into.
I first came to FastScripts when a blogger (who and for what blog I cannot remember) mentioned that it might help solve a problem I was having, issuing a hot-key combination to an AppleScript I wrote* to open a selected item (RapidWeaver theme package, project, php file, whatever…) in TextMate from my favorite file browser, Path Finder. You see this sort of thing used to be dead easy in QuickSilver (triggers, we used to call them), you enable proxy’s, grab the item, do what you want with it. But in my long struggle to ween myself off QuickSilver and all that it made it mighty, if not temper-mental, I found myself needing to script the things that QuickSilver took for granted. I actually enjoy this hands on dig through what makes Apple tick though.
So it was then that I discovered the magic of FastScripts and what it brought to the AppleScripting platform. It did what I needed, allowed me to assign an application specific hot-key combo to my Open-in-TextMate script. But it does more then the AppleScript menu ever allowed. It makes more sense, completely accessible with hot-keys and keyboard navigation, both global and application-specific shortcuts can be defined… It runs scripts fast and effectively, ties in exceedingly well with any app I’ve used it for, runs AppleScript, Perl, Automator workflows, etc… It just makes a lot of sense to me.
I might be a little script happy these days, but for as many hot-key combo’s as I can remember, I will gladly write AppleScripts for to help automate my day. Like this one for mounting and un-mounting hard disks when needed; instead of opening up DiskUtility and selecting a disk to mount or writing a few commands Terminal.app, I simply use a hot-key shortcut to run this script:
set diskname to "MyDisk"
do shell script "diskutil mount `diskutil list | awk '/ " & diskname & " / {print $NF}'`"
* In the end I just ended up using Allan Craig’s Open-in-TextMate script as there was little point in reinventing the wheel… and his worked better.
Let the renovations begin
One kitchen cabinet removed, baseboards removed, door casing pryed off, wallpaper stripped, stove pulled out… it smells like renovation to me. One of the joys of owning a home is being able to remodel at will (or as finances allow).
While I am not all that quick with the renos, what with all the kids running around, I still do enjoy when a new project gets underway.

Assist your photograpy with iPhone apps
If you don’t have an iPhone and have never seen one in action, you think I am a crack-head for bringing it in a photography blog. The fact is that the iPhone has turned out to be quite the photographic companion for me. In fact I only have 2 GB of music on my iPhone, but over 6,250 images from my image library on my computer.
The iPhone has become my mobile portfolio, my flickr uploaded, my on-the-fly image editor and my insta-shot camera. But I am not the only one who has tapped into the power of the iPhone as a photographic assistant. Photography Bay recently published a list and mini review of some of the hottest photography related iPhone apps. Whether you have an iPhone or not, this list will certain make you hungry for the photographic possibilities.
The worst part
The worst part about being sick is that my body wants to sleep all the time and that just isn’t practical. The worst part about the weekends is that there is never enough hours to get done all the projects on my growing list of things to accomplish before summer ends, before thanksgiving, before your relatives come for Christmas… you get the point.
Now combining the two, being sick on the weekend, results in fewer items being checked of my list of goals and too few naps for my tired, sick body. And what does that get me? A night of tossing and turning, thinking about what I could have done had I not taken those cat-naps that have surely contributed to my wakeful state at 1:48 am. sigh…
i am teh sick
One thing they fail to tell you when you sign up at the “start your own business” stand is that you are it; you are the big cheese, the secretary, the janitor… you are the work force. But what happens when you get sick? You can’t call in sick. You can’t just hide in your cubical and sleep it off.
That’s the harsh reality for many of us small business owners. We are the only one we can count on to get the work done and our reputations, let alone bottom lines, cannot affoard to take rime off fora cold… or can we?
One thing I have worked hard on with my company is not working hard. I don’t mean to sound like my life is a peach and I don’t do an honest days work because I do. But I build flexibility into my work week. I work on a 4 day schedule with and asumed 5 day week… huh?
I work Monday to Friday but asume that at least one full day will be spent goofing off, researching, experimenting with code, playing games, or if need be, getting well. I compensate for this day of not working, I may work a few hours one evening, get up early another day, not take a lunch the next. In the end it all equates to me not feeling so guilty on a day like today; a day spent sniffling over a box of tissue as I half heartedy performed some machine maintenance, answered a few support emails, and poked around a few forums.
Will the company fall apart come Monday? Nope. According to my 4 day plan I am right on schedule.
Do you work for yourself? How do you plan for sick days and expected interuptions?
