Mac OSX Snow Leopard has revived the Services menu.
I’ve implemented a really simple Service called “Open Terminal Here”. It’s a small service which becomes available in the context menu of every file and folder in the Finder with an entry called “Open Terminal Here”.
It’s function is really simple, it activated the Terminal application and changes the current directory to selected directory or the containing directory, depending whether you selected a file or folder.
The linked zip file contains a file named: “Open Terminal Here.workflow”
If you would like to change the name appearing in your services menu, just change the name of the file to something else. make sure the extension remains the same. For example: “Any other Name.workflow”.
After you are happy with the services name, copy the resulting file to the directory “Library/Services” in your user’s home directory. Now you can open a Terminal window at the location you’ve just selected, it works for multiple selections too.
Here’s the link to the zip file: Open Terminal Here 0.3.zip
Oh just a little tip, to open the current Terminal.app path you’re at into a Finder window, just type “open .” followed by a return. (Yes, that’s 4 characters, a space and finally a dot.)
Some people have reported some issues while installing this service. Please see the comments for a workaround by j.g. Owen.
-Fixed the multiple window problem (courtesy John-Michael Glenn)
-should fix a localization problem.
I’ve also created a SVN repository for this little bit of code: http://leenarts.net/svn/opensource/Open%20Terminal%20Here/
When asked for a username and password, just enter empty strings.
At my company the sysadmins provide a little service when putting all phone numbers of colleagues on my cell phone. Every colleague is prefixed with a dot. My car’s carkit though lists all numbers grouped by alphabet. So this leads to like a couple hundred entries grouped under a single dot. Fortunatly I can sync my phone to my Apple’s Address Book. When it’s in there, the following little AppleScript allows me to change all first names starting with a dot to something without a dot.
First I transfer all dot-prefixed entries to a special group, then this script runs the people in that group through a little check and adjustment when needed.
(The syntax of AppleScript is a real pain.)
on lstripString(theText, trimString)
set x to count trimString
repeat while theText begins with the trimString
set theText to characters (x + 1) thru -1 of theText as text
tell application "Address Book"
set infoSupporters to people of group "InfoSupport"
repeat with p in infoSupporters
if first name of p starts with "." then
set new_first_name to my lstripString(first name of p, ".")
set first name of p to new_first_name
display dialog "Done!"
According to the MacPorts port command man page the option -u: “uninstall non-active ports when upgrading and uninstalling”.
Just running port upgrade all the time litters your systems with lots and lots op old archived versions of installed ports.
To correct this whole mess you could run “sudo port -u uninstall”. This should uinstall any archived versions you might have. You might need to add a -f to that to make it work: “sudo port -uf uninstall”.
You might have some trouble when you force a removal like this when one of your installed ports is linked against an older version of a library. This can be fixed by replaying some steps on this page.
Basically this post is a reminder for myself. But just maybe someone might find this useful too.
Yesterday TrueCrypt version 5.0 has been released. Nothing special you might say, but then again, you might not be running Mac OSX. TrueCrypt has been released for the Mac as well. The cool thing about it is that it uses MacFuse.
Download TrueCrypt here.
You will find several options suitable for your system.
MacFuse is a kernel extension for the OSX operating system allowing mounting of file systems in user space. With MacFuse a user can mount a file system dynamically without needing super user privileges. MacFuse is based on the original Fuse kernel extension for Linux based operating systems. With MacFuse/Fuse you can do cool things like an mounting a remote file system over SSH, a screenshot file system dynamically generating screen shots of all active windows on your desktop or just about any other piece of data that can be mashed in to a hierarchical layout or read/write NTFS file systems. You probably think this is boring. But the thing is, it’s all dynamic. Without MacFuse I guess implementing TrueCrypt for Mac would have been a whole lot harder.
With the release of the latest TrueCrypt using a secure portable drive is finally a decent option for me. Sure OS X already has the concept of secure DMG files. But those are kinda Mac only. And I have to be able to carry stuff between my Mac and several Windows machines.
One word of caution though, remember that you do need to make some form of back-up of all your encrypted data. Back-up the individual files or the entire encrypted disk image. Because if only one bit falls over in your encrypted disk, the entire disk will be corrupted. Correction supplied by Honza in the comments. The behaviour of TrueCrypt is more like a real hard drive. If a bit falls over, only the file containing the tainted section will fail.
I was trying to forward a message. One with loads and loads of replies. Really in the order of dozens of replies on replies.
Aaaaanyway… I thought, what the heck I'll give Apple Mail some time.
And there Apple Mail was munching away… ..on my internal memory that is!! After about 10 minutes or so Apple Dumped on me. Turns out the Kernel identified Apple Mail as a run-away procces.
Luckily, I had taken a snapshot with the Activity Monitor…
Now look at that screwed call stack. Something was definatly going up the recursion tree.
Analysis of sampling pid 700 every 10.000000 milliseconds
300 -[NSApplication run]
300 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
300 -[MainThread handlePortMessage:]
300 -[NSInvocation invoke]
300 khtml::Selection::Selection[in-charge](DOM::Position const&, khtml::EAffinity)
etc, etc, etc… (You get the idea here?)
How I resolved this you say? Well, the weird thing was that Apple Mail was able to start and just show me the offending mail. Only when I tried forwarding OR replying things got ugly. I went into the Mail folder in my Library to VI my way out of it. As in locate the emlx file of that particular mail and "dd" the crap out of it to cut it down to size a bit. Then everything worked again in Apple Mail. All things went sunny again. (I do have the original message lurking on my pop box. So if any OG Apple engineer wants to look at it. Pleeeeeeease do contact me.
Man, am I having hard times with Rails and
DarwinPorts MacPorts or what? The strangest things keep happening. My Rails install broke down again. Imagine my frustration. I’ve been messing around with it for a few days now. And trust me, nothing wrong with rails. This time it was an incomming update on a support library called gettext. Argh!! On itself nothing wrong with updates, and that stuff breaks because of it, fine. But not all in one week please.
In hindsight the fix was real simple.
- sudo port uninstall [insert anything starting with rb-]
- sudo port install rb-rails
Oh and another one if you would want to use rb-sqlite3 on Rails. Install swig before installing the sqlite adapter. And don’t forget, in your database.yml: adapter: sqlite3 Yes, with a three that is.
Just a sidenote: I officially fell in love with TextMate. This editor is soooo cool. Thank you very much MacroMates.
I haven’t finished the book yet, I’m about half way through. But so-far it’s a great book about an excellent part of Mac OSX.
The book details how you should use Quartz 2D and Core Image. Quartz 2D is a central piece in the graphics development on Mac OSX. The thing with Quartz 2D is the fact that it is resolution and color independent. And this book really hammers it down. The interesting thing to me is the fact that Graphics 2D in Java is also resolution and color independent. This resolution and color independence makes it possible to program in a device independent manner. The “device” can be the screen, a memory bitmap, a PDF file/memory structure, a printer or anything else which is capable of displaying or producing graphics. The end result of this is that you only have to write your drawing code once without any device specific intricacies. There are a few things to keep in mind in a few exceptional cases, but that’s usually not a problem at all.
The book doesn’t seem to contain a lot of code. Most of the time it shows a few snippets to get a point across. But every listing comes with a number which references a file on the accompanying compact disk. Excellent stuff, you see something interesting, you want to fiddle with it in an editor anyway. So why waste precious page space? I personally hate it when books are half code, half actual text. Quartz 2D graphics on the other hand strikes just the right balance to me.
This books also goes into Core Image. Core Image is a framework on OSX which allows programming of the systems graphics card. If the graphics card does not support such actions Core Image provides a soft alternative, which is a lot slower offcourse.
“Ghee whiz… That was taking mighty long” I thought, “Why has my PowerBook been compiling and compiling for over 30 hours now?”
Then I remembered the command I entered to upgrade all installed MacPorts. I should have used installed instead of all. *Sigh!* I’ve just deleted my entire MacPorts install because I think it’s easier for me to actually just reinstall the few MacPorts I use.
MacPorts is a toolset for Mac OSX which allows you to get loads of unix tools ready and ported for the Mac OSX operating system. It’s a bit geeky, but it sure beats having to install everything by hand and hope you didn’t miss a mac specific patch.
While I’m not feeling very good today, I have a headache again, one can only stay in bed for so long. So while browsing around a bit (http://www.opensolaris.org/os/ to be exact).
I stumbled upon some very positive news from the Apple Word Wide Developers Conference (WWDC). According to ZD-NET Australia the next release of Apple OS-X, Leopard, will support DTrance. It also gets an Apple work-over, so it will probably look and feel good too. Take a look at the bottom of Apple’s Leopard preview page. Apple will include a tool called XRay which will leverage DTrace to provide its functionality. Knowing Apple this will probably mean that the original tool will be included as well.
For those who are wondering what DTrace is. Well, it’s a comprehensive dynamic tracing framework. DTrace provides a powerful infrastructure to permit administrators, developers, and service personnel to concisely answer arbitrary questions about the behaviour of the operating system and user programs.
“What?” you might say… well it comes down to this:
- dynamically enable and manage thousands of probes
- dynamically associate predicates and actions with probes
- dynamically manage trace buffers and probe overhead
- examine trace data from a live system or from a system crash dump
- implement new trace data providers that plug into DTrace
- implement trace data consumers that provide data display
- implement tools that configure DTrace probes
(Source: http://www.opensolaris.org/os/community/dtrace/, you can find a more detailed description of DTrace there as well.)
Let’s just say, seeing is believing. Once you see DTrace in action, you’re hooked.
I’ll be taking over a few tasks while a colleague of mine is taking some well deserved R&R. The thing is, I’ve heard it involves Python. *sweet* 😉
That does mean I’ll be scrapping my Ruby experimentation, because I have to brush up my Python skills a bit. It’s been a while since I’ve done any serious Python coding.
If you’re looking into Python too, start here. Oh and, MacOSX 10.4 comes with Python 2.3.5 pre-installed.