The Ultimate Vim Plugin
I switched to Vim from Textmate and the hardest feature I had to leave behind was Textmate’s Command-T function. When you type Command-T, Textmate indexes all the files in your working directory and allows you to search for the file you want to edit, just by typing a few letters in the filename. The letters don’t even have to be next to each other, just in the filename. I used this featrue all the time. For instance, if I wanted to open some_class.php, I could search for ‘sc’ and most hit enter to edit the file.
Vim obviously doesn’t have this feature natively, but last night I came across a plugin project on GitHub that adds it! The project is called Command-T and it was pretty easy to install. The only catch I came across was that vim requires ruby support, which I did not have. I had to rebuild vim, which ended up being easier than I expected.
To tell if you already have ruby support:
vim --version | grep ruby
If you see “+ruby” then you already have ruby support. If you see “-ruby” then you are going to need to rebuild. I had to install ncurses-devel, and figuring that our took some googling, but after that, installation was simple:
# ./configure --disable-selinux --enable-rubyinterp
# make
# make install
Then install the plugin and start enjoying Command-T functionality in Vim.
A couple notes from my install:
- I had to add ‘syntax on’ to my .vimrc. It seems that syntax highlighting was the default in my previous version of vim, but not with my new one.
- I added ‘let mapleader = “,”’ to my .vimrc. The default leader key is ’', but I saw a few places that people like to remap the leader key to ’,’ and since that is a much easier keystroke I decided to do the same.
I am still just getting started with this plugin again, but am really enjoying it. If you try out the plugin and find any other great tricks, please share what you find.
Custom domains with Wordpress MU
I have been hosting blogs for my family members for a long time and recently decided to switch over to Wordpress MU. Wordpress MU allows you to maintain one Wordpress installation (one code base, one database, etc) and give multiple users their own blog. It works by allowing you to either choose a subdomain or first level directory for each user’s blog. I wanted to give my family the ablity to have their own domains for a blog - not just be on a subdomain.
I was able to do this by creating (or rather modifying) a special Wordpress MU file call sunrise.php. If a sunrise file is placed in the wp-content folder, it is processed. In it you can override the blog id that WP will use.
With that in mind, my sunrise.php file examines the full URL of the request to determine if it matches any of the custom domains in a special custom domain table.
So if you are adventurous, try to follow my basic instructions for the project and set up custom domains for your blogs too. I will be doing more work on this and will keep the project up to date as I learn more about it.
Let me know how it goes.
jquery's live() vs. bind()
Anyone using jquery’s event methods know a good way to test performance of the various ways to bind events to an element? I am most interested in testing .live(‘click’, function()…) vs. .bind(‘click’, function()…).
My instinct tells me that there would be massive overhead using live() but a few google searches tell me otherwise. I am not sure if I am reading posts by people who know what they are talking about, but they say that using live() allows you to only bind one event and then let jquery handle the event dispatching. Sounds reasonable, but then it also seems like additional overhead of having the browser fire an event on every single click, for example, and then making jquery figure out if the event matches something you are interested in.
CSS Sprites
When I first tried out Compass I was drawn to the project because it turned the art of creating CSS into something I could really understand as a programmer. I like being able to write functions that reduce the amount of code I have to write. After writing just a few lines of SASS, I figured that generating sprites should be a function of SASS. You should be able to add the image as if it were a standalone image and when the SASS file is processed all the images in the file should get turned into a sprite. All the offsets should be calculated for you. I was dreaming.
After doing a little searching around github, I found a project that looks to be really close to what I wanted. Sprite takes a config file and generates a sprite for you. It then creates the CSS or SASS mixin for you! I am looking forward to trying this project out.
Anyone know of a better way to incorporate sprites into your development? While this sounds easy, I am not going to stop looking until I find an even easier sprite method.
Update 02/25/2010: I am not as experienced installing ruby gems as I would have hoped. I am stalled on playing with this project as I try to get RMagick installed. I think the problem is with my install of ImageMagick, but need to keep investigating. I have install ImageMagick from both source and binary and it makes no difference. I am hoping to get some time this weekend to really dig into it and get something working.
My favorite thing about Jekyll
For a few months I have been searching for a vim plugin that would allow me to post to my Wordpress blog directly from vim. There is a ruby-based Textmate bundle that would allow for blogging from Textamte, but I couldn’t find a suitable replacement for vim. The beauty of Jekyll is that since posting is handled by creating a text file, you are free to use any text editor you choose - in my case vim! I now need to find a good markdown vim plugin (hopefully for snipmate) to make blogging here even easier.
Ok, enough writing about Jekyll. My one day infatuation with it is over. Going forward I am going to use this site to write about purely technical topics and hopefully start writing and sharing code on github. If you want to know what I had for lunch follow me on Twitter and if you want to know a minute by minute recount of what I did this weekend, read my personal blog. Enjoy!
Setting up your own Jekyll blog on github
I set this blog up yesterday in a about two hours yesterday. Over half of that was spent reading through documentation on how to get these projects installed and how to use the github hosting service. In the interest of saving someone else some time, I wanted to share how I set everything up.
The first thing that should be noted is that you don’t have to set anything up. You can just fork my project, remove my posts, edit the _layouts and start adding your own posts. When you push your posts to github, they automatically run the files through Jekyll and create your static site. The only reason you need to Install Jekyll is if you want to deploy your site somewhere else or if you want to do a lot of customization to your templates - local development is a lot easier than pushing every single change to github to see how something looks.
I setup the projects in a CentOS VMWare instance because CentOS has some great tools for installing what is needed. If you are on a Mac you could probably also use Homebrew to get stuff setup easily or install from source. I don’t trust random snippets of code I find on the web enough to trust them on my actual machine, so sandboxing them in a virtual machine allows me to play around without worry of screwing anything up.
I first installed Jekyll following these intstructions. My OS didn’t come with ruby and rubygems so I needed to run a quick ‘yum install ruby rubygems ruby-devel python-pygments -y’. Pygments is a python project that adds line numbering if you use certain liquid syntax in your posts. Github renders using pygments by default so I figured I would set it up locally too.
After Jekyll is installed you can start creating your site. The first thing you should do is setup your git repo.
- Create a new repo at github named your_name.github.com
- Follow the instructions provided by github to set up your local repo.
- In that repo run ‘jekyll’
- Take a look at my _config.yml and .gitignore. Neither is needed but help. Jekyll is going to create your site locally, but since github also creates it when you push to them, you don’t need to send them the static files. When I first started playing with this stuff, I set up the project to only send github my staticly-generated files. This worked, but since they run everything through Jekyll and this is the “right” way to do things I decided to follow the new setup.
- Start Jekyll in your root project dir with ‘jekyll –server’. Any changes you make to your files will automatically get picked up and deployed to your local site.
Now that you have Jekyll set up, you should start creating and modifying your layouts. I found that looking at other layouts was the easiest way to set up my own. Layouts are basically HTML with a little bit of liquid templating thrown in.
When you are ready to start blogging, you create a new file in your _posts directory named ‘yyyy-mm-dd-title-of-your-post.extension’ where extension can be .html, .markdown or .textile. You choose how you want your post rendered and Jekyll does the rest. I like Markdown because it is so easy to use, but the others would work fine too.
After you create your first post, you need to commit (git commit -a -m ‘my first post’) and then push (git push origin master).
That’s all there is to it. Your site is now live at your_site.github.com. Please let me know how this worked out.
Hello, World
Here is the obligitory hello world post for this new blog. I was more intersted in trying out a few github projects than starting a new blog, so don’t be surprised if this is the only post you see here.
The following projects were used to create this blog:
- Jekyll - a blog-aware, static site generator in Ruby
- Compass - a Stylesheet Authoring Environment that makes your website design simpler to implement and easier to maintain.
Jekyll is a pretty cool blog engine that combines templates and post files to generate static files for the blog. It was a pretty easy install and after looking at a couple template examples of fellow Jekyll users, my (basic) templates were a snap to create.
Compass is another cool project I have been wanting to use for some time. Compass is a CSS framework that takes sass files and creates the CSS. Sass is a HAML based CSS language.