#! /usr/bin/env ruby # # on osx this script will dump out a listing of extention -> mime type based # on the same config apache/httpd uses. require 'rubygems' fmt = ARGV.shift || 'yaml' config = ARGV.shift || '/etc/apache2/mime.types' index = {} IO.readlines(config).each do |line| line.strip! next if line[%r/^\s*#/] next if line.empty? content_type, *extensions = line.split %r/\s+/ extensions.each do |extension| index[extension] = content_type end end require fmt puts index.send("to_#{ fmt }") __END__ ruby a.rb yaml --- mny: application/x-msmoney rs: application/rls-services+xml sbml: application/sbml+xml sus: application/vnd.sus-calendar mxs: application/vnd.triscape.mxs ecelp7470: audio/vnd.nuera.ecelp7470 hpid: application/vnd.hp-hpid mxu: video/vnd.mpegurl cxx: text/x-c ... ruby a.rb json ...(huge json hash)