21 August 2008
I made this bash snippet a little while ago to help me quickly jump around my projects in Terminal.
export PROJECTS="$HOME/Projects"
export PROJECT_ARCHIVE="$HOME/Development/Archive"
p() {
cd "$PROJECTS/$1"
}
p-archive() {
mv "$PROJECTS/$1" "$PROJECT_ARCHIVE/$1"
}
p-restore() {
mv "$PROJECT_ARCHIVE/$1" "$PROJECTS/$1"
}
_p() {
COMPREPLY=( $(compgen -W "$(ls $PROJECTS | sort | uniq | grep -vE \"^_\")" -- ${COMP_WORDS[COMP_CWORD]} ) )
}
complete -F _p p
complete -F _p p-archive
complete -F _p p-restore
Put this somewhere in your .bash_profile so when you open up a new terminal you can type
p <tab>
to access all your projects. Also “p” on its own will take you to your project home folder. Neato timesaver!
14 August 2008
A little while ago I wrote a helpful library called Gravtastic which allows you to easily add Gravatars to your Ruby classes. It features a simple syntax. If you currently use Gravatars I bet your views’ look somewhat like this:
<%= image_tag "http://gravatar.com/#{Digest::MD5.hexdigest(user.email)}" %>
With Gravtastic all you have to do is add:
has_gravatar
to your model (or resource) and now your view can look like this:
<%= image_tag user.gravatar_url %>
You can see a more comprehensive summary of the API at Gravtastic’s GitHub page.
One of the appeals of Gravatars for developers is that they are fucking simple to implement. So why should you bother with Gravtastic? That first view code wasn’t too bad… Well! There are actually lots of Gravatar quirks which Gravtastic bends around. It handles SSL, normalizes emails’ and parses additional options. The code has 100% spec coverage and passes any heckling so it should be pretty quality. As far as I know, Gravtastic is the most feature complete and well tested Ruby library for Gravatarsout there. Kinda overkill, I know, but it works and works well.
Thanks to Matthew Moore, Gravtastic is also listed as a somewhat official plugin.
It has been published as a Ruby gem so to have a play around with it all you have to do is:
gem install gravtastic
Again, the source is up at GitHub for you to fork around with.