Although I haven't abandoned TextMate as my editor of choice for day-to-day coding, I have been taking the time to really learn Vim and all it can do. I've used Vim for 10+ years, but with only the most basic of commands for editing files on remote servers, or quick changes to various config files. As I learn more, I'm finding that Vim can do just about everything I'm used to in TextMate, and in some cases, more.
I've been using MacVim for learning, which is a full-featured, native app for OSX. It has built in support for everything you want to do or add on: 256 colors, Ruby support, etc. But if you're in Terminal.app and fire up vim, you'll find that some of your (my) favorite plugins that work fine in MacVim, do not work (specifically: Command-T needs Ruby support, and ConqueTerm needs Python support). The default Vim install in OSX lacks a lot of the niceties that come by default with MacVim. Here's how I built a new version of Vim for using in Terminal.app.
The Vim download page suggests using Mercurial to fetch the latest version of the source if you want to compile it yourself. Here are some options for installing Mercurial on OSX. Once that's done, you'll want to find a place to fetch the source. I put mine in ~/tmp/.
# fetch the source into a vim directory
hg clone https://vim.googlecode.com/hg/ vim
cd vim
# make sure you're up to date
hg pull
hg update
Now that you have the latest version of the source, it's time to compile your own version of Vim:
# configure to install in /usr/local/bin and make sure Ruby and Python
# support are built in
./configure --prefix=/usr/local --enable-rubyinterp --enable-pythoninterp --with-features=huge
# build
make
# after it's finished building, you can double check that the support you
# want is now built in with this command:
./src/vim --version
In the output from that command, you should see +ruby and +python which signifies that both Ruby and Python support are built in, and that's what I needed. Since the newly built Vim is what we want, install it:
make install
In order to make sure that this Vim is used when typing vim at the command line, make sure that /usr/local/bin comes first in your path. This way our full-featured Vim at /usr/local/bin/vim will be called instead of the OSX built-in version at /usr/bin/vim. For reference, this is how I set path in my ~/.bashrc:
export PATH="/usr/local/bin:/usr/local/pgsql/bin:/usr/local/php5/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
And now you have a version of Vim that should allow you to add on just about any plugin available. But, if you want to take advantage of themes with 256 colors, you won't be able to do that in Terminal.app, but a replacement like iTerm2 would work just fine.
If you ever need to recompile a newer version, or just to try some different configuration options, you'll need to clean up the build directories and update the source beforehand:
# thoroughly clean the source tree
make clean
make distclean
# update vim source
hg pull
hg update default
Then you can proceed with the configuration and build steps above.
References:
My last post on installing MongoDB on Ubuntu is quite popular. Sadly, they aren't the best, or the most up to date installation instructions. While I don't really mess with MongoDB anymore, I feel a little bad with so much traffic coming from Google to those outdated instructions. In fact, it's super easy to install MongoDB on an Ubuntu server these days.
Basically, all you need to do is add a new source to your /etc/apt/sources.list. For the latest Ubuntu (10.10 at the time of this post), you'll add:
deb http://downloads.mongodb.org/distros/ubuntu 10.10 10gen
Once you've added the new source, you'll need to import MongoDB's public GPG key in order to download from the official servers:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
Once that's done, run sudo apt-get update and then sudo apt-get install mongodb-stable to get the latest stable release. Once installed, you can configure via the configuration file at /etc/mongodb.conf.
The full instructions, including the source URLs for older Ubuntu/Debian versions, can be found on the MongoDB website.
Edited 12/15/2010: Added the GPG key step.
As I get a little more comfortable with how Jekyll works, I've found a few Bash aliases that have been helping out. Below are four aliases I have set up to make blogging with Jekyll easier (with a little explanation for each).
# let's write an entry (cd to path and open up TextMate)
alias timetoblog="cd ~/code/blog && mate ."
# start up Jekyll for local preview of blog
alias serveblog="cd ~/code/blog && jekyll --server --auto"
# delete the existing built site and rebuild
alias buildblog="cd ~/code/blog && rm -rf _site/ && jekyll"
# use rsync to push the weblog to my host
alias deployblog="cd ~/code/blog && rsync -rtz --delete _site/ username@host.com:~/path/to/weblog/root/"
Each of these assume a little on how you have Jekyll configured, so you will have to adjust each for your own setup. You can see my own configuration options on Github.
Some of these tips originally came from the Jekyll wiki and various weblog posts.
I'll keep this short: I've yet again relaunched the weblog using yet other kind of weblog software. There are several not-so-well thought out reasons for changing everything again, but the main ones are:
- Since I didn't write this software, I won't be too tempted to rewrite it
- I have other ideas I'd rather be working on instead of rewriting weblog software (which I seem to have a problem with)
- Jekyll generates static files, which should lessen the load on my VPS
This one should hold me over for long enough. At least long enough to write another post.
Given my recent interest in MongoDB, I figured I should update my Ruby backup script to now support the exporting and backing up of MongoDB databases.
I've updated the code and placed the changes up in my Github account: simple-s3-backup.
EDIT: Please take a look at some updated instructions. The information here is a bit out of date, and makes things a lot harder than it needs to be.
There are already a few installation tutorials for getting MongoDB up and running on an Ubuntu server, but each either left a step or two out, or their suggested setup wasn't what I was looking for, so I'm sharing my own tips. But, a few notes first:
- These instructions are how I installed MongoDB on Ubuntu 8.10 (Intrepid Ibex)
- Many of the tutorials out there recommend putting MongoDB in
/opt/mongodb, but I chose /usr/local instead
- These instructions worked for me, and they probably will for you, but I can't guarantee a thing
Initial user and directory setup
Before installing anything, I'm going to prepare some necessary directories and create the mongodb user:
sudo adduser mongodb
# for the mongodb data files:
sudo mkdir /var/lib/mongodb
# for the log files:
sudo mkdir /var/log/mongodb
sudo chown mongodb /var/lib/mongodb/
Install dependencies
Install the needed dependencies for building MongoDB from source:
sudo apt-get install curl tcsh scons g++ xulrunner-1.9-dev libpcre++-dev libboost-dev libmozjs-dev
Now, the Mozilla JavaScript libary. I normally install from my own temp directory (~/tmp), but download and compile from wherever you're comfortable:
curl -O ftp://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz
tar zxvf js-1.7.0.tar.gz
cd js/src
export CFLAGS="-DJS_C_STRINGS_ARE_UTF8"
make -f Makefile.ref
sudo JS_DIST=/usr make -f Makefile.ref export
Build MongoDB
We'll use git to clone the source from their GitHub repository. I'm also going to compile the 1.2.2 release instead of the current HEAD. Again, get the source and build from whichever temp directory you're comfortable with.
git clone git://github.com/mongodb/mongo.git
cd mongo
# checkout the 1.2.2 release for building
git checkout -b build r1.2.2
# build:
scons all
# install:
sudo scons --prefix=/usr/local install
Now, create the init.d script file to have MongoDB start up on a reboot.
sudo vi /etc/init.d/MongoDB
# my version of this script is here: http://gist.github.com/291349
# make init script executable:
sudo chmod +x /etc/init.d/MongoDB
# set up runtime links:
sudo update-rc.d MongoDB defaults
And to get it up and running, just run the init script:
sudo /etc/init.d/MongoDB start
If all the steps above went without any problems, then MongoDB should now be up and running on your Ubuntu server.
Here are some references that helped a lot in getting my own setup working:
Now, what I'm using MongoDB for will have to wait a day or so. :)
After reading about the troubles Jeff Atwood had with his host going down, I figured it was time I get a real backup process in place for my own data. Since my hosting is self-managed (at Slicehost) without any sort of attached official backup plan, I'm definitely vulnerable to any sort of server failure. I've had a near miss a couple of times with personal computers--which I now back up often--but I've yet to set up anything recurring for my hosted files.
So, I took some time over the weekend and wrote a simple backup script with Ruby that saves the archive files to Amazon S3. A while back I tried something similar using rsync, but at the time I stumbled on setting the SSH keys and all that up. Since I'm now using S3 to host images for The Tools Artists Use, adding another "bucket" to store some backups was a no-brainer.
The script works for me, and since it may be useful for others, I've put the code up on my Github account: simple-s3-backup.
Well, I did it. I killed the old weblog.
I didn't just change weblog software (although I did do that, too), but I'm getting rid of all the old posts. Half of them are outdated and the rest were sort of useless. It want to start somewhat fresh again.
In a few days, I'll have something a little more substantive on the big switch. Until then, welcome to the new brilliantcorners.org!