Archives
Admin / Logout

Adam Merrifield

a picture of me
I am a web designer, theme designer, professional photographer and internet personality. I make many pretty things and I write a lot of content for the internet.

I am one of those guys that, because of the industry I am in, need to be connected at all times. At any given moment you'll find me posting on a forum, updating with twitter, Digging things worthy of attention, uploading pictures, or tagging cool sites.

here i am

seyDoggy Systems:
This is home base, the corporate headquarters, the hub, if you will, seyDoggy.com.

seyDesign news:
these are the RapidWeaver related posts that originally appear in the seyDesign.com blog

Uploads from seyDoggy:
these are the pictures that I upload to flickr

Merrifield Photography:
as a professional photographer I my camera ready at Merrifield-Photography.com.

delicious.com/seydoggy:
these are the websites I want to share or revisit later on. I just tag them on delicious.com.

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 TextMate or Terminal), and somehow I have managed to etch out a living doing so.

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:

<a href="#note_091027194043">See this note</a>
<div id="note_091027194043">
    This is the special note I wanted you to see.
</div>

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” 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” from CodeCollector.net

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

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 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

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&amp;oe=UTF-8&amp;hl=en&amp;q=this%20or%20that&amp;client=qsb-mac&amp;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

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” 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]

| Trackback

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 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 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]

| Trackback

I am making fish tonight! mmm…

Broiled Talapia Parmesan

Shared by DaveT8

Category: Dinner
Cuisine: American
Serves: 8

 

Ingredients

  1. 2 lbs talapia fillet
  2. 1/2 cup good quality parmesan cheese
  3. 1/4 cup butter softened
  4. 3 Tbs mayonnaise
  5. 2 Tbs fresh squeezed lemon juice
  6. 1/4 tsp dried basil
  7. 1/4 tsp black pepper
  8. 1/8 tsp onion powder
  9. 1/8 tsp celery salt

Directions

  1. In a bowl combine cheese, butter, mayo, lemon juice.
  2. Preheat broiler.
  3. Season fish with herbs and spices.
  4. Arrange fillet in a single layer on a foil lined broiler or baking pan.
  5. Broil fish a few inches from heat about 2 to 3 minutes on each side.
  6. Remove fish from oven and liberally cover with cheese mixture over top of fillets.
  7. Return fish to broiler and broil several more minutes or until topping is browned and fish flakes easily
  8. Be careful not to over cook fish.

Search, share, and cook your recipes on Mac OS X with SousChef!

[tags]fish,talapia,dinner,recipe[/tags]

| Trackback

Slow Cooked Pulled Pork

Ingredients

  1. 5-6 lb. pork shoulder/pork butt
  2. 1 medium onion, thinly sliced
  3. 1 cup ketchup
  4. 2/3 cup apple cider vinegar
  5. 1/2 cup brown sugar
  6. 1/2 cup tomato paste
  7. 3 tbsp Worcestershire sauce
  8. 3 tbsp mustard
  9. 2 tsp paprika
  10. 2 tsp garlic powder
  11. pinch cayenne pepper
  12. 1 1/2 tsp salt
  13. 1 1/2 tsp ground black pepper
  14. 3/4 cup water

Directions

  1. Place onion on the bottom of your slow cooker. Place pork shoulder, trimmed of any obvious excess fat, into slow cooker on top of onions.
  2. In a large mixing bowl, whisk together all remaining ingredients to form the barbecue sauce. Feel free to adjust salt and pepper to taste, if necessary. Pour half of the sauce over the pork and cover. Set remaining sauce aside.
  3. Cook over low heat for about 8 hours (or according to your slow cooker’s presets).
  4. Remove pork to a large bowl and shred with two forks. Transfer meat back into slow cooker and cook for a few more minutes, until meat has soaked up the sauce. Pulled pork can be held on the “warm” setting in the slow cooker for serving.
  5. Serve on soft sandwich rolls, topped with extra barbecue sauce.

Search, share, and cook your recipes on Mac OS X with SousChef!

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