Run Multiple Websites on One Server
“Here’s a simple tutorial to get many websites running on one ubuntu serverLet’s say you have root access to your own server and want to run many websites on it. If you have Ubuntu Server running with Apache, I will show you in a few easy steps how to configure and run as many websites on your server as the load can handle.Follow these simple instructions and your additional websites will up and running immediately.”–via Ubuntu Server – Configure and Run Multiple Websites on One Server | Tech Exposures.
Mac Mini Vault – Apple TV Webserver.
“One of the fun projects going on at Mac Mini Vault is our Apple TV webserver. As much as we’d love to see how many Apple TV’s we could mount into a data center cabinet, it will never be a sustainable service to offer. This project was a fun way to see how far we could take the A4 powered Apple TV. The Apple TV is running iOS 4.2.2 obviously jailbroken with lighttpd for a web server. You can see the webpage we set up by visiting atv.macminivault.com. We’ll keep an eye on the CPU load and watch the analytics to record how much traffic the Apple TV receives.” — via Apple TV Webserver..
Again, some of those on twitter know me all too well. Thanks (again) to @DEVi8 for showing me this one.
Building a Micro Server – Part 1

You might recall a number of months back I was working on repurposing an old iMac into a web server. I was doing this more because it could be done and not because I had to. Truth is I have two other servers which have more then enough head room to take on the additional, and somewhat minor load of web serving duties. But it was the challenge — or complete and utter geek indulgence — that drove me to waste spend my time making something of the old iMac G3.
However, the footprint of an iMac G3 (both physically and environmentally) is not ideal. You can’t rack mount an iMac G3, or stick it on a shelf or hide it under a desk… So I promptly ditched the idea and trumped it up as good bit of fun and some R&D.
But the bug for a smaller server had been planted… I was really liking the idea of a mini server that I could stow away under my desk (and not in a sound proof closet). Not just a web server, but a little everything server.
I had initially toyed with the idea of buying a Mac Mini for this but thought my wife would likely kill me for buying a new Mac as an experimental toy server while she continues to work from a PowerMac G4 (that happens to be dying a slow death). So I set about seeing what it would take to build my own micro server with all new parts that would approximate the Mac mini. Could it be done for less?
This is what I found (no affiliation):
- 1u micro server chassis – $79.99
- mini server motherboard – $109.99
- 2.2GHz Dual-Core CPU – $51.99
- 1u 4 pin CPU fan – $47.00
- 2GB DDR2 SDRAM – $56.99
- 160GB HDD (optional as I had a few laying around) – $51.99
The total, if you include the hard drive, is $397.95 ($345.96 without hard drive). That’s more then $250 – $300 less then the Mac Mini. I know it’s a bit like comparing apples to oranges; the chip is slower, the bus is slower, the footprint is bigger and the I/O doesn’t really compare. On the flip side, the Mac mini doesn’t have a server grade power supply, is limited to slower laptop HDD’s and can’t be rack mounted. There are tradeoff’s either way but when I look at what I am hoping to use it for — web/file/media server — the differences will be outweighed by the 40% – 45% savings of the home built micro server.
This was enough for me, I was sold on the idea. If for nothing else then the pure geeky joy of it… so I went ahead and ordered the parts.
In part two I will show you the assembly of the micro server once the parts arrived, and some of the hiccups I had.
[tags]how to,server,mac mini[/tags]
Going to democamp Guelph Tonight
Tonight I’m heading out to democamp Guelph for a little geek networking, beer and to hear about the latest and greatest in new tech ideas in and around the Guelph area.
The event happens every 3 months or so and consists of a couple hours of 3 minute demos followed by a brief Q & A period. The demos usually consist of new startup ideas, web apps in development, new concepts and overall tech geekness.
But more important are the people who show up. If you’re just getting started in the tech sector, or have just recently had a great idea for a startup, there is no better place to start your networking.
If you want to keep up with what’s going on tonight at democamp Guelph, just follow the twitter hash tag: #dcg.
seyDoggy.com Gets a New Look
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. 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 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]
How AppleScript Saved My Address Book
From the time I got my iPhone — over a year and a half ago — I have been trying to force myself to use Apples own native products, like Mail, Address Book, iCal, etc… It was my thinking that this would make life easier, integrating into the whole Mac-iPhone way of life.
The thing is, I haven’t used any of these products since the days of OS X 10.2. For a time I was using ThunderMail (way back in the day) and eventually the whole Google Suite of apps like Gmail and Google Calendar. So a little over 1.5 years back, I started looking into the migration from these web services to the desktop apps that OS X provides.
With apps like BusySync (and ultimately BusyCal which I now use over iCal and in conjunction with Google Calendar), getting my calendar off the web but still having “anywhere” access was easy enough. And I did, for the first time ever, succumb to the .mac/mobileme world so my information is fully mobile and accessible to me in any form I choose. I am all about redundancy when it comes to data.
Since Mail and Gmail now do IMAP — and do it fairly well — getting local with my mail has not been difficult by any stretch, but I have to admit, I just don’t like the way Mail does things. I never have and that’s why I stopped using it so many years ago. I can get used to it though, and I am trying… on and off.
But my real reason why, after the better part of two years, I haven’t managed to fully integrate into the Macisphere way of doing things is none of the above… It has been moving contacts that has been the biggest catch.
I stopped using the Apple suite of apps around 2002-2003, so it goes without saying that the contacts acquired since then is quite extensive. Gmail’s way of collecting those contacts is sort of a drag-net approach — someone sends you an email and Gmail does it’s best to add that person to your contacts list… at all cost, with little regard for their name or whether it’s a duplicate. After this many years Gmail has collected what it thinks are 10,000 unique contacts… uhhh… yeah. And there is no way to manage those contacts in any practical manner.
So with a slew of free tools, exports, imports and lots of crying I was able to cram those 10,000 contacts into Address Book… which promptly rendered Address Book utterly useless. Fortunately Address Book comes with a handy command to look for duplicates (Card > Look for Duplicates…) and then merges them and their relevant data together. Great. After running for the better bit of 5 hours, Address Book was able to cut that down to a smidge over 4,500 contacts. While this made the app a little more useful on my Mac (though still really slow), Contacts on my iPhone was still, more or less useless.
And this is the way I’ve left it for the last 18 months. Defeated, deflated and frustrated.
Enter AppleScript. Why I hadn’t thought of this earlier, I have no idea, but just a few days ago, while writing an AppleScript to send out all my Christmas E-Cards (which invariably makes use of Mail and Address Book) I thought I had better do something about Address Book once and for all.
I knew going into this that Address Book was full of duplicate information, but it was different enough that Address Book wasn’t able to tell. For instance, if a contact has a first name of “John” and a last name of “Reynolds”, Address Book can’t draw the similarity from another contact with a dubious first name of “John Reynolds” and no last name. Nor can it conclude that the contact with the first name “Reynolds” and last name “John” is likely the same as the first contact.
In addition to this mass confusion, in Address Book’s attempt to manage duplicate contacts, it merged nameless email addresses into thousands of other nameless email addresses creating countless, nameless contacts, each with dozens, if not hundreds of emails… sound confusing?
It was time for some bug guns… big scripting, non-discriminating guns.
Before I go any farther, let me start by saying DO NOT TRY THIS AT HOME! YOU WILL CAUSE IRREVERSIBLE CHANGES TO YOUR CONTACTS IN ADDRESS BOOK! Unless you are certain you have this information backed up or stored elsewhere, or unless you are just as desperate as me and don’t care anymore, do not use these scripts!!!
Delete Nameless Entries
So first things first. I want to get rid of all the nameless, kludged together contacts that resulted from Address Book compiling nameless, and therefor what it deemed to be duplicate, contacts. This is what I came up with:
tell application "Address Book"
activate
set thePeople to every person whose first name is missing value and last name is missing value
repeat with i from 1 to count of thePeople
set thePerson to (item i of thePeople)
delete thePerson
save
end repeat
end tell
[get the up-to-date code snippet here]
AppleScript will tell Address Book to find all the contacts with no first or last name and delete them with no questions asked. If this scares you, DON’T USE IT. This cut down my contact list from 4,500+ to to about 2,300+. Good… better… but not great.
Cleanup @ Entries
One thing I can’t stand is a contact with no proper name. You are nothing to me if all I have is your email address. It especially bothers me when a contact uses all or bits of their email address as the first and/or last name, like…
first name: john
middle name: @doe.
last name: com
or…
first name: john@doe.com
So this next script looks for such contacts and indiscriminately wipes them out. If there is any question about whether the person really does have a proper first or last name, it will pause and ask… but for the most part it will just hack and slash with reckless abandon.
tell application "Address Book"
activate
set thePeople to (every person whose first name contains "@" or last name contains "@" or middle name contains "@")
repeat with i from 1 to count of thePeople
set thePerson to (item i of thePeople)
set firstName to (first name of (item i of thePeople) as string)
set lastName to (last name of (item i of thePeople) as string)
set middleName to (middle name of (item i of thePeople) as string)
set theirEmails to (value of email of (item i of thePeople) as string)
set urlList to {"com", "net", "ca", "org", "uk", "us", "fr", "it", "edu", ".com", ".net", ".ca", ".org", ".uk", ".us", ".fr", ".it", ".edu"}
if first name of (item i of thePeople) is missing value or last name of (item i of thePeople) is missing value then
delete thePerson
else if firstName contains "@" and lastName contains "@" then
delete thePerson
else if urlList contains lastName then
delete thePerson
else
display dialog "first name: " & firstName & return & "middle name: " & middleName & return & "last name: " & lastName & return & return & theirEmails buttons {"Cancel", "KEEP", "DELETE"} default button "DELETE" giving up after 30
copy result as list to {the buttonReturned, the gaveUp}
if gaveUp is true then error number -128
if buttonReturned is "Canceled" then error number -128
if buttonReturned is "DELETE" then delete thePerson
end if
save
end repeat
end tell
[get the up-to-date code snippet here]
Detect Name Switch
The next step was to sort out how many contacts were actually duplicates, only with their first and last names reversed. It’s understandable that Address Book would think such entries were unique, but you’d think the error was common enough that it would have such provisions built in and at least ask you to review what it suspects might be duplicates. Since Address Book does nothing of the sort, I had to write an AppleScript that does.
The script is too long and complex show it all here, but basically what happens is AppleScript tells address book to look for contacts whose first and last names match those contacts whose last and first names are the same. It then prompts me with the comparative information and asks me to decide if they are in fact the same. If yes, then it asks me which one, if any, that I want to delete.
This process cut another several hundred more contacts from my list.
[get the up-to-date code snippet here]
Split First Name
Something else I found regularly when going through my contacts is entires where both the first and last name would be in the first name field and the last name field entry left empty. This would also produce a lot of undetectable duplicates as the comparison of first name: John Doe to first name: John, last name: doe would obviously yield two unique contacts.
This script will search for contacts whose first names contain a space and whose last name is not present. Going on the assumption that the first and last name are both contained in the first name (hence the space), the script takes the first word and the last word and uses them for a proper first and last name. Again, it does so rather blindly, so this contact first name: Royal Bank of Canada will become first name: Royal, last Name: Canada. I need not say this again… proceed with caution.
tell application "Address Book"
(*
set first name to first word in first name
set last name to last word in first name
*)
set the thePeople to (every person whose (last name is missing value and first name contains " "))
repeat with i from 1 to count of thePeople
set theirName to (first name of (item i of thePeople))
set firstName to (first word of theirName)
set lastName to (last word of theirName)
set properties of (item i of thePeople) to {first name:firstName, last name:lastName}
set newFirstName to (first name of (item i of thePeople))
set newLastName to (last name of (item i of thePeople))
save
end repeat
end tell
This process, when combined with another duplicate search from the Address Book card menu, managed to chop out another 500 contacts.
[get the up-to-date code snippet here]
And the Winner Is?
After beating Address Book over the head with these scripts various times and after running Address Books own duplicate check after each script run I was able to cut my number of contacts from Gmail’s initial 10,000, down to 4,500+ until finally I managed to walk away from the whole fight with a clean, organized Address Book containing 1,308 cards! Ahhh… victory!
So does this make me a happy user of the Apple office apps? It’s certainly got me closer. Now that I have an Address Book that is usable, I’m now using Mail on both the desktop and iPhone and am making a real effort to get used to them both.
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 and Isolator. 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” from CodeCollector.net
Simple Web Search
Do 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” from CodeCollector.net
Launch apps by task
My 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” from CodeCollector.net
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]
Scripting LittleSnapper… Slight Return
Less then a week after writing this AppleScript — which launches LittleSnapper and snaps the website currently in view in Safari — the boys at Realmac Software come out with this bookmarklet 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 1will sometimes work - Camino is
URL of browser window 1and 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 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
[tags]applescript,littlesnapper,realmac,software,safari,firefox,opera,camino,browser,bookmarklet,hot-key[/tags]
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]

