Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: ([userId]) ->
      # limit one admin
      return if Houston._admins.findOne {'user_id': $exists: true}
      Houston._admins.insert user_id: userId
      return true

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# used by login page to see if admin has been created yet
Houston._publish 'admin_user', ->
  if Houston._user_is_admin @userId
    return Houston._admins.find user_id: @userId
  Houston._admins.find {user_id: $exists: true}, fields: _id: true
```

Response:
var fn, mongo_driver, save_collections;

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("houston_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  _houston_make_admin: function([userId]) {
    // limit one admin
    if (Houston._admins.findOne({
      'user_id': {
        $exists: true
      }
    })) {
      return;
    }
    Houston._admins.insert({
      user_id: userId
    });
    return true;
  }
});

fn = Meteor.bindEnvironment(save_collections, function(e) {
  return console.log(e);
});

// MongoInternals is the 'right' solution as of 0.6.5
mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;

mongo_driver.mongo.db.collections(fn);

// publish our analysis of the app's collections
Houston._publish('collections', function() {
  if (!Houston._user_is_admin(this.userId)) {
    return;
  }
  return Houston._collections.collections.find();
});

// used by login page to see if admin has been created yet
Houston._publish('admin_user', function() {
  if (Houston._user_is_admin(this.userId)) {
    return Houston._admins.find({
      user_id: this.userId
    });
  }
  return Houston._admins.find({
    user_id: {
      $exists: true
    }
  }, {
    fields: {
      _id: true
    }
  });
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var fn, mongo_driver, save_collections;

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("houston_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  _houston_make_admin: function([userId]) {
    // limit one admin
    if (Houston._admins.findOne({
      'user_id': {
        $exists: true
      }
    })) {
      return;
    }
    Houston._admins.insert({
      user_id: userId
    });
    return true;
  }
});

fn = Meteor.bindEnvironment(save_collections, function(e) {
  return console.log(e);
});

// MongoInternals is the 'right' solution as of 0.6.5
mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;

mongo_driver.mongo.db.collections(fn);

// publish our analysis of the app's collections
Houston._publish('collections', function() {
  if (!Houston._user_is_admin(this.userId)) {
    return;
  }
  return Houston._collections.collections.find();
});

// used by login page to see if admin has been created yet
Houston._publish('admin_user', function() {
  if (Houston._user_is_admin(this.userId)) {
    return Houston._admins.find({
      user_id: this.userId
    });
  }
  return Houston._admins.find({
    user_id: {
      $exists: true
    }
  }, {
    fields: {
      _id: true
    }
  });
});
```

Response:
save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: ([userId]) ->
      # limit one admin
      return if Houston._admins.findOne {'user_id': $exists: true}
      Houston._admins.insert user_id: userId
      return true

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# used by login page to see if admin has been created yet
Houston._publish 'admin_user', ->
  if Houston._user_is_admin @userId
    return Houston._admins.find user_id: @userId
  Houston._admins.find {user_id: $exists: true}, fields: _id: true


Prompt:
save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: ([userId]) ->
      # limit one admin
      return if Houston._admins.findOne {'user_id': $exists: true}

Response:
Houston._admins.insert user_id: userId
      return true

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# used by login page to see if admin has been created yet
Houston._publish 'admin_user', ->
  if Houston._user_is_admin @userId
    return Houston._admins.find user_id: @userId
  Houston._admins.find {user_id: $exists: true}, fields: _id: true


Response:
Houston._publish = (name, func) ->
  Meteor.publish Houston._houstonize(name), func

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods[Houston._houstonize "#{name}_insert"] = (doc) ->
      return unless Houston._user_is_admin @userId
      collection.insert(doc)

    methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
      return unless Houston._user_is_admin @userId
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods[Houston._houstonize "#{name}_delete"] = (id, update_dict) ->
      return unless Houston._user_is_admin @userId
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Houston._publish name, (sort, filter, limit) ->
      return unless Houston._user_is_admin @userId
      try
        collection.find(filter, sort: sort, limit: limit)
      catch e
        console.log e

    collection.find().observe
      added: (document) ->
        Houston._collections.collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: $each: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

    fields = Houston._get_field_names(collection.find().fetch())
    c = Houston._collections.collections.findOne {name}
    if c
      Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
Houston._publish = (name, func) ->
  Meteor.publish Houston._houstonize(name), func

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods[Houston._houstonize "#{name}_insert"] = (doc) ->
      return unless Houston._user_is_admin @userId
      collection.insert(doc)

    methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
      return unless Houston._user_is_admin @userId
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods[Houston._houstonize "#{name}_delete"] = (id, update_dict) ->
      return unless Houston._user_is_admin @userId
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Houston._publish name, (sort, filter, limit) ->
      return unless Houston._user_is_admin @userId
      try
        collection.find(filter, sort: sort, limit: limit)
      catch e
        console.log e

    collection.find().observe
      added: (document) ->
        Houston._collections.collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: $each: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

    fields = Houston._get_field_names(collection.find().fetch())
    c = Houston._collections.collections.findOne {name}
    if c
      Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack
```

Response:
Houston._publish = function(name, func) {
  return Meteor.publish(Houston._houstonize(name), func);
};

Meteor.startup(function() {
  var set_up_collection;
  set_up_collection = function(name, collection) {
    var c, fields, methods;
    methods = {};
    methods[Houston._houstonize(`${name}_insert`)] = function(doc) {
      if (!Houston._user_is_admin(this.userId)) {
        return;
      }
      return collection.insert(doc);
    };
    methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {
      if (!Houston._user_is_admin(this.userId)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.update(id, update_dict);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.update(id, update_dict);
      }
    };
    methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {
      if (!Houston._user_is_admin(this.userId)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.remove(id);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.remove(id);
      }
    };
    Meteor.methods(methods);
    Houston._publish(name, function(sort, filter, limit) {
      var e;
      if (!Houston._user_is_admin(this.userId)) {
        return;
      }
      try {
        return collection.find(filter, {
          sort: sort,
          limit: limit
        });
      } catch (error) {
        e = error;
        return console.log(e);
      }
    });
    collection.find().observe({
      added: function(document) {
        return Houston._collections.collections.update({name}, {
          $inc: {
            count: 1
          },
          $addToSet: {
            fields: {
              $each: Houston._get_field_names([document])
            }
          }
        });
      },
      removed: function(document) {
        return Houston._collections.collections.update({name}, {
          $inc: {
            count: -1
          }
        });
      }
    });
    fields = Houston._get_field_names(collection.find().fetch());
    c = Houston._collections.collections.findOne({name});
    if (c) {
      return Houston._collections.collections.update(c._id, {
        $set: {
          count: collection.find().count(),
          fields: fields
        }
      });
    } else {
      return Houston._collections.collections.insert({
        name,
        count: collection.find().count(),
        fields: fields
      });
    }
  };
  return Dummy.findOne(); // hack
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
Houston._publish = function(name, func) {
  return Meteor.publish(Houston._houstonize(name), func);
};

Meteor.startup(function() {
  var set_up_collection;
  set_up_collection = function(name, collection) {
    var c, fields, methods;
    methods = {};
    methods[Houston._houstonize(`${name}_insert`)] = function(doc) {
      if (!Houston._user_is_admin(this.userId)) {
        return;
      }
      return collection.insert(doc);
    };
    methods[Houston._houstonize(`${name}_update`)] = function(id, update_dict) {
      if (!Houston._user_is_admin(this.userId)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.update(id, update_dict);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.update(id, update_dict);
      }
    };
    methods[Houston._houstonize(`${name}_delete`)] = function(id, update_dict) {
      if (!Houston._user_is_admin(this.userId)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.remove(id);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.remove(id);
      }
    };
    Meteor.methods(methods);
    Houston._publish(name, function(sort, filter, limit) {
      var e;
      if (!Houston._user_is_admin(this.userId)) {
        return;
      }
      try {
        return collection.find(filter, {
          sort: sort,
          limit: limit
        });
      } catch (error) {
        e = error;
        return console.log(e);
      }
    });
    collection.find().observe({
      added: function(document) {
        return Houston._collections.collections.update({name}, {
          $inc: {
            count: 1
          },
          $addToSet: {
            fields: {
              $each: Houston._get_field_names([document])
            }
          }
        });
      },
      removed: function(document) {
        return Houston._collections.collections.update({name}, {
          $inc: {
            count: -1
          }
        });
      }
    });
    fields = Houston._get_field_names(collection.find().fetch());
    c = Houston._collections.collections.findOne({name});
    if (c) {
      return Houston._collections.collections.update(c._id, {
        $set: {
          count: collection.find().count(),
          fields: fields
        }
      });
    } else {
      return Houston._collections.collections.insert({
        name,
        count: collection.find().count(),
        fields: fields
      });
    }
  };
  return Dummy.findOne(); // hack
});
```

Response:
Houston._publish = (name, func) ->
  Meteor.publish Houston._houstonize(name), func

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods[Houston._houstonize "#{name}_insert"] = (doc) ->
      return unless Houston._user_is_admin @userId
      collection.insert(doc)

    methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
      return unless Houston._user_is_admin @userId
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods[Houston._houstonize "#{name}_delete"] = (id, update_dict) ->
      return unless Houston._user_is_admin @userId
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Houston._publish name, (sort, filter, limit) ->
      return unless Houston._user_is_admin @userId
      try
        collection.find(filter, sort: sort, limit: limit)
      catch e
        console.log e

    collection.find().observe
      added: (document) ->
        Houston._collections.collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: $each: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

    fields = Houston._get_field_names(collection.find().fetch())
    c = Houston._collections.collections.findOne {name}
    if c
      Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack


Prompt:
Houston._publish = (name, func) ->
  Meteor.publish Houston._houstonize(name), func

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods[Houston._houstonize "#{name}_insert"] = (doc) ->
      return unless Houston._user_is_admin @userId
      collection.insert(doc)

    methods[Houston._houstonize "#{name}_update"] = (id, update_dict) ->
      return unless Houston._user_is_admin @userId
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods[Houston._houstonize "#{name}_delete"] = (id, update_dict) ->
      return unless Houston._user_is_admin @userId
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

Response:
Meteor.methods methods

    Houston._publish name, (sort, filter, limit) ->
      return unless Houston._user_is_admin @userId
      try
        collection.find(filter, sort: sort, limit: limit)
      catch e
        console.log e

    collection.find().observe
      added: (document) ->
        Houston._collections.collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: $each: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

    fields = Houston._get_field_names(collection.find().fetch())
    c = Houston._collections.collections.findOne {name}
    if c
      Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack


Response:
save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: (userId) ->
      # limit one admin
      return if Houston._admins.findOne {'user_id': $exists: true}
      Houston._admins.insert user_id: userId
      return true

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# used by login page to see if admin has been created yet
Houston._publish 'admin_user', ->
  if Houston._user_is_admin @userId
    return Houston._admins.find user_id: @userId
  Houston._admins.find {user_id: $exists: true}, fields: _id: true


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: (userId) ->
      # limit one admin
      return if Houston._admins.findOne {'user_id': $exists: true}
      Houston._admins.insert user_id: userId
      return true

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# used by login page to see if admin has been created yet
Houston._publish 'admin_user', ->
  if Houston._user_is_admin @userId
    return Houston._admins.find user_id: @userId
  Houston._admins.find {user_id: $exists: true}, fields: _id: true
```

Response:
var fn, mongo_driver, save_collections;

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("houston_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  _houston_make_admin: function(userId) {
    // limit one admin
    if (Houston._admins.findOne({
      'user_id': {
        $exists: true
      }
    })) {
      return;
    }
    Houston._admins.insert({
      user_id: userId
    });
    return true;
  }
});

fn = Meteor.bindEnvironment(save_collections, function(e) {
  return console.log(e);
});

// MongoInternals is the 'right' solution as of 0.6.5
mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;

mongo_driver.mongo.db.collections(fn);

// publish our analysis of the app's collections
Houston._publish('collections', function() {
  if (!Houston._user_is_admin(this.userId)) {
    return;
  }
  return Houston._collections.collections.find();
});

// used by login page to see if admin has been created yet
Houston._publish('admin_user', function() {
  if (Houston._user_is_admin(this.userId)) {
    return Houston._admins.find({
      user_id: this.userId
    });
  }
  return Houston._admins.find({
    user_id: {
      $exists: true
    }
  }, {
    fields: {
      _id: true
    }
  });
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var fn, mongo_driver, save_collections;

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("houston_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  _houston_make_admin: function(userId) {
    // limit one admin
    if (Houston._admins.findOne({
      'user_id': {
        $exists: true
      }
    })) {
      return;
    }
    Houston._admins.insert({
      user_id: userId
    });
    return true;
  }
});

fn = Meteor.bindEnvironment(save_collections, function(e) {
  return console.log(e);
});

// MongoInternals is the 'right' solution as of 0.6.5
mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;

mongo_driver.mongo.db.collections(fn);

// publish our analysis of the app's collections
Houston._publish('collections', function() {
  if (!Houston._user_is_admin(this.userId)) {
    return;
  }
  return Houston._collections.collections.find();
});

// used by login page to see if admin has been created yet
Houston._publish('admin_user', function() {
  if (Houston._user_is_admin(this.userId)) {
    return Houston._admins.find({
      user_id: this.userId
    });
  }
  return Houston._admins.find({
    user_id: {
      $exists: true
    }
  }, {
    fields: {
      _id: true
    }
  });
});
```

Response:
save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: (userId) ->
      # limit one admin
      return if Houston._admins.findOne {'user_id': $exists: true}
      Houston._admins.insert user_id: userId
      return true

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# used by login page to see if admin has been created yet
Houston._publish 'admin_user', ->
  if Houston._user_is_admin @userId
    return Houston._admins.find user_id: @userId
  Houston._admins.find {user_id: $exists: true}, fields: _id: true


Prompt:
save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: (userId) ->
      # limit one admin
      return if Houston._admins.findOne {'user_id': $exists: true}

Response:
Houston._admins.insert user_id: userId
      return true

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our analysis of the app's collections
Houston._publish 'collections', ->
  return unless Houston._user_is_admin @userId
  Houston._collections.collections.find()

# used by login page to see if admin has been created yet
Houston._publish 'admin_user', ->
  if Houston._user_is_admin @userId
    return Houston._admins.find user_id: @userId
  Houston._admins.find {user_id: $exists: true}, fields: _id: true


Response:
Houston._publish = (name, func) ->
  Meteor.publish Houston._houstonize(name), func

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods[Houston._houstonize "#{name}_insert"] = ([doc]) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods[Houston._houstonize "#{name}_update"] = ([id, update_dict]) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods[Houston._houstonize "#{name}_delete"] = ([id, update_dict]) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Houston._publish name, (sort, filter, limit) ->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e

    collection.find().observe
      added: (document) ->
        Houston._collections.collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: $each: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

    fields = Houston._get_field_names(collection.find().fetch())
    c = Houston._collections.collections.findOne {name}


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
Houston._publish = (name, func) ->
  Meteor.publish Houston._houstonize(name), func

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods[Houston._houstonize "#{name}_insert"] = ([doc]) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods[Houston._houstonize "#{name}_update"] = ([id, update_dict]) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods[Houston._houstonize "#{name}_delete"] = ([id, update_dict]) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Houston._publish name, (sort, filter, limit) ->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e

    collection.find().observe
      added: (document) ->
        Houston._collections.collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: $each: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

    fields = Houston._get_field_names(collection.find().fetch())
    c = Houston._collections.collections.findOne {name}
```

Response:
Houston._publish = function(name, func) {
  return Meteor.publish(Houston._houstonize(name), func);
};

Meteor.startup(function() {
  var set_up_collection;
  return set_up_collection = function(name, collection) {
    var c, fields, methods;
    methods = {};
    methods[Houston._houstonize(`${name}_insert`)] = function([doc]) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      return collection.insert(doc);
    };
    methods[Houston._houstonize(`${name}_update`)] = function([id, update_dict]) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.update(id, update_dict);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.update(id, update_dict);
      }
    };
    methods[Houston._houstonize(`${name}_delete`)] = function([id, update_dict]) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.remove(id);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.remove(id);
      }
    };
    Meteor.methods(methods);
    Houston._publish(name, function(sort, filter, limit) {
      var e;
      if (Meteor.users.findOne({
        _id: this.userId,
        'profile.admin': true
      })) {
        try {
          return collection.find(filter, {
            sort: sort,
            limit: limit
          });
        } catch (error) {
          e = error;
          return console.log(e);
        }
      }
    });
    collection.find().observe({
      added: function(document) {
        return Houston._collections.collections.update({name}, {
          $inc: {
            count: 1
          },
          $addToSet: {
            fields: {
              $each: Houston._get_field_names([document])
            }
          }
        });
      },
      removed: function(document) {
        return Houston._collections.collections.update({name}, {
          $inc: {
            count: -1
          }
        });
      }
    });
    fields = Houston._get_field_names(collection.find().fetch());
    return c = Houston._collections.collections.findOne({name});
  };
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
Houston._publish = function(name, func) {
  return Meteor.publish(Houston._houstonize(name), func);
};

Meteor.startup(function() {
  var set_up_collection;
  return set_up_collection = function(name, collection) {
    var c, fields, methods;
    methods = {};
    methods[Houston._houstonize(`${name}_insert`)] = function([doc]) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      return collection.insert(doc);
    };
    methods[Houston._houstonize(`${name}_update`)] = function([id, update_dict]) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.update(id, update_dict);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.update(id, update_dict);
      }
    };
    methods[Houston._houstonize(`${name}_delete`)] = function([id, update_dict]) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.remove(id);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.remove(id);
      }
    };
    Meteor.methods(methods);
    Houston._publish(name, function(sort, filter, limit) {
      var e;
      if (Meteor.users.findOne({
        _id: this.userId,
        'profile.admin': true
      })) {
        try {
          return collection.find(filter, {
            sort: sort,
            limit: limit
          });
        } catch (error) {
          e = error;
          return console.log(e);
        }
      }
    });
    collection.find().observe({
      added: function(document) {
        return Houston._collections.collections.update({name}, {
          $inc: {
            count: 1
          },
          $addToSet: {
            fields: {
              $each: Houston._get_field_names([document])
            }
          }
        });
      },
      removed: function(document) {
        return Houston._collections.collections.update({name}, {
          $inc: {
            count: -1
          }
        });
      }
    });
    fields = Houston._get_field_names(collection.find().fetch());
    return c = Houston._collections.collections.findOne({name});
  };
});
```

Response:
Houston._publish = (name, func) ->
  Meteor.publish Houston._houstonize(name), func

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods[Houston._houstonize "#{name}_insert"] = ([doc]) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods[Houston._houstonize "#{name}_update"] = ([id, update_dict]) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods[Houston._houstonize "#{name}_delete"] = ([id, update_dict]) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Houston._publish name, (sort, filter, limit) ->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e

    collection.find().observe
      added: (document) ->
        Houston._collections.collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: $each: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

    fields = Houston._get_field_names(collection.find().fetch())
    c = Houston._collections.collections.findOne {name}


Prompt:
Houston._publish = (name, func) ->
  Meteor.publish Houston._houstonize(name), func

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods[Houston._houstonize "#{name}_insert"] = ([doc]) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods[Houston._houstonize "#{name}_update"] = ([id, update_dict]) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods[Houston._houstonize "#{name}_delete"] = ([id, update_dict]) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)

Response:
return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Houston._publish name, (sort, filter, limit) ->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e

    collection.find().observe
      added: (document) ->
        Houston._collections.collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: $each: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

    fields = Houston._get_field_names(collection.find().fetch())
    c = Houston._collections.collections.findOne {name}


Response:
if c
      Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: ([userId]) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.collections.find()

Houston._publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
if c
      Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: ([userId]) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.collections.find()

Houston._publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)
```

Response:
var fn, mongo_driver, save_collections;

if (c) {
  Houston._collections.collections.update(c._id, {
    $set: {
      count: collection.find().count(),
      fields: fields
    }
  });
} else {
  Houston._collections.collections.insert({
    name,
    count: collection.find().count(),
    fields: fields
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("houston_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  _houston_make_admin: function([userId]) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return true;
  }
});

fn = Meteor.bindEnvironment(save_collections, function(e) {
  return console.log(e);
});

// MongoInternals is the 'right' solution as of 0.6.5
mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;

mongo_driver.mongo.db.collections(fn);

// publish our own internal state
Meteor.publish('_houston', function() {
  if (Meteor.users.findOne({
    _id: this.userId,
    'profile.admin': true
  })) {
    return Houston._collections.collections.find();
  }
});

Houston._publish('adminUser', function() { // used by login page to see if admin has been created yet
  return Meteor.users.find({
    'profile.admin': true
  }, {
    fields: {
      'profile.admin': true
    }
  });
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var fn, mongo_driver, save_collections;

if (c) {
  Houston._collections.collections.update(c._id, {
    $set: {
      count: collection.find().count(),
      fields: fields
    }
  });
} else {
  Houston._collections.collections.insert({
    name,
    count: collection.find().count(),
    fields: fields
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("houston_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  _houston_make_admin: function([userId]) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return true;
  }
});

fn = Meteor.bindEnvironment(save_collections, function(e) {
  return console.log(e);
});

// MongoInternals is the 'right' solution as of 0.6.5
mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;

mongo_driver.mongo.db.collections(fn);

// publish our own internal state
Meteor.publish('_houston', function() {
  if (Meteor.users.findOne({
    _id: this.userId,
    'profile.admin': true
  })) {
    return Houston._collections.collections.find();
  }
});

Houston._publish('adminUser', function() { // used by login page to see if admin has been created yet
  return Meteor.users.find({
    'profile.admin': true
  }, {
    fields: {
      'profile.admin': true
    }
  });
});
```

Response:
if c
      Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: ([userId]) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.collections.find()

Houston._publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Prompt:
if c
      Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

Response:
Meteor.methods
    _houston_make_admin: ([userId]) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.collections.find()

Houston._publish 'adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Response:
root = exports ? this

Dummy = new Meteor.Collection("system.dummy")  # hack.
collections = {'users': Meteor.users}

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods["_houston_#{name}_insert"] = (doc) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods["_houston_#{name}_update"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods["_houston_#{name}_delete"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Meteor.publish "_houston_#{name}", (sort, filter, limit) ->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
root = exports ? this

Dummy = new Meteor.Collection("system.dummy")  # hack.
collections = {'users': Meteor.users}

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods["_houston_#{name}_insert"] = (doc) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods["_houston_#{name}_update"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods["_houston_#{name}_delete"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Meteor.publish "_houston_#{name}", (sort, filter, limit) ->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e
```

Response:
var Dummy, collections, root;

root = typeof exports !== "undefined" && exports !== null ? exports : this;

Dummy = new Meteor.Collection("system.dummy"); // hack.

collections = {
  'users': Meteor.users
};

Meteor.startup(function() {
  var set_up_collection;
  return set_up_collection = function(name, collection) {
    var methods;
    methods = {};
    methods[`_houston_${name}_insert`] = function(doc) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      return collection.insert(doc);
    };
    methods[`_houston_${name}_update`] = function(id, update_dict) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.update(id, update_dict);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.update(id, update_dict);
      }
    };
    methods[`_houston_${name}_delete`] = function(id, update_dict) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.remove(id);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.remove(id);
      }
    };
    Meteor.methods(methods);
    return Meteor.publish(`_houston_${name}`, function(sort, filter, limit) {
      var e;
      if (Meteor.users.findOne({
        _id: this.userId,
        'profile.admin': true
      })) {
        try {
          return collection.find(filter, {
            sort: sort,
            limit: limit
          });
        } catch (error) {
          e = error;
          return console.log(e);
        }
      }
    });
  };
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var Dummy, collections, root;

root = typeof exports !== "undefined" && exports !== null ? exports : this;

Dummy = new Meteor.Collection("system.dummy"); // hack.

collections = {
  'users': Meteor.users
};

Meteor.startup(function() {
  var set_up_collection;
  return set_up_collection = function(name, collection) {
    var methods;
    methods = {};
    methods[`_houston_${name}_insert`] = function(doc) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      return collection.insert(doc);
    };
    methods[`_houston_${name}_update`] = function(id, update_dict) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.update(id, update_dict);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.update(id, update_dict);
      }
    };
    methods[`_houston_${name}_delete`] = function(id, update_dict) {
      var user;
      if (!this.userId) {
        return;
      }
      user = Meteor.users.findOne(this.userId);
      if (!(user != null ? user.profile.admin : void 0)) {
        return;
      }
      if (collection.findOne(id)) {
        return collection.remove(id);
      } else {
        id = collection.findOne(new Meteor.Collection.ObjectID(id));
        return collection.remove(id);
      }
    };
    Meteor.methods(methods);
    return Meteor.publish(`_houston_${name}`, function(sort, filter, limit) {
      var e;
      if (Meteor.users.findOne({
        _id: this.userId,
        'profile.admin': true
      })) {
        try {
          return collection.find(filter, {
            sort: sort,
            limit: limit
          });
        } catch (error) {
          e = error;
          return console.log(e);
        }
      }
    });
  };
});
```

Response:
root = exports ? this

Dummy = new Meteor.Collection("system.dummy")  # hack.
collections = {'users': Meteor.users}

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods["_houston_#{name}_insert"] = (doc) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods["_houston_#{name}_update"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods["_houston_#{name}_delete"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Meteor.publish "_houston_#{name}", (sort, filter, limit) ->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e


Prompt:
root = exports ? this

Dummy = new Meteor.Collection("system.dummy")  # hack.
collections = {'users': Meteor.users}

Meteor.startup ->
  set_up_collection = (name, collection) ->
    methods = {}
    methods["_houston_#{name}_insert"] = (doc) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      collection.insert(doc)

    methods["_houston_#{name}_update"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.update(id, update_dict)
      else

Response:
id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.update(id, update_dict)

    methods["_houston_#{name}_delete"] = (id, update_dict) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      if collection.findOne(id)
        collection.remove(id)
      else
        id = collection.findOne(new Meteor.Collection.ObjectID(id))
        collection.remove(id)

    Meteor.methods methods

    Meteor.publish "_houston_#{name}", (sort, filter, limit) ->
      if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
        try
          collection.find(filter, sort: sort, limit: limit)
        catch e
          console.log e


Response:
collection.find().observe
      added: (document) ->
        Houston._collections.collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: $each: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

    fields = Houston._get_field_names(collection.find().fetch())
    c = Houston._collections.collections.findOne {name}
    if c
      Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
collection.find().observe
      added: (document) ->
        Houston._collections.collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: $each: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

    fields = Houston._get_field_names(collection.find().fetch())
    c = Houston._collections.collections.findOne {name}
    if c
      Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true
```

Response:
var c, fields, save_collections;

collection.find().observe({
  added: function(document) {
    return Houston._collections.collections.update({name}, {
      $inc: {
        count: 1
      },
      $addToSet: {
        fields: {
          $each: Houston._get_field_names([document])
        }
      }
    });
  },
  removed: function(document) {
    return Houston._collections.collections.update({name}, {
      $inc: {
        count: -1
      }
    });
  }
});

fields = Houston._get_field_names(collection.find().fetch());

c = Houston._collections.collections.findOne({name});

if (c) {
  Houston._collections.collections.update(c._id, {
    $set: {
      count: collection.find().count(),
      fields: fields
    }
  });
} else {
  Houston._collections.collections.insert({
    name,
    count: collection.find().count(),
    fields: fields
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("houston_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  _houston_make_admin: function(userId) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return true;
  }
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var c, fields, save_collections;

collection.find().observe({
  added: function(document) {
    return Houston._collections.collections.update({name}, {
      $inc: {
        count: 1
      },
      $addToSet: {
        fields: {
          $each: Houston._get_field_names([document])
        }
      }
    });
  },
  removed: function(document) {
    return Houston._collections.collections.update({name}, {
      $inc: {
        count: -1
      }
    });
  }
});

fields = Houston._get_field_names(collection.find().fetch());

c = Houston._collections.collections.findOne({name});

if (c) {
  Houston._collections.collections.update(c._id, {
    $set: {
      count: collection.find().count(),
      fields: fields
    }
  });
} else {
  Houston._collections.collections.insert({
    name,
    count: collection.find().count(),
    fields: fields
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("houston_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  _houston_make_admin: function(userId) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return true;
  }
});
```

Response:
collection.find().observe
      added: (document) ->
        Houston._collections.collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: $each: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

    fields = Houston._get_field_names(collection.find().fetch())
    c = Houston._collections.collections.findOne {name}
    if c
      Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true


Prompt:
collection.find().observe
      added: (document) ->
        Houston._collections.collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: $each: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.collections.update {name}, {$inc: {count: -1}}

    fields = Houston._get_field_names(collection.find().fetch())
    c = Houston._collections.collections.findOne {name}
    if c
      Houston._collections.collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and

Response:
(col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true


Response:
fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.collections.find()

Meteor.publish '_houston_adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.collections.find()

Meteor.publish '_houston_adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)
```

Response:
var fn, mongo_driver;

fn = Meteor.bindEnvironment(save_collections, function(e) {
  return console.log(e);
});

// MongoInternals is the 'right' solution as of 0.6.5
mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;

mongo_driver.mongo.db.collections(fn);

// publish our own internal state
Meteor.publish('_houston', function() {
  if (Meteor.users.findOne({
    _id: this.userId,
    'profile.admin': true
  })) {
    return Houston._collections.collections.find();
  }
});

Meteor.publish('_houston_adminUser', function() { // used by login page to see if admin has been created yet
  return Meteor.users.find({
    'profile.admin': true
  }, {
    fields: {
      'profile.admin': true
    }
  });
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var fn, mongo_driver;

fn = Meteor.bindEnvironment(save_collections, function(e) {
  return console.log(e);
});

// MongoInternals is the 'right' solution as of 0.6.5
mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;

mongo_driver.mongo.db.collections(fn);

// publish our own internal state
Meteor.publish('_houston', function() {
  if (Meteor.users.findOne({
    _id: this.userId,
    'profile.admin': true
  })) {
    return Houston._collections.collections.find();
  }
});

Meteor.publish('_houston_adminUser', function() { // used by login page to see if admin has been created yet
  return Meteor.users.find({
    'profile.admin': true
  }, {
    fields: {
      'profile.admin': true
    }
  });
});
```

Response:
fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.collections.find()

Meteor.publish '_houston_adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Prompt:
fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

Response:
# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.collections.find()

Meteor.publish '_houston_adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Response:
collection.find().observe
      added: (document) ->
        Houston._collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.update {name}, {$inc: {count: -1}}

    fields = Houston._get_field_names(collection.find().fetch())
    c = Houston._collections.findOne {name}
    if c
      Houston._collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
collection.find().observe
      added: (document) ->
        Houston._collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.update {name}, {$inc: {count: -1}}

    fields = Houston._get_field_names(collection.find().fetch())
    c = Houston._collections.findOne {name}
    if c
      Houston._collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true
```

Response:
var c, fields, save_collections;

collection.find().observe({
  added: function(document) {
    return Houston._collections.update({name}, {
      $inc: {
        count: 1
      },
      $addToSet: {
        fields: Houston._get_field_names([document])
      }
    });
  },
  removed: function(document) {
    return Houston._collections.update({name}, {
      $inc: {
        count: -1
      }
    });
  }
});

fields = Houston._get_field_names(collection.find().fetch());

c = Houston._collections.findOne({name});

if (c) {
  Houston._collections.update(c._id, {
    $set: {
      count: collection.find().count(),
      fields: fields
    }
  });
} else {
  Houston._collections.insert({
    name,
    count: collection.find().count(),
    fields: fields
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("houston_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  _houston_make_admin: function(userId) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return true;
  }
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var c, fields, save_collections;

collection.find().observe({
  added: function(document) {
    return Houston._collections.update({name}, {
      $inc: {
        count: 1
      },
      $addToSet: {
        fields: Houston._get_field_names([document])
      }
    });
  },
  removed: function(document) {
    return Houston._collections.update({name}, {
      $inc: {
        count: -1
      }
    });
  }
});

fields = Houston._get_field_names(collection.find().fetch());

c = Houston._collections.findOne({name});

if (c) {
  Houston._collections.update(c._id, {
    $set: {
      count: collection.find().count(),
      fields: fields
    }
  });
} else {
  Houston._collections.insert({
    name,
    count: collection.find().count(),
    fields: fields
  });
}

Dummy.findOne(); // hack

save_collections = function(meh, collections_db) {
  var col, collection_names;
  collection_names = (function() {
    var i, len, results;
    results = [];
    for (i = 0, len = collections_db.length; i < len; i++) {
      col = collections_db[i];
      if ((col.collectionName.indexOf("system.")) !== 0 && (col.collectionName.indexOf("houston_")) !== 0) {
        results.push(col.collectionName);
      }
    }
    return results;
  })();
  return collection_names.forEach(function(name) {
    var e, key, value;
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        if (collections[name] == null) {
          console.log(e);
        }
      }
      return set_up_collection(name, collections[name]);
    }
  });
};

Meteor.methods({
  _houston_make_admin: function(userId) {
    // limit one admin
    if (Meteor.users.findOne({
      'profile.admin': true
    })) {
      return;
    }
    Meteor.users.update(userId, {
      $set: {
        'profile.admin': true
      }
    });
    return true;
  }
});
```

Response:
collection.find().observe
      added: (document) ->
        Houston._collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.update {name}, {$inc: {count: -1}}

    fields = Houston._get_field_names(collection.find().fetch())
    c = Houston._collections.findOne {name}
    if c
      Houston._collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and
           (col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true


Prompt:
collection.find().observe
      added: (document) ->
        Houston._collections.update {name},
          $inc: {count: 1},
          $addToSet: fields: Houston._get_field_names([document])
      removed: (document) -> Houston._collections.update {name}, {$inc: {count: -1}}

    fields = Houston._get_field_names(collection.find().fetch())
    c = Houston._collections.findOne {name}
    if c
      Houston._collections.update c._id, {$set: count: collection.find().count(), fields: fields}
    else
      Houston._collections.insert {name, count: collection.find().count(), fields: fields}

  Dummy.findOne()  # hack

  save_collections = (meh, collections_db) ->
    collection_names = (col.collectionName for col in collections_db \
      when (col.collectionName.indexOf "system.") isnt 0 and

Response:
(col.collectionName.indexOf "houston_") isnt 0)

    collection_names.forEach (name) ->
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e unless collections[name]?

        set_up_collection(name, collections[name])

  Meteor.methods
    _houston_make_admin: (userId) ->
      # limit one admin
      return if Meteor.users.findOne {'profile.admin': true}
      Meteor.users.update userId, $set: {'profile.admin': true}
      return true


Response:
fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.find()

Meteor.publish '_houston_adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.find()

Meteor.publish '_houston_adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)
```

Response:
var fn, mongo_driver;

fn = Meteor.bindEnvironment(save_collections, function(e) {
  return console.log(e);
});

// MongoInternals is the 'right' solution as of 0.6.5
mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;

mongo_driver.mongo.db.collections(fn);

// publish our own internal state
Meteor.publish('_houston', function() {
  if (Meteor.users.findOne({
    _id: this.userId,
    'profile.admin': true
  })) {
    return Houston._collections.find();
  }
});

Meteor.publish('_houston_adminUser', function() { // used by login page to see if admin has been created yet
  return Meteor.users.find({
    'profile.admin': true
  }, {
    fields: {
      'profile.admin': true
    }
  });
});


Prompt:
Convert this JavaScript to CoffeeScript.
```javascript
var fn, mongo_driver;

fn = Meteor.bindEnvironment(save_collections, function(e) {
  return console.log(e);
});

// MongoInternals is the 'right' solution as of 0.6.5
mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;

mongo_driver.mongo.db.collections(fn);

// publish our own internal state
Meteor.publish('_houston', function() {
  if (Meteor.users.findOne({
    _id: this.userId,
    'profile.admin': true
  })) {
    return Houston._collections.find();
  }
});

Meteor.publish('_houston_adminUser', function() { // used by login page to see if admin has been created yet
  return Meteor.users.find({
    'profile.admin': true
  }, {
    fields: {
      'profile.admin': true
    }
  });
});
```

Response:
fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.find()

Meteor.publish '_houston_adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Prompt:
fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

Response:
# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.find()

Meteor.publish '_houston_adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Response:
_houston_setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e

        set_up_collection(name, collections[name])

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.find()

Meteor.publish '_houston_adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)


Prompt:
Convert this CoffeeScript to JavaScript.
```coffeescript
_houston_setupNewCollection: (name) ->
      return unless @userId
      user = Meteor.users.findOne(@userId)
      return unless user?.profile.admin
      unless name of collections
        try
          collections[name] = new Meteor.Collection(name)
        catch e
          for key, value of root
            if name == value._name
              collections[name] = value
          console.log e

        set_up_collection(name, collections[name])

  fn = Meteor.bindEnvironment save_collections, (e) ->
    console.log e

  # MongoInternals is the 'right' solution as of 0.6.5
  mongo_driver = MongoInternals?.defaultRemoteCollectionDriver() or Meteor._RemoteCollectionDriver
  mongo_driver.mongo.db.collections fn

# publish our own internal state
Meteor.publish '_houston', ->
  if Meteor.users.findOne(_id: @userId, 'profile.admin': true)
    Houston._collections.find()

Meteor.publish '_houston_adminUser', ->  # used by login page to see if admin has been created yet
  Meteor.users.find({'profile.admin': true}, fields: 'profile.admin': true)
```

Response:
var fn, mongo_driver;

({
  _houston_setupNewCollection: function(name) {
    var e, key, user, value;
    if (!this.userId) {
      return;
    }
    user = Meteor.users.findOne(this.userId);
    if (!(user != null ? user.profile.admin : void 0)) {
      return;
    }
    if (!(name in collections)) {
      try {
        collections[name] = new Meteor.Collection(name);
      } catch (error) {
        e = error;
        for (key in root) {
          value = root[key];
          if (name === value._name) {
            collections[name] = value;
          }
        }
        console.log(e);
      }
      return set_up_collection(name, collections[name]);
    }
  }
});

fn = Meteor.bindEnvironment(save_collections, function(e) {
  return console.log(e);
});

// MongoInternals is the 'right' solution as of 0.6.5
mongo_driver = (typeof MongoInternals !== "undefined" && MongoInternals !== null ? MongoInternals.defaultRemoteCollectionDriver() : void 0) || Meteor._RemoteCollectionDriver;

mongo_driver.mongo.db.collections(fn);

// publish our own internal state
Meteor.publish('_houston', function() {
  if (Meteor.users.findOne({
    _id: this.userId,
    'profile.admin': true
  })) {
    return Houston._collections.find();
  }
});

Meteor.publish('_houston_adminUser', function() { // used by login page to see if admin has been created yet
  return Meteor.users.find({
    'profile.admin': true
  }, {
    fields: {
      'profile.admin': true
    }
  });
});