Easy Text File Conversion on the Mac

Like a lot of other web developers, clients provide me content for their sites/applications in all sorts of formats, and it can get a little crazy. But it turns out that a little terminal utility on the Mac can help the stress of text file conversion.

The utility is called textutil and you can access it by going into your Applications > Utilities > Terminal, running Terminal, and then typing textutil. If you type the command without any arguments you’ll see a fairly strong list of options. Textutil supports conversion of txt, rtf, rtfd, html, doc, docx, odt, wordml, and webarchive formats.

Running textutil isn’t as hard as it looks. For example, I have a lot of clients that send me material in .docx or .odt format. I like to convert them over to .rtf files for quicker review (so Word or OpenOffice doesn’t have to load up). I make sure I’m in the same directory as the file I’m working with of course, and I execute:

textutil -convert rtf -output introduction.rtf introduction.docx

Once that’s done, you’ll notice an .rtf file is now in the same directory containing the original material.

Now the power of textutil doesn’t end there. Sometimes I want to convert a bunch of files and combine them into a single file. To do that I do something like:

textutil -cat rtf -output combined_project.rtf *.docx

Doing this takes all the .docx files in the current directory and combines them into a single .rtf file called combined_project.

If you have to deal with client provided text a lot, take a serious look at textutil – it has some great features hidden within it’s depths (like font resizing).

Making Configuration Files with YAML: Revised

So back in July 2007 I posted a blog on making configuration files with YAML, and I’ve been noticing a lot of readership on the old article. Because it seems that a lot of people are reading it I felt it was important to show how I apply this nowadays.

First I put my config.yml file within the /config/ directory within my Rails application. It looks something like this:

development: &non_production_settings
    :api_key: "[Enter Google ID]"
    :title: "[Title]"
    :address: "http://localhost:3000/"

  <<: *non_production_settings

    :api_key: "[Enter Google ID]"
    :title: "[Title]"
    :address: "[Address]"

Then, I create a new file called load_config.rb within the /config/initializers directory. You can name the file whatever you want – that’s just what I call it. This is where the actually YAML loading is going to happen – and this is what it looks like:

raw_config = File.read(RAILS_ROOT + "/config/config.yml")
APP_CONFIG = YAML.load(raw_config)[RAILS_ENV]

Now any time I want to all one of these variables I just call it like:

<%= APP_CONFIG[:site][:title] %>

Stop Leading Your Team to The Destination, Give Them The Map

To start 2009 this will be one of the first of many business oriented posts coming to this blog. It’s great to be a technologist, but it’s important we as technologists can do something with our ideas. So I hope to provide some benefit to those of you willing to listen.

The biggest thing every executive needs to run a successful company is a vision – you can’t do crap without a vision of what it looks like. I’m not talking about a 5-year plan, or a 10-year plan… I’m talking about an idea. What do you want to be? Who are you in the realm of all of your competitors? If you don’t know this, why come in the office in the morning? What pushes you to get up everyday? There has got to be something… and that’s the first step – figure out what it is.

Once you’ve got the idea figured out, don’t tell everyone about it by commanding they follow behind you, because people will get lost and it will slow the entire process down.

Think about it for a second. If a group of people in several cars are all trying to get to the same place, but only the person in the front of the line knows how to get there. With every stop sign and stop light, every turn, and every interruption the people in the line have to check where the leader is… and in turn the leader needs to check that everyone is behind him. So instead of commanding, give everyone the map, explain the vision, and explain how they fit into the vision of what’s going on. Then with the map in hand they can get to the destination in their own right. Give your people the freedom to make small course changes on the way, side streets or pit stops, they’ll meet you at the finish line.

Let’s say part of the corporate vision is to provide a superior user experience in all of your software. If you share the map and embed that ideal in your corporate culture you’ll see how people will take charge. Jill in QA will consider it when testing. Bob in design will research the best user experience paradigm in his interface, just as Sam will do the same when programming the front end.

Have a vision, build a culture around the vision, and then let the smart people work.