Archive for the 'Mac' Category

Script and Droplet for forcing an app to run with the old WebKit

Jul 20, 2007 in Mac, Scripting

Thomas Aylott over at subtleGradient had a posting a little while ago about how to install Safari 2 on top of Safari 3 beta and open applications with the older version of WebKit. I was needing to do this a lot and his work around called for running a command from the shell every time. I thought wouldn’t it be nice to to have some quick way to do this from the finder. Also, some apps were spitting out some text to standard error in the terminal and while the “&” at the end prevented standard output from going to the terminal (by making the command run in the background), standard error was stilling being displayed. So, I wrote a bash script and turned it into a droplet with Platapus. I then created a Automator workflow that opened a selected finder item with the droplet, and saved it as Finder plug-in, which allows me to call it from a contextual menu in the Finder. Of course you can always add the app to the dock or use Quicksilver triggers or whatever you prefer at that point.

I’ve included the script code below and posted the app and workflow with this posting (to use them you will have to first follow the instructions over at subtleGradient to install Safari 2 on top of Safari 3).
(*the workflow should be installed in “~/Library/Workflows/Applications/Finder“)

#!/usr/bin/env bash

IFS=" "
filename=${*##/*/}
appname=${filename%%.*}
binpath="$*/Contents/MacOS/$appname"

env DYLD_FRAMEWORK_PATH="/Applications/Safari2.app/Contents/Resources" \
WEBKIT_UNSET_DYLD_FRAMEWORK_PATH=YES "$binpath" >&/dev/null &

Tags: , , , , , ,

Setting up Mercurial and Trac for personal version control on your Mac

Mar 07, 2007 in Mac, Web Development

So I’ve recently started my first foray in to programing a larger Rails project and need a version/source control mechanism to handle maintaining it with my collaborators. We choose to go with Subversion, and Trac. I instantly fell in love with version control! Now to you veteran programmers out there, you probably know all about this, but I’m a n00b so please excuse my excitement. So I wanted to find a way to do version control on my own machine for my smaller personal projects, and ideally use some slick interface to be able to browse the changes. I had recently read in one of the TextMate users mailing list (which I obsessively read) about Mercurial, someone was having problems with the Subversion bundle, and someone suggested if their needs were lightweight they should consider Mercurial (for which there is also a TextMate bundle). So I decided to check it out.

For those of you who don’t know about Mercurial (a.k.a. hg), It’s a distributed version control system (for a comparison on version control systems see Wikipedia), which differs from SVN’s centralized method. SVN has you commit changes to a central repository and you handle any conflicts between your copy and the current revision then. With hg you commit changes on your local machine, and then eventually you may combine it with another copy of the repo. So if you figure out a way to solve a problem that someone else is having and you’re talking about it, you can just “push” your version to them, and then they can get your fix. There’s more to it than that, but if you want more go to the Mercurial web site. So it works great, since your local copy is a full set of changes, as a personal version control system. Then all you need is a nice way to browse the revision history, in comes Trac. Now I know you could use a standard diff file/tool, or the built in web interface, but I hate the way those look, and I love the way Trac looks, just a personal preference. And lucky for us Trac has a new Mercurial plugin!

So here we are at the meat of this entry, how to set it up on your Mac. What you should already have installed is OS X 10.4 (aka Tiger), and DarwinPorts (which it’s self requires the installation of Xcode tools from Apple). Once you’ve got that set up you’re ready for my instructions:

  1. Install the following “ports”. Use the Terminal application and the commands should look like this:

    sudo port install python24
    

    and allow any dependencies they might require:

    • python24
    • mercurial
    • sqlite3
    • py-docutils
    • py-setuptools
    • py-sqlite
    • clearsilver
    • SilverCity
    • subversion
  2. Make sure your PATH is set up right in your .profile file in your home directory, test this by entering hg version in the terminal.
  3. Set up a Mercurial repository (Also see Mercurial wiki):

    1. Set up a .hgrc file in your home directory (~/). See Mercurial wiki hgrc page
    2. Navigate to your projects directory in the terminal shell.
    3. Create the repository:

      hg init
      
    4. Set up your .hgignore file to handle files you don’t want under version control. See Mercurial wiki hgignore page

    5. Add your project files to the repository:

      hg add
      
    6. Commit your project:

      hg commit
      
  4. Install Trac (you can always see the Trac wiki for help)

    1. Download Trac 0.10.x tar package
    2. Extract the contents of the archive.
    3. Navigate to the top of the directory created by the extraction.
    4. Enter the following command:

      sudo python ./setup.py install
      
    5. A good idea is to test that your PATH is working by enter trac-admin help at the command prompt

  5. Install the Mercurial plugin for Trac:

    1. Get the latest code for the plugin via the Subversion repository:

      svn co http://svn.edgewall.com/repos/trac/sandbox/mercurial-plugin
      

    You can execute this anywhere on your hard drive.

    1. Run:

      cd mercurial-plugin
      
    2. Run the following command to make the “egg” for the plugin:

      python setup.py bdist_egg
      
    3. Run:

      cd dist
      
    4. To install it globally for your install of Trac:

      sudo easy_install TracMercurial-0.10.0.2-py2.4.egg
      
    5. To activate it add this to your global trac.ini file (it should exist in this directory: /opt/local/Library/Frameworks/Python.framework/Versions/2.4/share/trac/conf, you may have to create it as it may not exist yet):

      [components]
      tracvc.hg.* = enabled
      
  6. Set up a Trac project

    1. Run a command like this to set up your Trac project (the path part should be the path where you want the Trac files to go, not where your hg repo is):

      trac-admin ~/Sites/myproject initenv
      
    2. It will walk you through a series or prompts.

    3. When it asks for type of repository type: hg
    4. It will also ask for the path to the repository give it the full absolute path that you created your repository in before (see step 3).
    5. Open the trac.ini file for the project:

      cd ~/Sites/myproject/conf/
      open trac.ini
      
    6. Add the following lines to the end of the file:

      [hg]
      # -- Show revision number in addition to the changeset hash
      show_rev = yes
      
      # -- Changeset hash format
      node_format = short
      # hex:   Show the full SHA1 hash 
      # short: Show a shortened hash for the changesets
      
    7. You may wish to further customize your trac.ini file, if so see the Trac wiki page on it.

  7. Make changes, commit changes, run Trac Standalone Server, repeat:

    1. Make changes to your project files.
    2. Commit the changes, you can either do: hg commit. Or you can use the Mercurial bundle for TextMate.
    3. Run the Trac standalone server, by entering this command in the terminal:

      tracd --port 8000 ~/Sites/myproject
      
  8. Enjoy!

Tags: , , , , , ,