Homebrew is a great little package manager for OS X. If you haven't already, installing it is pretty easy:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"| // This script loops though the list of collection names in a MongoDB and runs the compact operation on them | |
| // Simply paste this into the Mongo shell | |
| use testDbName; | |
| db.getCollectionNames().forEach(function (collectionName) { | |
| print('Compacting: ' + collectionName); | |
| db.runCommand({ compact: collectionName, force: true }); | |
| }); | |
| # TO FIND OUT WHICH COLLECTIONS ARE THE LARGEST (MONGODB CONSOLE) | |
| var collectionNames = db.getCollectionNames(), stats = []; | |
| collectionNames.forEach(function (n) { try{ stats.push(db[n].stats());}catch(e){} }); | |
| stats = stats.sort(function(a, b) { return b['storageSize'] - a['storageSize']; }); | |
| for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize']/1024/1024/1024 + " GB)"); } | |
| # AND TO DELETE A COLLEECTION IN Henhouse Rails console: | |
| collections = %W( |
| paramaw@ParamaPro:keychain-proxy (master) rails c | |
| A syntax error has occurred: | |
| unknown type of % string: /Users/paramaw/.rvm/gems/rbx-2.2.10/gems/vk-ruby-1.0.1/lib/vk-ruby/params.rb:41:7 | |
| Code: | |
| %i[host verb timeout open_timeout ssl proxy middlewares stack].inject(options.dup) do |result, name| | |
| ^ | |
| Backtrace: |
| # include this in application controller | |
| module Authentication | |
| protected | |
| # Inclusion hook to make #current_user and #signed_in? | |
| # available as ActionView helper methods. | |
| def self.included(base) | |
| base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method | |
| end | |
| # Returns true or false if the user is signed in. |
| hello test gist |