Archives
Admin / Logout

Adam Merrifield

a picture of me
I am a theme developer, a coder and internet personality.

what i am

I am the owner and operator of seyDoggy Systems, a small theme, code and design outfit based in Kitchener, Ontario, Canada. We primarily develop web based technologies but have begun to dabble in the desktop realm.

what i do

I code like a fool. I design like a fool. I am happiest when I can split my time between the two (though I tire of Photoshop faster then I do Sublime Text 2 or Terminal), and somehow I have managed to etch out a living doing so.

seyDoggy.com Gets a New Look

[new seydoggy site](http://seydoggy.com/ “seyDoggy systems . theme . code . design”)It’s finally done… I think. After spending more then a year at it, I think I have finally consolidated all of the web properties and blogs that I’ve wanted to for quite some time.

Probably the most notable changes are to [seyDoggy.com](http://seydoggy.com/ “seyDoggy systems . theme . code . design”). It’s no longer a portfolio site for past work since we don’t actually do client work anymore. It’s now just a calling card, if you will, or a hub I guess.

Also, the seyDoggy blog has been moved over to this blog. All of the original posts have been maintained so all the posts on RapidWeaver tips, AppleScripting, browser hacking, etc, are still available.

And last but not least, I’ve brought the [Merrifield Photography](http://merrifield-photography.com/ “Merrifield Photography”) blog over here as well. There are some pretty old stuff in there that I didn’t want to let die.

So there we are… my web-life is a little tidier, a little cleaner, a lot simpler. Now I just need to give the layout here a little tender loving care.

[tags]seydoggy,web,design,blog[/tags]

| Trackback

Available Light Portraits

Reiley - December 30 2009

Reiley – December 30 2009, originally uploaded by seyDoggy.

I pulled out my 1984 50mm f1.7 Minolta lens earlier this week and have kept it on ever since. I love that old lens. I love how at f1.7 you can shoot with just about any available light and get a decent shot.

This one is a nice, contemplative shot of my son who is with us for the holidays. He’s really growing up fast.

| Trackback

Sunday Morning Snack

Sunday Morning Snack

Sunday Morning Snack, originally uploaded by seyDoggy.

Sunday Morning Snack

Sunday Morning Snack, originally uploaded by seyDoggy.

Sunday morning is a time for mom and dad to tackle some chores and projects but it only takes a little sun and childish wonder to get me to pause and enjoy what Sunday means to the girls.

Bathed in Sunday morning light, the girls enjoy a self chosen snack of BearPaws.

| Trackback

Bunny Escapes Zoo – 2004

Bunny Escapes Zoo - 2004

Bunny Escapes Zoo – 2004, originally uploaded by seyDoggy.

Years ago a bunch of bunnies managed to get free of their pen at the Waterloo Park. For quite some time after (and I am sure still today) you could find the bunnies — now feral — roaming about many of the public green spaces within a few kilometers of the park. Quite used to humans being around, you could often have these critters chewing grass at your feet while you ate your lunch on the city hall lawn.

This was shot in May 2004 on Fujifilm NPH 120.

| Trackback

RapidWeaver Add-ons Version Identifier

RapidWeaver Add-ons Version IdentifierOne thing RapidWeaver does poorly — at this current moment — is help the end user determine the product version they are using on any given 3rd party add-on. Knowing your add-ons (theme or plugin) version number is critical when asking for support and is often one of the first things the developer will ask you for.

If you know where the add-ons are kept (`~/Library/Application Support/RapidWeaver/`) then you might be able to determine a plugin or themes version number with the Finder, or if you have RapidWeaver open you can find out a plugin’s version by opening the plugin browser, or if you show a themes package contents and…

Well, I like to have these sorts of things at my fingertips and do as little thinking as possible, so I wrote an AppleScript to gather this information for me no matter where I am or what I am doing[*][a_091103113228]:

– file types to choose from
set rwTypeArray to {“Theme”, “Plugin”}

– choose from those file types
set rwTypeLong to {choose from list rwTypeArray ¬
with prompt ”Which RapidWeaver product type ¬
you like to find the version of?” ¬
with title “Theme or Plugin”} as string

– logic from result
if rwTypeLong is “Theme” then
set rwType to “rwtheme”
else
set rwType to “rwplugin”
end if

– get name of hard drive
tell application “System Events”
set diskName to (get name of startup disk) as string
end tell

– get name of user
set userName to (do shell script “whoami”) as string

– select file from RW directory
tell application “Finder”
set rwFile to (choose file with prompt ¬
“Please select your RapidWeaver ” & rwTypeLong & “:” ¬
default location (diskName & “:Users:” & userName & ¬
“:Library:Application Support:RapidWeaver” as alias) ¬
of type rwType without invisibles)

– read version number
tell application “System Events”
set rwInfo to (get version of the file (rwFile as string))
end tell

– and display it
if rwInfo = “” then
display dialog ¬
“It seems that your ” & rwTypeLong & ¬
” doesn’t have a version number that I can read. ¬
Sorry.\n\n¬
Would you like me to reveal it’s ¬
package contents for you?” ¬
buttons {“Cancel”, “Yes”} default button (2)
set rwPath to rwFile & “Contents” as text
open rwPath
else
display dialog “The version information:\n\n” & rwInfo & ¬
“\n\n …has been copied to your clipboard.” ¬
buttons {“OK”} default button (1)
– copy to clipboard
set the clipboard to rwInfo

end if
end tell

### Notes ###

* If a theme is to have it’s version number read, it must have an Info.plist in it’s package contents. Some theme developers do not include this file. For those that don’t, the script will reveal the theme’s package contents so that you can inspect the version number at the bottom of the Theme.plist file

### Download ###

Get your fresh copy of [RapidWeaver\_Addons\_version.scpt][a_091103112457] from CodeCollector.net

[a_091103112457]: http://www.codecollector.net/view/BB433BE1-0BD0-43C6-AE7A-CFEE8E623AB8 “RapidWeaver_Addons_Version.scpt”
[a_091103113228]: http://seydoggy.com/2009/11/03/rapidweaver-add-ons-version-identifier/#a_091103113228

Comments (1) | Trackback

Creating Unique ID's For… Anything!

There are numerous reasons you might need a unique identifier on something; you upload files with common names to the same ftp site, you use the id attribute for internal links on a blog that might display multiple posts (the chances of repeating yourself are good), you want to sign your emails with a unique, one time id for your own verification… Whatever the case, a unique id could come in handy.

The easiest thing to do is use a timestamp and a shell script can do that easily enough for us. For everyday use, the year, month, day, hour, minutes and seconds should suffice (unless you need multiple unique id’s per second). Here is how the bash script would look:

date +%y%m%d%H%M%S

Entering this string into the Terminal.app would yield a twelve digit number like this:

091027191546

The first pair of digits is the year, the second pair is the month, the third pair is the day, then the hour, minutes and seconds (all in pairs). Run this script in Terminal.app as many times as you like and you will never get the same number.

So you could enter this into your terminal every time you wanted a unique id… or you could make this shell script work *for* you from anywhere.

## TextMate Snippet ##

TextMate Snippet for Unique ID TextMate makes running shell scripts dead easy — all you need to do is create your own snippet. To do this:

* open your Bundle editor — `Bundles > Bundle Editor > Show Bundle Editor` ***or*** `⌃⌥⌘B`
* create a new bundle (if you don’t already have your own) from the + icon
* within that bundle create a new snippet from the + icon
* in the edit window, type:

`date +%y%m%d%H%M%S`
* define a Tab Trigger or Key Equivalent
* leave the scope selector blank to have the snippet apply to all language types

Now you have a snippet that is accessible in any language scope you use TextMate for. This is handy if you write reference links in HTML articles, such as:

See this note

This is the special note I wanted you to see.

Or for reference style links in MarkDown:

Check out our site, [seyDoggy][a_091027194631], for some
really cool tips and tricks.

[a_091027194631]: http://www.seydoggy.com/ “seyDoggy’s really cool site”

### Download ###

Download your fresh copy of “[Unique ID.tmSnippet][a_091027205118]” from seyDoggy.com.

## AppleScript to clipboard ##

UniqueID AppleScript for creating unique id'sSay you’re not a TextMate user but you still want a quick way to run this shell script with as little effort as possible. AppleScript makes quick work of this task with it’s `do shell script` functionality. We need to make an AppleScript that runs the shell script, then copies the results to the clipboard. Then we can paste that result into what ever we’re working with at the time; file renaming, email signing, etc…

Here is how the script looks:

set uniqueID to (do shell script “date +%y%m%d%H%M%S”)
set the clipboard to uniqueID
display alert “\”" & uniqueID & “\”" & “Has been copied to your ¬
clipboard” giving up after 1

### Download ###

Get your fresh copy of “[UniqueID.scpt][a_091027205534]” from CodeCollector.net

[tags]applescript,shell,script,textmate,snippet,terminal,unique id[/tags]

[a_091027205118]: http://www.seydoggy.com/downloads/UniqueID.tmSnippet.zip “Download from seyDoggy.com”
[a_091027205534]: http://www.codecollector.net/view/55260B3D-599D-489A-BC7E-C51AF597B2D0 “Download from CodeCollector.net”

Comments (1) | Trackback

3 Quick AppleScripts to Save You Time

AppleScript is an automation solution that allows you to handle tasks quickly and efficiently without a lot of thought or effort on your part. This can be repetitive *things* you may want to take care of in short order or this might simply be *stuff* you want to do from anywhere regardless of what app you are in. Whatever the case, AppleScript can usually be employed for such tasks.

I enjoy solving process streamlining needs on my own with AppleScript and I am not one to keep good things to myself so here are just 3 little scripts I would like to share. You might have a use for them and they might just make your day easier.

## Toggle apps on or off ##

If you’re like me you might have one or two apps that do all that you need them to just by turning them on or off. So why leave them running in the background all the time? Two apps that I can think of in my list are [Nocturne][btn] and [Isolator][wmi]. I use them from time to time but not often enough to keep them in the menu bar permanently. Activating their features requires me to select their icon from the menu bar and selecting the option that toggles their behavior on or off. Or if you just leave their behavior toggled on then quit and restart the app, it has the exact same effect. Quitting the app turns the feature off (obviously) and starting the app turns the feature on…

Sounds like a job for AppleScript:

– replace “YourAppName” with your app
set yourApp to “YourAppName”

– leave the rest to us
if appIsRunning(yourApp) then
tell application yourApp to quit
else
tell application yourApp to activate
end if

on appIsRunning(appName)
tell application “System Events” to ¬
(name of processes) contains appName
end appIsRunning

By changing the name of “YourAppName” to the app you want to toggle on or off and then setting yourself a keyboard shortcut for the script, you can then activate the app and it’s only desired feature with a stroke of the keys.

### Download ###

Get your fresh copy of “[On-Off_AppToggle][ooat]” from CodeCollector.net

[btn]: http://code.google.com/p/blacktree-nocturne/ “blacktree-nocturne – Project Hosting on Google Code”
[wmi]: http://willmore.eu/software/isolator/ “Isolator”
[ooat]: http://www.codecollector.net/view/CD71C6B3-F52E-4040-AF95-2BE9F9668827 “Code Collector – View Snippet”

## Simple Web Search ##

Google Web Search AppleScriptDo you remember when a query to a search engine was a simple string that looked like `http://www.google.com/search?q=this%20or%20that`? Now-a-days search strings tend to include all sorts of information like the source of the search, encoding, language, client, OS… and ends up like and unreadable bunch of garbage like this `http://www.google.com/search?source=qsb-mac&oe=UTF-8&hl=en&q=this%20or%20that&client=qsb-mac&ie=UTF-8`. I for one don’t need every one of my queries to be counted so I wrote a simple script to pose that basic string once again. For your own purposes you can change the search engine and browser to suit your needs.

set userQuery to text returned of ¬
(display dialog “Google search:” ¬
default answer “” buttons {“Cancel”, “OK”} ¬
default button 2)

set httpArray to ¬
{“http://”, “www.”, “.com”, “.ca”, “.net”, “.org”, “.info”, “.us”}

set httpBool to false
repeat with httpAny in httpArray
if userQuery contains httpAny then
set httpBool to true
exit repeat
end if
end repeat

if httpBool then
tell application “Safari” to open location userQuery
else
tell application “Safari” to open location ¬
“http://www.google.com/search?q=” & userQuery
end if
tell application “Safari” to activate

When you launch this script you just enter your search query and press return.

### Edits ###

**r4 10-29-09 09:43** – It would be handy if you could use this script to open known urls to, so I’ve edited the script to do so in a basic manner. It’s not perfect yet as I need to write some regular expressions to really detect proper TLDs and such. But it will do for now. So, perform a query and Safari will open that query in as a Google search. Or, enter a URL and Safari will directly open that website.

### Download ###

Get your fresh copy of “[Google_Search][gs]” from CodeCollector.net

[gs]: http://www.codecollector.net/view/969C4A3D-C59F-400C-94D5-A26B4DE2DB20 “Code Collector – View Snippet”

## Launch apps by task ##

Launch Task AppsMy days, weeks and even months can often be broken into many different tasks. I wear a lot of hats as a small business owner. One day I might be providing support for the RapidWeaver themes I make and the next day I will be knee deep in code making the latest greatest product. One minute I am social networking and the next I am designing something shiny.

Each of these tasks involves a unique set of apps to be open which can make changing gears a time consuming — if not confusing — process.

To address this I wrote a script that launches (or quits) a particular set of apps based on the task I need to do. For example:

* If I am busy with support, I want to launch:
* Mailplane
* Safari
* TextMate
* If I am networking I will use:
* Safari
* Adium
* LimeChat
* Mailplane
* TweetDeck
* If I am designing I want:
* DigitalColor Meter
* LittleSnapper
* Photoshop
* Or if I am developing a new theme:
* RapidWeaver
* Safari
* TextMate
* MAMP

And so on… As mentioned, I can use the script to either launch these sets of apps or quit them and I can do so with a single keyboard-shortcut. This saves a lot of time and helps keep the clutter to a minimum. You can fill in your own task sets and your own apps to suit.

– define the sorts of tasks you wish to activate multiple apps for
set taskArray to {“Surfing”, “Media”, “Designing”}

set taskName to ¬
{choose from list taskArray with prompt ¬
“Pick your process:”} ¬
as string
set toDoArray to {“Launch apps”, “Quit apps”}
set toDoResult to ¬
{choose from list toDoArray with prompt ¬
“Would you like to launch or quit these applications?”} ¬
as string

if taskName is equal to “Surfing” then

– define the apps you would like to open/close
set appArray to ¬
{“Safari”, “LittleSnapper”, “Mail”}

runTrue(appArray,toDoResult)
else if taskName is “Media” then

– define the apps you would like to open/close
set appArray to ¬
{“iTunes”, “Last.fm”, “DVD Player”}

runTrue(appArray,toDoResult)
else if taskName is “Designing” then

– define the apps you would like to open/close
set appArray to ¬
{“Adobe Photoshop CS3″, “DigitalColor Meter”, “LittleSnapper”}

runTrue(appArray,toDoResult)
else
display dialog ¬
“Something is wrong! Please check your array values.”
end if

– runTrue function
on runTrue(appArray,toDoResult)
repeat with appName in appArray
if toDoResult is “Launch apps” then
tell application appName to activate
else if toDoResult is “Quit apps” then
tell application appName to quit
else
display dialog “Houston, we have a problem!”
end if
end repeat
end runTrue

### Download ###

Get your fresh copy of “[LaunchTaskApps][lta]” from CodeCollector.net

[lta]: http://www.codecollector.net/view/7882/LaunchTaskApps “Code Collector – View Snippet”

## Go play ##

I hope you can make use of these scripts in your own daily workflow. I know I would be lost without them. Do have any scripts of your own you want to share? Feel free to comment and let me know.

[tags]applescript,app toggle,launch task apps, google search[/tags]

| Trackback

Scripting LittleSnapper… Slight Return

Less then a week after writing [*this*][sls] AppleScript — which launches [LittleSnapper][ls] and snaps the website currently in view in Safari — the boys at Realmac Software come out with [*this bookmarklet*][bml] that does exactly the same thing, only with a mouse-click instead of a hot-key combination… unless you’re me.

I loath the mouse and if I can avoid ever using it I will go to great lengths to make sure my hands stay firmly atop my keyboard. Perhaps you’re the same way, so for kicks I turned Realmac Software’s bookmarklet into an executable AppleScript that I can assign a hot-key to.

## What’s a bookmarklet? ##

First you have to understand what a bookmarklet does. A bookmarklet is nothing more then a bit of javascript (in many cases) that when clicked performs a basic task. It’s like a mini application… like an applet… in fact, it *is* an applet, hence the name “bookmark”-”let”. In the case of the LittleSnapper bookmarklet, clicking the bookmark (or URL) tells your browser (in javascript) to change the URL in the address bar from `http://example.com` to `littlesnapper://snap/http://example.com`. You’re just adding `littlesnapper://snap/` to the front of any URL! You can actually do this yourself, provided you have LittleSnapper. Try going your favorite website, click the address field, type `littlesnapper://snap/` in front of the URL and hit return… ta-da!

## Make one-click easier? ##

So let’s go back to actually using the bookmarklet… you have to click on it and that’s no fun. It’s time to turn it into AppleScript!

The bookmarklet, if you look at it in your bookmarks folder, looks like this:

javascript:location.href=’littlesnapper://snap/’+location.href;

The quick and dirty way to turn this into an executable AppleScript would be to use Safari’s built in `do JavaScript` method, like this:

tell application “Safari”
do JavaScript “location.href=’littlesnapper://snap/’\n
+location.href;” in document 1
end tell

But that would leave you pretty much locked into using the script with Safari when using hot-keys, while *clicking* the bookmarklet will work in any browser. So `do JavaScript` is too limiting.

Since we only need to pass in the string `littlesnapper://snap/` before the URL, why not just write a method that does that:

tell application “Safari”
set currentURL to URL of front document
open location “littlesnapper://snap/” & currentURL
end tell

This works, but if you want to apply it to all other browsers — Opera, Camino, Firefox, etc — you have a lot of work ahead of you as you discover the various degrees of scriptability each app has. To grab the URL in some of these apps you have to jump through hoops:

* in safari it’s `URL of front document`
* for Firefox `«class curl» of window 1` will sometimes work
* Camino is `URL of browser window 1` and so on…

Some apps need to use System Events to access them, others don’t. And then try and tell each one that you want to `open location`, again with or without System Events… it turns into argument soup very quickly.

A good rule of thumb when trying to script anything is to simplify the number of tasks you assign to any given process. In this case, for each browser I am trying to do two things; get the current URL and then open a new, modified URL.

## LittleSnapper is a browser too! ##

Then it got me thinking — LittleSnapper uses webkit as it’s rendering engine and therefor it should share a lot of the same scripting dictionary that Safari uses. So I thought I would test something out; I attempted to `open location “littlesnapper://snap…` with LittleSnapper itself:

set currentURL to “http://www.google.ca”
tell application “LittleSnapper”
open location “littlesnapper://snap/” & currentURL
end tell

Viola! Without opening a “browser”, I just snapped a web shot of Google.ca, right in LittleSnapper. This now cuts the workload of running unique scripts for each browser in half since I can now tell LittleSnapper to open the URL… once I have it.

## Scripting a common thread ##

So now to get the URL from the browser — any browser — without making a code spaghetti like this mess:

if application “Firefox”is running then
tell application “Firefox”
set currentURL to «class curl» of window 1
end tell
else if application “Safari”is running then
tell application “Safari”
set currentURL to URL of front document
end tell
else if application “Opera”is running then
tell application “Opera”
set props to GetWindowInfo of window 1
set currentURL to item 1 of props
end tell
else if application “Camino”is running then
tell application “Camino”
set currentURL to URL of window 1
end tell
end if

There has to be a better way… and there is. Here comes System Events to the rescue with a couple of keystroke executions like so:

tell application “System Events”
– highlight address field with ⌘L
keystroke “l” using {command down}

– copy to clipboard with ⌘C
keystroke “c” using {command down}
end tell

This will allow us to access any browser the same way, with global hot-keys as executed by AppleScript.

Now we just need to talk to those browsers to find out which one is in use. We can do this with an if statement, like this:

if application “Safari” is running then
tell application “System Events”
keystroke “l” using {command down}
keystroke “c” using {command down}
end tell
end if

But with four or more browsers this would be a bit much.

## The full deal ##

So let’s make an array out of our favorite browsers, run that array through a loop, mash in our System Event keystrokes, and finish it all off with a variable passed into LittleSnapper and this is what we get:

– let’s define our array
set appArray to {“Safari”, “Firefox”, “Opera”, “Camino”}

– then run that array through a loop
repeat with appName in appArray
if application appName is running then
tell application appName to activate
tell application “System Events”
keystroke “l” using {command down}
keystroke “c” using {command down}
end tell
delay 0.5

– make a variable from the clipboard
set currentURL to the clipboard
end if
end repeat

– pass that variable in to LittleSnapper
tell application “LittleSnapper”
activate
open location “littlesnapper://snap/” & currentURL
end tell

Is this overkill to get a hot-key combo that does what a bookmarklet does in one click? Depends on who you ask I guess. I think it’s a pretty good solution in fact. Now instead of copying a bookmarklet to the toolbar of every browser I use, I have a script that I can assign a global hot-key to (via [FastScripts][fs] or some such tool) and use it across any browser I set in my array.

Yes, I am *that* much of a geek.

## Download ##

[Get it fresh from CodeCollector.net][ccdn2]

[tags]applescript,littlesnapper,realmac,software,safari,firefox,opera,camino,browser,bookmarklet,hot-key[/tags]

[sls]: http://www.seydoggy.com/2009/09/30/scripting-littlesnapper/ “seyDoggy Web and Graphic Design – seyDoggy weblog – my thoughts on the web and the mac”
[ls]: http://www.realmacsoftware.com/littlesnapper/ “LittleSnapper – Screenshot and Website Capture for Mac OS X Leopard”
[bml]: http://www.realmacsoftware.com/blog/index_files/littlesnapper-bookmarklet.php “Realmac Software Blog – RapidWeaver and LittleSnapper News”
[fs]: http://www.red-sweater.com/fastscripts/ “FastScripts”
[ccdn2]: http://www.codecollector.net/view/E8CE65D6-67B3-45DF-A3E5-745F9616F1B3 “Download from CodeCollector.net”

| Trackback

Scripting LittleSnapper

[Scripting LittleSnapper][ls]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][ls] 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][em] 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[*][buttons]:

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][rssw] [FastScripts.app][fsa]. You could also use this in [LaunchBar][lb], [QuickSilver][qs], [Butler][btlr], or any other means you may use to run AppleScripts.

## Full Script ##

– This script launches LittleSnapper

– and tells it to snap the current web page

– By Adam Merrifield
– 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][ccdn]

## Notes ##

* this exact sequence of commands could change if Realmac Software ever changed LittleSnapper’s menu layout, but I prefer this shorthand over the verbose menu item selections.

[buttons]: http://www.seydoggy.com/2009/09/30/scripting-littlesnapper/#buttons

## References ##

* [Apple Developer Connection][apldev]
* [MacScripter][mcscrpt]
* [Mac OS X Hints][mcoshnt]

## 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][fsa] 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]

[ls]: http://www.realmacsoftware.com/littlesnapper/ “LittleSnapper – Screenshot and Website Capture for Mac OS X Leopard”

[em]: http://emberapp.com/seydoggy/ “View all images :: Ember”

[rssw]: http://www.red-sweater.com/ “Red Sweater – Amazing Mac Software”

[fsa]: http://www.red-sweater.com/forums/viewtopic.php?id=878 “How can I set keyboard shortcuts for FastScripts menus? (Page 1) – FastScripts – Red Sweater Software”

[lb]: http://www.obdev.at/products/launchbar/index.html “LaunchBar 5″

[qs]: http://code.google.com/p/blacktree-alchemy/ “blacktree-alchemy – Project Hosting on Google Code”

[btlr]: http://www.manytricks.com/butler/ “Many Tricks · Butler”

[ccdn]: http://www.codecollector.net/view/FCD7F708-8EB8-404D-B173-A8D2C6254B48

[apldev]: http://developer.apple.com/applescript/

[mcscrpt]: http://macscripter.net/

[mcoshnt]: http://www.macosxhints.com/search.php?query=applescript&mode=search&type=all&keyType=all

Comments (1) | Trackback

iMac G3 Web Server – Part 1

Creating an iServer from an iMac G3Recently 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](http://en.wikipedia.org/wiki/Linus_Torvalds “Linus Torvalds – Wikipedia, the free encyclopedia”) does ##

That’s when I decided that [Ubuntu Server](http://www.ubuntu.com/products/whatIsubuntu/serveredition “Ubuntu Server Edition | Ubuntu”) 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](http://www.ubuntu.com/ “Ubuntu Home Page | Ubuntu”) (which can be [downloaded here](http://cdimage.ubuntu.com/ports/releases/9.04/release/ “Ubuntu 9.04 (Jaunty Jackalope)”)) 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)](http://en.wikipedia.org/wiki/WOPR “WOPR – Wikipedia, the free encyclopedia”) 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: ##

  1. * 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.
  2. ** I set my server name up to the default “ubuntu”. Yours may read different.

[tags]server,linux,ubuntu,imac,g3,terminal,root[/tags]

Comments (1) | Trackback
Powered by RapidWeaver, WP-Blog and WordPress 3.5.1