Professional Development on a MacBook Pro

Posted by David Glassborow Thu, 12 Jul 2007 15:26:00 GMT

Like a number of people in the Delphi Community ( Steve Trefethen, Dan Miser ), and the development community as a whole, I now do all my development on a MacBook Pro. I changed to an Apple machine six months ago, for a number of reasons:

  • I needed a new laptop, and the MacBook Pro hardware is so goddamn thin, light, and good looking.
  • I am becoming increasingly disillusioned by Windows, especially the new DRM stuff.
  • I fancied trying out OSX, a change is as good as a rest and all that.
  • Bootcamp and virtualisation allow me to use Windows XP on an Apple laptop.
  • The web is freeing us from being locked into particular Operating Systems.

As a professional developer, most of my clients run Windows, and most of my native development is done using Visual Studio 2005 or Delphi 2006, connecting to SQL Server or Oracle backends. I boot my laptop into Windows to do this work, or use Parallels to run it with Mac OSX (when I got my MacBook Pro I got it with 3G of RAM so Windows runs pretty fast inside OSX). Increasingly though I am doing web development, which means I can do much more work inside just OSX.

The more I have used OSX, the more I prefer it to Windows, so I have put together this list of tools and hints for doing professional development on OSX:

Using Bootcamp

  • Steve has got an excellent list of the keyboard mapping for Windows
  • Parallels allows runs Windows (from a bootcamp partition) in OSX
  • As does VMWare

Using OSX

One of the things there first confused me using OSX is the link between a visual Window and a running program. Having used Windows for the best part of 15 years, I had the stong mental link between having a open window and having a program running. OSX is much more like the systray in a way. In most instances, a program carries on running even if all its windows are shut. At first this seems odd, but now I am actually used to Mail and iCal running in the background, collecting mail and showing me reminders, without having windows cluttering up the place or being minimised. Also the dock changes icons depending on status of the program, so I can see that new mail is waiting, without requiring an open window to tell me.

I guess it is the unix heritage, but OSX seems much happier having loads of programs running a the same time, than Windows would (or maybe this laptop has just got too much memory).

Another change from the Windows way of thinking is about installation of software. In OSX an application is a directory with a name of BlahBlah.app. It contains all that is necessary to run. So drag and drop to install software, move things around as desired, and delete it when no longer wanted. Only software that needs to make system changes needs to have install scripts.

You need to install Quicksilver for launches programs, and more advanced voodoo. Have a look at some of the screen casts at The Apply Blog, a good beginner one is here. You won’t believe for a powerful bit of software it is.

Another thing worth getting your head around is this idea of OSX services. These are simple ‘services’ that are provided to all programs running, accessible of the programs menu. While there are some useful ones built in, there really come into the own where you start changing them using Service Scrubber and This Service. See some examples from John Gruber about writing your own scripts and making them available to all apps (although I’d recommend using Ruby over Perl ;-).

Web Development

It goes without saying that you should be using Firefox with Firebug for web development. Day to day browsing I use Camino which is the firefox engine inside a more OSX integrated and looking program.

  • Textmate is a great editor, as most people know, but if you are doing any JavaScript development make sure you get the JS Tools bundle. Having your script ‘lint’ed everything you save is a great productivity improver. Also get the GetBundle bundle to make it easy to manage extensions and find new ones. Blog writing is easy with the built in markdown support.
  • Eclipse (especially with the new CodeGear betas running inside Eclipse ) has plugins to do pretty much everything (although I still use Textmate most of the time).
  • Anybody know of a Fiddler equivalent for OSX ?

Subversion

Does anybody use anything else anymore ? I use the tigris plugin scplugin to have subversion integration with the finder. It is not quite as good as tortoise. There is also Svnx which is ok, but I don’t find the UI all that intuitive.

Database Access

For connecting to Oracle, I use the free SQL Developer which has a native OSX version. Most of the open source databases have native clients (e.g. Postgres), but otherwise I use Aqua Studio v4.7 which is free. One of the nice things is most of the tools are Java based, so if you can find a JDBC package for your database, chuck it in /Library/Java/Extensions and then all the Java apps on your machine have connectivity to it (I have found ones for SQL Server, Oracle, MySql and Postgres).

Other Languages / Database Engines

  • Anything available in the Open-source world, if not explicitly released for OSX, is normally available on DarwinPorts or Fink, projects to make linux/unix software compilable on OSX (which is a unix variant behind the scenes), and easily installable handling all the dependancies etc.

Are there any useful development tools or hints I have missed ? Let me know and I’ll try and keep a development bias list here or on this page.

And if your still using boring old Windows, come and join the revolution !

Posted in , , ,  | 5 comments

Feedburner and Apache redirects

Posted by David Glassborow Tue, 05 Jun 2007 17:56:00 GMT

Looking at the load this blog is causing, virtually all of it’s requests are for the syndication feeds so I decided to off-load the network bandwidth to Feed Burner ( recently acquired by Google).

Feedburner basically checks your site every 30 minutes (you can also manually request an update) and caches the response. Rather than ask my subscribers to change the feeds source, I decided to use Apache to redirect all requests to my feeds to feedburner, unless it was actually feedburner requesting the information.

To get this to work took a bit of Apache shenanigans, so I thought I would document it here both for myself and for anyone else who needs to do the same. It is also a useful example of how powerful Apache is, particularly as a forward facing server than manages the virtual URL space and links it up to various webs server technologies and platforms behind the scenes (loose URL => implementation coupling). The blog is running on Ruby on Rails, Typo engine, running on port 4000 internally. Our firewall blocks outside access to this port, so we use Apache to proxy it for us (it rewrites any URL’s on the way out to be the correct external address). We also use it as an SSL gateway, so we setup all the certificates in just one place.

All configuration in Apache is done in the http.conf file. Here is the setup I am using for the blogs subdomain with notes of what is going on. There is also a similar VirtualHost setting for 443 (SSL Access), but doesn’t really add much by posting it here. I will give a quick summary of what is going on here, but full details can be found on the excellent Apache documentation

# Concept First blog
<VirtualHost *:80>
  ServerName blogs.conceptfirst.com
  DocumentRoot "e:/Blogs/www"
  ErrorLog "e:/blogs/logs/error.log"
  CustomLog e:/blogs/logs/access.log common
  DirectoryIndex index.html
  <Directory "e:/Blogs/www">
    Options none
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>

Tell apache which virtual host name this is for, where static files are, where to put log files, etc.

  RewriteEngine on

RewriteEngine on tells apache to apply the following rules. Apache can handle redirects and proxying using Redirect and ProxyPass directives, but I had issues with the order things were being done in, so used rewrite rules for it all. Rewrite rules are more flexible and powerful than the individual Redirect or ProxyPass directives, so its worth understanding their capabilities in full.

  RewriteLogLevel 0
  # RewriteLog "e:/rewrite.log"

If having problems debugging rewrite rules, I’d recommend just setting up a log file and turning RewriteLogLevel to 9. Turn it off by putting back to 0 when everything is working.

  # Redirect feeds to feedburner unless actually feed burner. Only do main ones
  RewriteCond %{HTTP_USER_AGENT} !FeedBurner  
  RewriteRule /xml/rss20/feed.xml$ http://feeds.feedburner.com/ConceptFirst [R,L]
  RewriteCond %{HTTP_USER_AGENT} !FeedBurner  
  RewriteRule /xml/atom10/feed.xml$ http://feeds.feedburner.com/ConceptFirst [R,L]

This is the configuration that tells Apache to redirect all my traffic to feedburner unless its from Feedburner itself.

  • RewriteCond: A condition rule, applies to the next line. It is negated by !
  • RewriteRule: A rewriting rule, with a match part (regular expression) and a target
    • [R]: Send a HTTP 302 redirect
    • [P]: Do a internal proxy
    • [L]: Stop applying rewrite rules after this one

So the first two lines tells Apache (in random syntax pseudo-code): IF (HTTP_USER_AGENT <> 'FeedBurner') AND (URL = '/xml/rss20/feed.xml') THEN SEND_REDIRECT_TO('http://feeds.feedburner.com/ConceptFirst') AND STOP_PROCESSING_RULES

Feedburner uses the HTTP header USER_AGENT set to FeedBurner so that is how we detect it and don’t redirect it to itself ! I am only redirecting my main feeds here, the categorised feeds and individual comment feeds are still handled by the blog engine.

  # Make admin secure
  RewriteRule /accounts(.*) https://blogs.conceptfirst.com/accounts$1 [R,L] 
  RewriteRule /admin(.*) https://blogs.conceptfirst.com/admin$1 [R,L]

These two lines use a similar rules to make sure the admin parts of the blog are handled through HTTPS so we don’t get any cleartext passwords floating around on the net. The $1 at the end of the redirect is the matched data from (.*) in the regular expression. So if the URL is /admin/login, $1 will be /login.

  # Proxy to mongrel for everything but the media directory
  RewriteCond $1 !^Media/(.*)
  RewriteRule /(.*) http://localhost:4000/$1 [P,L]

This is the rule that actually gets the blog pages from the internal ruby on rails app. The condition rule is checking the URL match to make sure it is not part of the Media subdirectory (this is a static directory that apache serves up, it contains images for blog entries, etc). Everything else gets passed to the server running on 4000.

  ExpiresActive On
  ExpiresByType text/html "now plus 1 day"
  ExpiresByType image/gif "now plus 1 week"
  ExpiresByType image/jpeg "now plus 1 week"
  ExpiresByType text/css "now plus 1 week"
  ExpiresByType image/png "now plus 1 week"
  ExpiresByType image/jpg "now plus 1 week"
</VirtualHost>

The Expires stuff is the Apache way of setting the HTTP expires headers when sending responses. I’ve set images to be cached on the client for a week to help reduce bandwidth and load on the server.

I greatly recommend Apache, its very easy to setup, and very powerful (although it does test your knowledge of regular expressions :-), we’ve used it to proxy Ruby On Rails, Cold Fusion, IIS and home grown web servers, and its great for rewriting URLs to make them technology agnostic and nice and RESTful.

Posted in  | Tags  | 1 comment

SQL Server Spatial

Posted by David Glassborow Tue, 05 Jun 2007 14:26:00 GMT

SQL Server 2000 has always been one of my favorite bits of software. I have written various software that runs on top of MSDE and always been really pleased with it.

Having spent a great deal of time recently working woth Oracle 10, I have really noticed how much easier administration is with SQL Server. I have also had lots of issues with Oracle drivers (in particular where CLOB fields are used).

I have to admit to being rather unwealmed by SQL Server 2005. I’m not a great fan of stored procedures (I belive the logic should be in a middle tier) and certainly not of running .net code inside a DB server.

One thing I was looking forward to was the addition of spatial algorithms to SQL Server.

Wikipedia notes that spatial data is planned for the next version, but for the mean time I will be using Oracle for my clients, and personally Postgres.

I think Microsoft really missed out here. More and more of my clients need to store spatial data, I would love to use SQL Server, but my money has to goes to Oracle or an open source database.

Pull your finger out Microsoft and make sure 2008 is spatial enabled !

Posted in  | no comments

Older posts: 1 2