FeelingRoot

M-x geek-food

Entries Comments


WYMeditor is not defined – 0.5rc1

18 September, 2009 (00:56) | Ruby on Rails |

Hi folks, I am sorry I can’t find time to write more often but there it goes:

If you’ve been trying to get WYMeditor 0.5-rc1 running with rails 2.3.x and you get this error in your firebug console:”WYMeditor is not defined” here’s how you fix it:

Go ahead and open up wym_editor_helper.rb and swap these 2 lines:

output << javascript_include_tag(’/wymeditor/wymeditor/lang/en.js’)
output << javascript_include_tag(’/wymeditor/wymeditor/jquery.wymeditor.js’)

so that they look like this:

output << javascript_include_tag(’/wymeditor/wymeditor/jquery.wymeditor.js’)
output << javascript_include_tag(’/wymeditor/wymeditor/lang/en.js’)

That should get rid of that annoying warning.

Cheers,

Cezar

Emacs etags for Rails projects

24 March, 2009 (05:40) | Emacs, Ruby on Rails | 8 comments

Here’s a rake task I am using for every project to build up an emacs TAGS file using exuberant ctags on os x.

module Tags

RUBY_FILES = FileList['**/*.rb'].exclude(”pkg”)

end

namespace “tags” do

task :emacs => Tags::RUBY_FILES do

puts “Making Emacs TAGS file”

sh “/opt/local/bin/ctags -e #{Tags::RUBY_FILES}”, :verbose => false

end

end

task :tags => ["tags:emacs"]

So the way you use is by going to the project’s root folder and type rake tags:emacs.
I hope you will find this handy.

Installing memcached 0.12 and libmemcached 0.25 on OS X 10.5.6

18 February, 2009 (00:52) | Ruby on Rails |

Today I had to install these specific versions of the memcached gem (0.12) and libmemcached (0.25). So first off, macports (uodated today) comes with libmemcached @0.26 so in order to get the @0.25 version I had to manually fetch the Portfile from an earlier revision and add it to macports sources. Here’s how you do that:

1. Set up a local port repository

sudo su

cd /opt/local/etc/macports/

add “file:///Users/Shared/dports” to sources.conf beforersync://rsync.macports.org/release/ports/ [default]

2. Install the port into your local repository

cd /Users/Shared/dports

svn co –revision 42743 http://svn.macports.org/repository/macports/trunk/dports/devel/libmemcached/ devel/libmemcached/

portindex /Users/Shared/dports

3. Now you should be able to see @0.25 in the listing with @0.25 showing first (the order is important)

port list libmemcached

libmemcached                   @0.25           devel/libmemcached

libmemcached                   @0.26           devel/libmemcached

4. Go ahead and install libmemcached @0.25

port install libmemcached

Now that libmemcached is installed we need to install the memcached gem:

ARCHFLAGS=”-arch i386″ gem install memcached –version ‘0.12′ –no-ri –no-rdoc — –with-opt-dir=/opt/local/

That should be all! Let me know if you have any problems.

LivePipe’s TABS.js and REST anchor tags in Rails

21 January, 2009 (01:36) | Ruby on Rails |

This is the first in the series of small tutorials; stuff that I pick up on a daily basis as I write my rails apps, mostly things that are not so obvious from the API docs and pretty hard to find by searching on google.

The problem:

So the problem I was facing was how to use the anchor tags in Rails and stay RESTful to preselect a specific tab using LivePipe’s tabs.js.

The solution:

It turns out that there is an “:anchor” option that you can provide to link_to like so:

<%= link_to ‘Go to tab’, edit_user_path(@user, :anchor => ‘name_of_the_anchor’) %>

IM from GNU Emacs with BitlBee

11 September, 2008 (17:34) | Emacs |

It’s time for some more geek fun with Emacs. This time I’m gonna show you a simple way to chat with your messenger friends across XMPP/Jabber (including Google Talk), MSN Messenger, Yahoo! Messenger, AIM and ICQ, all without leaving Emacs.

Things you will need:

  • GNU Emacs (of course)
  • ERC (emacs IRC client)
  • BitlBee server (you can download/install it from http://www.bitlbee.org/main.php/download.html)

So here we go:

To install bitlbee on Ubuntu you can do : sudo apt-get install bitlbee. And to start it: sudo /etc/init.d/bitlbee start.

On OS X if you are using macports you do: sudo port install bitlbee. And to start it: /opt/local/sbin/bitlbee -D.

You can of course configure it by copying and customizing the sample config file that comes with BitlBee but for this simple example we’ll stick to running BitlBee without a config file.

Now that BitlBee is started you can connect to it from any IRC client, but for the purpose of this post, I will choose ERC because it’s nice IRC client for GNU Emacs.

In GNU Emacs do: M-x erc <RET>, type “localhost” for IRC server, leave the port unchanged (6667), chose a nickname (or username) and hit <RET>.

You should now be connected to the bitlbee server running on localhost.

Once you’ve connected to your server (or a public server) you need to register your account and then create a list of the outside IM accounts you want to use or have access to. To register (whether on public or private server) use:

register [password]

After you’ve registered your account on your new server you simply add your accounts.

For Yahoo: account add yahoo handle password <RET>

For MSN: account add msn handle password <RET>

Jabber (Gmail): account add jabber example@gmail.com password talk.google.com:5223:ssl <RET>

All that remains now is to connect to all those accounts, and you do that by typing : account on <RET> and save <RET> to save the above settings.

A few usefull BitlBee commands to get you started would be:

To refresh your buddy list: blist <RET>

To message a buddy: /msg username message <RET>

And of course you can always find more on the BitlBee homepage.

Better window management with ElScreen

11 August, 2008 (12:55) | Emacs | 6 comments

Today I stumbled upon a sweet little mode for GNU Emacs called ElScreen. The nice thing about it is that you can have multiple window setups in one frame. I use it to keep my gnus windows (usually two, the summary buffer and the message window) and my coding window separate from each other then I can easily switch between them by hitting C-z n (Switch to the “next” screen in a cyclic order) and C-z p (Switch to the “previous” screen in a cyclic order).

There are also a number of very useful shortcuts for working with setups (tabs – as ElScreen displays them):

  • C-z C-c  Create a new screen and switch to it.
  • C-z C-k  Kill current screen.
  • C-z C-n  Switch to the “next” screen in a cyclic order.
  • C-z C-p  Switch to the “previous” screen in a cyclic order.
  • C-z C-a  Toggle to the screen selected previously.
  • C-z 0  Jump to the screen number 0-9.
  • C-z C-w  Show a list of screen.

You can get ElScreen from this ftp address: here.

Installation is very simple, just copy the file elscreen.el into a directory in your path and add this line to your .emacs file (load “elscreen” “ElScreen” t).

from a terminal do:

[code lang="bash"]

cd ~

wget -c ftp://ftp.morishima.net/pub/morishima.net/naoto/ElScreen/elscreen-1.4.6.tar.gz

tar -xzf elscreen-1.4.6.tar.gz

cp elscreen-1.4.6/elscreen.el ~/.elisp/

[/code]

in .emacs add:

[code lang="lisp"]

(add-to-list 'load-path "~/.elisp/")

(load "elscreen" "ElScreen" t)

[/code]

I hope you find this useful and drop me a line if something is not working right.