Katipo
Search  
Site Blog
  About  
  Home
About Portfolio Solutions Client Area Contact Us
: : About Us
Awards
Jobs
Our People
What Is A ... ?
Working From Home
News
Photo Gallery
Katipo Blog


Archive for January, 2009

Make Rails logger available in code normally outside of logger scope

Saturday, January 24th, 2009

Here’s a quick one. Say you are debugging a bit of code in a plugin that doesn’t fall under the Rails app you are working on’s ActiveSupport context and thus “logger.debug” is not available to you.

You could write up your own logging mechanism, with or without using the Logger gem. However, if what you are working on is run by the Rails app and thus has the apps global constants available, you could simply tie it into the existing logger object in the Rails app like so in your file:

logger = RAILS_DEFAULT_LOGGER

Then you can use logger.debug, logger.info, etc. to your heart’s content. One caveat, if you are working on a gem or a something more general that won’t necessarily always be run in the context of Rails, then you will want to pull your use of logger out before distributing your code. Otherwise you add a dependency on Rails that you may not intend.

Adding Gist commands to emacs

Thursday, January 15th, 2009

You have to give Logical Awesome credit for how much work they do to integrate GitHub’s services with tools that developers use.

The Gist service is a good example. First they added command line support for it, then they simultaneously added in-editor support in Textmate, vim, and my own personal favorite emacs. The blog post announcing gist support in emacs and vim is here.

So how do you add the gist support to emacs?

First, you’ll need an account on github.com and have set up your ~/.gitconfig as outlined in here.

Then download or clone the gist.el file from http://github.com/defunkt/gist.el, copy only the gist.el file from that repository to someplace in your emacs load path (in my case /Users/walter/Library/Preferences/Aquamacs Emacs/ because I use Aquamacs on a Mac), and add a line to your ~/.emacs file or in my case /Users/walter/Library/Preferences/Aquamacs Emacs/Preferences.el that looks like this:

(require ‘gist)

Then you have to either restart your emacs program or do M-x load-library and answer prompt with gist for the new gist commands to be available.

Now you have M-x commands like these:

gist-view-gist
view gists after they’re posted
gist-region
Post the current region as a new paste at gist.github.com
Copies the URL into the kill ring.
gist-region-private
Post the current region as a new private paste at gist.github.com
Copies the URL into the kill ring.
gist-buffer
Post the current buffer as a new paste at gist.github.com.
Copies the URL into the kill ring.
gist-buffer-private
Post the current buffer as a new private paste at gist.github.com.
Copies the URL into the kill ring.
gist-region-or-buffer
Post either the current region, or if mark is not set, the current buffer as a new paste at gist.github.com
Copies the URL into the kill ring.
gist-region-or-buffer-private
you can probably guess…
gist-fetch
Given an gist id, fetches a Gist and inserts it into a new buffer
If the Gist already exists in a buffer, switches to it.

Very useful stuff for collaboration, but without leaving your editor.

Enjoy,
Walter


Katipo
Rachel Snowboarding