Wishful Coding

Didn't you ever wish your
computer understood you?

Open external links in running browser

Open external links in running browserAs a web developer I have like 5 browsers installed which I use regularly. That is, not on daily basis, but for occasional testing and browsing. What annoys me most about this is that when I click a link in another application, no matter what browser I'm currently running, it opens a fresh Safari window. The ideal solution would be to open any urls with the browser I'm using at that moment, no mater which browser that is and which one is set as the default browser. I have written a piece of Applescript that will do just this, you might need to edit this for the browsers which you are using though. Below you'll find a zip file containing the app bundle, and all the scripts needed to generate it yourself.

Browser Loader

To edit the browsers you use, open "/Applications/Utilities/AppleScript Editor.app" and then open the app bundle, this will reveal the script below, where you can make adjustments to the browsers used and their order. If you want do do this yourself, or the app bundle does not work for you for some reason, this is the actual Applescript I used:
on open location the_url
        tell application "System Events"
                set browser_apps to the name of every process whose visible is true
                if "Opera" is in browser_apps then
                        tell application "Opera"
                                open location the_url
                                activate
                        end tell
                else if "firefox-bin" is in browser_apps then
                        tell application "Firefox"
                                open location the_url
                                activate
                        end tell
                else if "Google Chrome" is in browser_apps then
                        tell application "Google Chrome"
                                open location the_url
                                activate
                        end tell
                else
                        tell application "WebKit"
                                open location the_url
                                activate
                        end tell
                end if
        end tell
end open location
Open external links in running browserCopy this file to the Applescript editor and hit Save, before you save, choose to save as an app bundle and make sure to check the "Stay Open" box. Now we need to modify the app bundle to make it eligible for url opening. To do this, right-click on the app and select "Show Package Contents", go to "Contents" and open "Info.plist". Edit "Info.plist" to contain this xml code within the outer dict element. For an example, download the app bundle above.
<key>CFBundleIdentifier</key>
        <string>nl.pepijndevos.urlhandler</string>
        <key>CFBundleURLTypes</key>
        <array>
                <dict>
                        <key>CFBundleURLName</key>
                        <string>Applescript urls</string>
                        <key>CFBundleURLSchemes</key>
                        <array>
                                <string>http</string>
                                <string>https</string>
                                <string>file</string>
                        </array>
                        <key>LSIsAppleDefaultForScheme</key>
                        <true/>
                </dict>
        </array>
Now, when you click an url it will just open your browser. I'm not sure what to do exactly, but here is what I did
  1. Run the app once
  2. Set it as the default browser in Safari
[update] Using Linux? Try this script on Humbug.in This script has also appeared on lifehacker.com download.com and maxosxhints.com

Top 5 multi-protocol IM clients for Mac

Among the few applications I use constantly is my IM client. Just like my web browser, I constantly seek better and faster IM applications. With browsers there are a few big ones and everyone knows them, for IM on Mac however, you have to take a close look to find something that suits your needs. Since I've done a lot of this searching, I'm going to do a list of my favorites. If I missed your favorite, pleas leave a comment.

Top 5 multi-protocol IM clients for MacAdium

One of the most used IM clients on Mac. Adium is an application based on the same technologies that power the popular Pidgin client, but offers a native Cocoa interface and a wealth of plugins and customizations, listed at their extras pages. The 1.4 beta supports some additional cool features, but due to a lack of manpower is still not done. I recommend using the beta, as it is quite stable.

Top 5 multi-protocol IM clients for MaciChat

The chat client included with Mac OS X, it supports only the XMPP and AIM protocols, but I consider it one of the best if you don't need other protocols. It is possible to use other protocols via a XMPP transport, but this very is unreliable at times.

Top 5 multi-protocol IM clients for MacTrillian

Is a well known Windows client that has recently released an alpha version for Mac. It is not very feature rich yet, but it looks and works nice so far. One downside of Trillian is that it stores your credentials in a central account on their server, one of the upsides of Trillian is that it stores all your credentials in a central account, which is cool if you use Trillian on multiple computers/phones.

Top 5 multi-protocol IM clients for MacPidgin

This app is mainly aimed at Linux and Windows users, but with a little help of my previous post you can get it to work on Mac quite nicely. It uses the same technology as Adium, but due to a broader audience it might offer some features not currently present in Adium. Only use this if you know you need it, Adium has a nicer interface on Mac.

Top 5 multi-protocol IM clients for MacYahoo Messenger

Contrary to what you might think Yahoo also supports WLM, provides a good Mac look and a full set of features, unlike some other branded clients. It's not the ideal thing though for the real IM diehard.

Conclusion

I'd go with Adium if you're a regular user, or iChat if you don't need any of those networks. For the experimental people, Trillian and Pidgin might be good options. For the social network people it might be worth waiting for Raindrop or Digsby. For the WLM oriented minds, the official WLM client, Mercury and aMSN might be of interest.

display: inline-block; tricks

In most cases where you want to have a set of items on one row, you use floats to make things work. The truth is, floats are not meant to do this and they create all sorts of strange behavior, even in good browsers if you don't know what you're doing. This article tells an interesting story on how you could use inline-block in all major browsers. I want to add a few tricks to the mix I learned in the past few years. Use case 1: You want a horizontal menu with more items than fit on the screen, but with a flexible width. Floats are not up to the job; They would just wrap to the next line instead of creating a scrollbar. Use case 2: You want to center something vertically. You could use a mix of position and margin statements to achieve this, but not if you don't know the width and height of the object. Since the elements are in the text flow now, we can apply text-specific CSS! The first example is achieved by setting whitespace: no-wrap; and overflow: auto; which makes all the items stay on one line and create a scroll bar. The second example is achieved by adding &zwnj; before the item to make it behave like a real line of text, that has vertical-align: middle; applied to it.

Examples