Skip to content

Instantly share code, notes, and snippets.

Keybase proof

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:

@kylemclaren
kylemclaren / collSize.js
Created November 20, 2016 07:11
MongoDB Collections sizes pretty printed 🌟
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);
}
@kylemclaren
kylemclaren / tmux-cheatsheet.markdown
Created April 21, 2016 04:07 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@kylemclaren
kylemclaren / gist:1be98cb24427e16d252b6069d9bfc40f
Created March 31, 2016 22:26 — forked from mtkd/gist:3393155
Pretty print a mongoid document
JSON.pretty_generate(JSON.parse(obj.to_json))
@kylemclaren
kylemclaren / mongoid.yml
Created October 21, 2015 11:11
Mongoid config for Compose MongoDB+ SSL deployment
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' );
@kylemclaren
kylemclaren / showIndexBuilds.js
Created April 24, 2015 10:22
Show current index builds (MongoDB)
db.currentOp(
{
$or: [
{ op: "query", "query.createIndexes": { $exists: true } },
{ op: "insert", ns: /\.system\.indexes\b/ }
]
}
)
@kylemclaren
kylemclaren / tunnel.py
Created April 15, 2015 09:35
Heroku SSH tunnel set up script (RethinkDB etc.)
# 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';