Archive for the ‘Cool Hacks’ Category

Replacing AppleScript with Ruby

Thursday, May 29th, 2008

I had a brief run-in with AppleScript trying to overcome an OS X terminal bug.  and its not something I enjoyed.  I would much rather be able to do scripts like this in a language I’m more comfortable in like ruby.  I’ve known for a while that one of the enhancements in OS X Leopard is that it has native support for scripting the UI from within other scripting languages like python and ruby, however, I didn’t realize that I could drop those scripts in the user scripts folder (~/Library/Scripts) and have them available from the scripts toolbar icon. (more…)

Using Capistrano without source control

Sunday, January 27th, 2008

I’m in the process of writing some capistrano recipes to make deploying to Amazon’s Elastic Compute Cloud (ec2) easier. Since I’m making this project available for general consumption, I wanted a way to make it easy for someone to try it out without having to check something into source control. (more…)

Running eclipse with GTK on Mac OSX

Monday, August 22nd, 2005

So, the eclipse performance on OSX was bugging me enough that I decided to try getting the eclipse GTK port running on OSX. The idea being that eclipse GTK runs pretty good on linux these days, so it should run similary well on OSX.

So, the eclipse performance on OSX was bugging me enough that I decided to try getting the eclipse GTK port running on OSX. The idea being that eclipse GTK runs pretty good on linux these days, so it should run similary well on OSX.

Well, I was partially right. While it does run a lot faster than carbonized eclipse, there are a bunch of UI glitches that make it less usable for me. I’m hoping that if I document how I got it to work, maybe someone else can do the grunt work of trying out other alternatives that may fix the problems I am having. If you do, I’d appreciate the feedback.

First some pre-requisites. You’ll need to have a X server installed and the gtk libraries. I’m using the Apple X server (from OSX 10.4 install CD), and used fink to install all the gtk libraries I needed - in fink-commander, install everything with gtk+ in the name.

Next, get the eclipse linux-gtk 3.1 release and extract it to the directory of your choice (I used /Applications/eclipse-swt. This makes for an easy starting point since I didn’t feel like creating a new eclipse port and building from scratch.

There are really only 3 native components we need to worry about replacing, two of which are optional. The launcher we can bypass by using java to launch eclipse, and the org.eclipse.core.resources.linux only improves filesystem performance, defaulting to java.io.File if the native library is not present. The only one we really need to do anything for is the swt plugin. Fortunately, one of the eclipse developers recently ported/compiled the swt-gtk libraries for OSX, and you can fetch them from here.

Now you need to extract the swt plugin into a directory of the same name:

cd <eclipseInstall>/plugins; unzip -d org.eclipse.swt.gtk.linux.x86_3.1.0 org.eclipse.swt.gtk.linux.x86_3.1.0.jar

Remove the jar when you are done. Next you need to copy the osx-swt-gtk *.jnilib files from the above download into the directory you just created. I also deleted the existing binaries from that directory to be safe.

Finally, to run eclipse, you have to use the command line to run the java launcher directly. Make sure your X server is running, and the shell you are running from has the DISPLAY=:0 environment set. Then the command to run eclipse is

java -cp <eclipseInstall>/startup.jar org.eclipse.core.launcher.Main -clean -os linux -ws gtk -arch x86 -vmargs -Xmx512M

Note that I specified linux/gtk/x86, which seems counter intuitive, but thats the download we started from. Also, you probably don’t want to use an existing workspace, so pick an empty directory for your workspace location.

Now, assuming I didn’t miss anything (let me know if I did), your eclipse should fire right up using swt-gtk.

Issues I have

  • Dialogs are all weird sizes/layouts, no idea how to fix them. Especially broken is the Find dialog (ctrl-f in an editor)
  • Related to dialogs, but more annoying to my work habits, the ctrl-f6 used for switching between editors is unreadable because its too small.

Things to do

  • Billy Biggs (eclipse guy who made the binaries) mentioned on eclipse.platform.swt newsgroup that fonts may be to blame, could be worth investigating.
  • Try a different X-server, maybe a more recent build of Xfree/Xorg from fink or darwinports would fix some of the dialog issues
  • Try some different window managers - I only tried the built in apple one and gnome-metacity, both exhibited same funky dialogs
  • If other issues are resolved acceptably, might be worthwhile to do the full macosx/gtk/ppc port using the eclipse source distribution. At the very least, the core.resources binary from linux/gtk/x86 should be recompiled in the same way swt libs were so that we don’t suffer when doing a workspace refresh.

Hosting your own domain (Part 1)

Friday, May 20th, 2005

A quick HOWTO on the configuration of this site, and how I host my own domain over my cable modem to provide it.

This machine is actually my mythtv box which is serving dual pupose to host my domain. Seems to handle the load ok, but don’t slashdot me or I’ll miss my scifi channel. Actually, I’m more worried about my wife missing one her shows, that would truly be a disaster! ;)

Here is a basic description of my system. If you have a similar setup (or want one), then the rest of this article may prove useful. Its been a while since I set all this up, so I may be lacking some details. Feel free to correct me as needed, or suggest a better way to things.

  • Fedora Core 2
  • Apache 2.0.x
  • Tomcat 5.0.x (jdk 1.4.2.x)
  • Postfix SMTP/Dovecot IMAP/Squirrel WebMail
  • Pebble blog software 1.6.x

First you need to register a domain - I used GoDaddy to register mine, but any registrar should work just fine. The hardest part is coming up with a good name that hasn’t already been taken.

Next you need someone to host your domain by providing DNS service for it. I use ZoneEdit because its free for up to 5 domains and does the job for me. A google search for “free dns service” will give you lots of choices. Once you sign up for an account, you need to create an entry for the domain name you chose above. The service should then tell you what DNS servers to use at the registrar for your domain (godaddy), so go back there and edit your domain to contain these DNS servers.

One pet peeve of mine is that the top level domain should resolve to the homepage rather than requiring the www prefix. Fortunately, this is the default behavior zoneedit, and it also defaults to adding a CName alias from www.yourdomain.com to yourdomain.com

Zoneedit also provides a mail service that will forward any address at your domain to a given email address. I prefer to host my own mail server (of course ;), so I disable this service and add a MX record from mydomain.com to mydomain.com. This way I can run my own SMTP/IMAP/Webmail servers. This may be too much for most sane people ;-)

You then need to setup any dynamic dns client to update your record in zoneedit whenever the IP address of your machine changes. I use ddclient on linux to do this, and it is setup as a daemon which checks every few minutes to see if the IP changes. This way I never have to worry about updating it manually because so long as my machine is on, zoneedit will have its correct IP. The custom part of my ddclient.conf config file looks like:

protocol=zoneedit1, 
server=www.zoneedit.com, 
login=myzoneeditlogin, 
password=somethingsecret 
yourdomain.com,yourotherdomain.com

At this point everything should be setup to resolve your domain name to your machine. However, it can take few days for zoneedit/godaddy/dns to do the initial sync up, so don’t be alarmed if you can’t resolve your domain name to your ip address right away.

Thats all for now. Part 2 will contain the configuration of my server software - apache/tomcat and postfix/dovecot/squirrelmail

Setting up eclipse for painless upgrades

Friday, April 8th, 2005

I’m always upgrading to the most recent development build of eclipse, and having to manually migrate my plugins each time is a PITA. Life became much easier when I setup an eclipse Extension Location to house just my plugins so that upgrading becomes the simple task of unzipping the new eclipse distribution.

Creating an extension location works under both the 3.0.x and 3.1.x releases of eclipse, under both linux and windows (and I assume all others). The steps to accomplish this under linux are as follows:

  1. As root, I install eclipse to /opt/eclipse
  2. As myuser, I create the directories
    • ~/eclipse-config
    • ~/eclipse-config/eclipse
    • ~/eclipse-config/eclipse/features
    • ~/eclipse-config/eclipse/plugins
    • ~/eclipse-config/workspace
  3. I edit ~/eclipse-config/eclipse/.eclipseextension to contain:
    	name=My Eclipse Configuration
    	id=my.eclipse.configuration
    	version=1.0.0
    
  4. As myuser I install plugins/feature to ~/eclipse-config/eclipse (manually or through eclipse update mechanism after step 6 completed)
  5. As myuser, I start eclipse like “/opt/eclipse/eclipse -data /home/conway/eclipse-config/workspace -vmargs -Xmx512M”
  6. In Help->Software Updates->Manage Configuration… I “Add an Extension Location” to ~/eclipse-config/eclipse. The setting for this ends up being stored in ~/.eclipse

The thing I really like about this method is that aside from installing the eclipse runtime as root, I never have to do anything else as root again - I can install all my plugins as myself in my home directory, and when it comes time to upgrade eclipse, I don’t have to deal with moving my plugins to a new install - I simply install the new eclipse into it own directory, run it, perform step 6, and all my plugins are present (assuming they work across eclipse versions =)

Also, for large multi-feature/multi-plugin extensions like the eclipse WebTools Project, I’ll create a new extension location just for that extension so that I can treat it as a single unit for enable/disable/upgrade.

The process under windows is identical except you don’t have to worry about user permissions, and you need to choose windows paths that make sense to you. I use c:\devtools\eclipse for my eclipse install and c:\devtools\eclipse-config for all my configuration.