%CD% – the pwd for cmd/dos on Windows

September 17th, 2010 by jason.nah

cmd promptHave you ever wondered what the cmd equivalent for the unix command pwd?

To those unfamiliar with pwd, it’s a UNIX shell command you type on a terminal screen to get the Present Working Directory (pwd). Why is this useful? Well it can be used as a shortcut for operations on the current directory you’re in. It’s also useful when it comes down to calling shell scripts and passing directory refences around to properly locate other files that you expect in specific locations relative to the present working directory.

So what’s the cmd equivalent?

%CD%

Open Windows Explorer
Ever been stuck in the terminal screen and wanted to open Windows Explorer in the current director? This command will save you multiple mouse clicks and help you visualise the directory quickly.

explorer %CD%

If you run explorer on the command prompt, it opens Windows Explorer but doesn’t navigate to the spot where your directory is. I have found this to be a great annoyance and just not that useful. Passing in a directory will cause explorer to open that directory up. This is a little more useful, but the folder view in XP seems to be hidden. You have to click on folders to see something useful.

So, to address this, run this instead

explorer /e,%CD%

The /e argument causes explorer to open in its default view. A comma is needed to delimit arguments to the explorer program. This opens the explorer in a much more familiar view. If you’re after more options, check out the following page on the command-line arguments for Explorer.exe.

  • Twitter
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Posterous
  • DZone
  • Technorati
  • LinkedIn
  • Facebook
  • email
  • RSS

Making Snow Leopard (10.6.3), PostgreSQL 8.4, RVM and TextMate Play Nice

September 15th, 2010 by jason.nah

Finder IconGreat, you just bought a new mac to replace your old, sluggish machine that keeps running out of space. Now comes the joy of migrating to a brand new spanking machine. These are the key steps that I took to migrate. In the midst of my journey, I didn’t find one consistent spot which had all the information I needed. So, to help those that may be doing what I did, here are my steps to get my tool stack back up and running….

Step 1: Use Migration Assistant

The mac tools make it easy to migrate from one machine to another and the tool to use is Migration Assistant. There is just one caveat – on your new machine, make sure you run Migration Assistant as part of the install process. This is incredibly important, as it allows the installer to copy the entire user from your old machine to the new – complete with .bash_profiles and .bashrc files and all. If you fail to do this, you can end up in a real mess. I did. In fact, I ran Migration Assistant, and tried to overwrite my current user – bad idea. I had to reinstall Snow Leopard.

Once you have selected the directories to move, let the tool take care of the rest. By in large, you will usually select most things. You may decide to omit Applications (as I did) and reinstall your applications from scratch. This is usually a better outcome.

Step 2: Install Applications

Now you have all your data, you need to reinstall your key applications (TextMate, Quicksilver, Firefox etc). This is fairly straightforward – and will test your memory to find all those license keys you need to reinstall each piece of software!

In this phase, don’t install Postgres using the DMG image as provided on the postgres site. The dmg contains a 32bit compiled version which will run on Snow Leopard but doesn’t work with trying to build libraries against it, since much of the building mechanisms require 64bit libraries.

Step 3: Install XCode 3.2.2

The XCode toolset is required to build any native software on the mac. It comes with gcc and other tools which makes building things from source a lot better. Make sure you get v3.2.2 since the version that ships on the Snow Leopard disk has a bug in it.

Head to http://developer.apple.com/technologies/xcode.html and click on Mac Dev Center -> XCode 3.2.2 and iPhone SDK 3.2. If the link sends you into a spin (it did for me), then go the iPhone Dev Center and click on the same link. You just need XCode 3.2.2. You will be required to register in order to download the SDK. Once you have it, install it.

Step 3: Re-install MacPorts and Install Postgres8.4

I had MacPorts running on my previous system. That won’t do you much good now if you’re coming from a 32bit environment. To remove MacPorts, run this:

sudo rm -Rf /opt/local

This will remove the MacPort binaries. Head over to http://distfiles.macports.org/MacPorts/ to download the MackPorts-1.8.2-10.6-SnowLeopard.dmg file and install that. Then install the following:

sudo port install wget
sudo port install postgres84 postgres84-server

This will download the dependencies, and the source files, compile and build the binaries appropriate to the current OS platform you are running. Installing wget gives you the similar tools on unix (it’s a curl equivalent). It also installs a number of useful dependencies. At the end of the install, you will need to run the following to complete the installation.

Create the postgres user (if you haven’t got one already) and run the following to setup the defaultdb for postgres:

sudo mkdir -p /opt/local/var/db/postgresql83/defaultdb
sudo chown postgres:postgres /opt/local/var/db/postgresql84/defaultdb
sudo su postgres -c '/opt/local/lib/postgresql84/bin/initdb -D /opt/local/var/db/postgresql83/defaultdb'

Then you will need to install postgres as a service:

sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql84-server.plist

Edit your shell profile and append postgres binaries to your path. The binary files live here:

/opt/local/lib/postgresql84/bin

Now fire up postgres as a service by running:

sudo launchctl start org.macports.postgresql84-server

To test postgres is install and running propertly, first, ensure that your current user has administrative privileges over postgres, run the following:

createuser --superuser  -U postgres

Then test that you can create a new database:

createdb test_db
psql test_db

You should see positive confirmation that you could login to the test_db instance. Now drop the database:

dropdb test_db
psql test_db

The last statement should show that there is no such database called ‘test_db’.

Step 5: Install RVM
RVM is a tool which allows you to switch between ruby environments. I use to do my own hot switching using symlinks and shell commands, but this tool takes care of everything in a very neat package.

The RVM install is relatively straightforward. I chose to install it as a user, making it easier to remove if required. I followed the RVM installation instructions as provided, with the following notes:

  • I installed it as a user – to make it easier to remove later if required.
  • I had to alter my .bash_profile and just appended the command to source $HOME/.rvm/scripts/rvm

Step 6: Making TextMate use RVM
My editor of choice is TextMate, which has internal support for Ruby and for running Ruby Unit Tests. Most of this magic requires you to tell TextMate where your Ruby runtime is, and the rest works fine. This causes TextMate to require the right files, and you should then be able to run Ruby tests directly with TextMate using CMD-R.

However, TextMate wasn’t really “designed” to handle multiple Ruby runtimes easily. Thankfully, as of 0.1.45 of RVM, you can simply get TextMate to point TM_RUBY to a pre-specified script.

There were two key things that need to do to get TextMate to play nice:

  1. Set TM_RUBY to ~/.rvm/bin/rvm-auto-ruby
  2. Rename /Applications/TextMate.app/Contents/SharedSupport/Support/lib/Builder.rb to something else

These TextMate-RVM integration instructions provide the detail of what needs to be done.

After all that, you’re done! Snow Leopard, PostgreSQL, RVM and TextMate all under one roof.

  • Twitter
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Posterous
  • DZone
  • Technorati
  • LinkedIn
  • Facebook
  • email
  • RSS

Book Review: Agile Project Management With Scrum

October 6th, 2009 by jason.nah

Over the last month, I had the opportunity to read “Agile Project Management With Scrum” as a follow up book to “Agile Software Development with Scrum”. Unlike “Agile Software Development with Scrum”, this book focuses more on the practice of project management using the Scrum Methodology, giving particular insight in terms of how to apply the Scrum principles in a concrete and useful manner. Here’s a quick summary of what I found useful…

Good Points

  • Useful templates and examples help highlight how to run the Scrum methodology.
  • Appendix on “Rules” is useful, providing concrete guidance on how to execute various Scrum PM practices including Sprint Planning, Daily Scrums and Reviews.
  • Core principles are clearly spelt out and illustrated, giving a feeling of how Scrum works in reality.

Bad Points

  • I found the dummy company names examples annoying and detracting.
  • It does seem like it repeats a little from the initial “Agile Software Development with Scrum”.
  • Twitter
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Posterous
  • DZone
  • Technorati
  • LinkedIn
  • Facebook
  • email
  • RSS