The other day I stumbled across an amazing feature of Sublime Text 2 that doesn't require a plugin to work, yet somehow after 1 year of using the software I hadn't come across it. If you ever find yourself rewriting huge code blocks such as configs, or copying/pasting lots of text and replacing certain parts for folder names for example then Snippets are the perfect tool! This is a short post to share awareness of this awesome feature.
Here is a small script I whipped up while I was bored in the Travelodge waiting for #MongoDBUK. It's basically a drop in script to make sure MongoDB is installed with the default settings, and up to date. Very simple, but it saves running the commands manually each time. I may update this in the future when I find a better way to check if a key is already added before always inserting it #!/usr/bin/env sh # Sudo is required to install everything properly if [ "$(whoami)" != "root" ]; then echo "You need to use sudo to run this command" exit 0; fi echo "Installing MongoDB, please be patient, this could take a few minutes.." REPOSOURCE="deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" REPOFILE=/etc/apt/sources.list # Make sure packages are up to date and key exists apt-get update -qq && sudo apt-get upgrade -qq -y apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 # Append to repo if ! grep -Fxq "$REPOSOURCE" $REPOFILE then echo ": Adding $REPOSOURCE to $REPOFILE" echo "$REPOSOURCE" >> $REPOFILE apt-get update -qq fi # Run install apt-get install -y mongodb-10gen I normally put this in my home folder at ~/install-mongodb then run it using sudo ./install-mongodb. Note that sudo is actually a requirement, and the script will warn you if it you don't have root permissions. I will add more scripts in the next few hours as I go through the MongoDB UK workshops to have simple ways of switching configs for different scenarios and replacing the defaults to enable auth, for example. If you have any cool things you'd like me to write about regarding MongoDB please feel free to ask in the comments.