I hereby claim:
- I am kylemclaren on github.
- I am kylemclaren (https://keybase.io/kylemclaren) on keybase.
- I have a public key ASBJ41IOHUZ6DuPQq0tqmUwo2JSiDSZZiPLn-SgO8R1R9Qo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| use mydb; | |
| // Container class | |
| function CollStats(name, storageSizeGB, indexSizeGB, totalSizeGB) { | |
| this.name = name; | |
| this.storageSizeGB = storageSizeGB.toFixed(0); | |
| this.indexSizeGB = indexSizeGB.toFixed(0); | |
| this.totalSizeGB = totalSizeGB.toFixed(0); | |
| } | |
| JSON.pretty_generate(JSON.parse(obj.to_json)) |
| development: | |
| # Configure available database clients. (required) | |
| clients: | |
| # Defines the default client. (required) | |
| default: | |
| # Defines the name of the default database that Mongoid can connect to. | |
| # (required). | |
| database: my_db | |
| # Provides the hosts the default client can connect to. Must be an array | |
| # of host:port pairs. (required) |
| /** | |
| * Typewriter.js 0.0.1 | |
| * @author Kyle Foster (@hkfoster) | |
| * @license MIT (http://www.opensource.org/licenses/mit-license.php/) | |
| */ | |
| var typewriter = ( function() { | |
| var headline = document.querySelector( '.typewriter' ); |
| db.currentOp( | |
| { | |
| $or: [ | |
| { op: "query", "query.createIndexes": { $exists: true } }, | |
| { op: "insert", ns: /\.system\.indexes\b/ } | |
| ] | |
| } | |
| ) |
| # SSH tunnel script | |
| # | |
| # Set the following environment variables: | |
| # | |
| # SSH_TUNNEL_TARGET=user@hostname:port | |
| # SSH_TUNNEL_KEY=RSA:{base64 private key} | |
| # SSH_TUNNEL_FORWARDS=localaddr:localport:remoteaddr:remoteport,[...] | |
| # | |
| # Notes: | |
| # |
| var collectionNames = db.getCollectionNames(), stats = []; | |
| collectionNames.forEach(function (n) { stats.push(db[n].stats()); }); | |
| stats = stats.sort(function(a, b) { return b['size'] - a['size']; }); | |
| for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); } |
| // I wanted to know the top five largest collections in my MongoDB database in | |
| // terms of document count. This MongoDB-specific JavaScript gets the job done. | |
| // | |
| // Edit variables in the config section, then execute like so: | |
| // | |
| // mongo --quiet topCollections.js | |
| // config | |
| var dbname = 'FIXME'; |