Scoped Thoughts

Felipe Rodrigues's blog

Setting-up clojure, clojure-mode and slime with Common-Lisp on Emacs

I've been working a lot with lisp lately. I was basicaly using scheme to follow the SICP course described here.
Yesterday I started to read Programming Clojure from Stuart Halloway
So, as an emacs user the first thing I did was look for a clojure-mode. Found one at http://clojure.codestuffs.com/. In fact found more than just a mode, found a slime/swank for clojure. I decided to install it.

First thing to do was install ELPA (http://tromey.com/elpa/install.html), by evaluating (it means pasting the code and press C-j) this code in my *scratch*:

Then I only had to list the packages with

M-x package-list-packages

and then:
M-x package-install

This last command will ask you the name of the package. Type clojure-mode.
After that, the clojure-mode will be installed. The next step is to install the slime/swank for clojure. Once the clojure-mode is installed, it is pretty easy to do:
M-x clojure-install

The installer will ask you where you want to install clojure. I choose /opt/clojure.
Now let's hack our personal emacs configuraiton to enable sbcl (Common Lisp) in our slime.

First, If you didn't choose the default location for clojure (like my case), you will have to add the following line in your .emacs file:

And that's it. When you need to use sbcl (Common-Lisp) you must run:

M-x slime

when you need to run clojure do:
M-- M-x slime

This will make slime ask you what lisp you want to start (tab for auto-completion). If you type clojure it will open the Clojure's REPL, if you type sbcl it will open Common-Lisp REPL.

To finish I don't like to type java -cp clojure.jar clojure.main to start clojure or even to run some script. So I used the clojure-extra found at http://clojure.codestuffs.com/
Added this file to my $PATH variable and created the file .clojure.conf in my home directory, like that:

You can customize and add things as you wish to your classpath by editing this file.
Done, now you just type clojure and the Clojure's REPL will show up. Have a happy hack.

A simple date_select matcher for cucumber with webrat on rails

Media_httpcukesinfoimagescukelogopng_eiypgoeydjjduca

I was working on my project when I decided to check if a date_select was returning with the same value when the model had errors.
My surprise was that webrat have nothing like that on the webrat_steps.rb, so I decided to scratch my itch.

That is pretty simple and could even be improved, but works fine. On your steps definition file add the following:

Done! Now you can use that on you @.feature@ files just like that:

Good luck with your specifications!

Media_httpimg294imageshackusimg2949791cucumberhuntjpg_onduibxqdcwcfpe

Ruby 1.9.1, MySQL and Rails on Ubuntu 9.0.4

With the release of Rails 2.3.3 I decided to upgrade my rails projects. Not enough, I decided to upgrade to Ruby 1.9 as well.
So, here is my first impressions:

Ubuntu packages don't have a stable version of Ruby 1.9. They are still offering 1.9.0 and I heard 1.9.1 is much better and stable.
The solution was compile and install from the source.
so, just:

wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz

Then just:
tar xzf ruby-1.9.1-p243.tar.gz

and
cd ruby-1.9.1-p243

and
./configure

and
make

and
sudo make install

If everything went fine, you can just remove the src folder where did extracted you tar.gz. This will replace your ruby commando, pointing to ruby 1.9.1. To check that, please, verify with
ruby -v

Now you just need to install some gems to make your new ruby world rock. First, install Rails:
sudo gem install rails

 Then, install your database adapters gems:
sudo gem install sqlite3-ruby pg

For mysql, try this: (Wasn't working when I wrote this post)
sudo gem install mysql

If don't work, then you will have to build it from source. Project page at http://www.tmtm.org/en/mysql/ruby
So
wget 'http://rubyforge.org/frs/download.php/51087/mysql-ruby-2.8.1.tar.gz'

then untar the file with
tar xzf mysql-ruby-2.8.1.tar.gz

access the directory you just extracted and do
ruby extconf.rb --with-mysql-config

and
make

Before finish, you can run a test to make sure it works. (You will need to install the test-unit gem):
ruby ./test.rb -- localhost your_user its_password the_database

If everything works as expected, just issue
sudo make install

And that's it. Hope it works well for you and you can enjoy the performance of Ruby 1.9.1

Filed under  //   mysql   rails   ruby   ruby 1.9.1  

Structure and Interpretation of Computer Programs at YouTube

Here goes a great series of class available at YouTube. It is a Berkley course based on the great book Structure and Interpretation of Computer Programs.
I came in greate time, since I'm studying Clojure.

 By the way, don't forget to check the other 19 classes on the right bar of this youtube video.

 

Filed under  //   functional programming   lisp   scheme  

Rails Magazine: A lovely initiative

I've in contact with rails community more frequently lately since I started a new rails project. Before that I was in some Groovy/Grails and Java projects.

Grails and Rails are so similar and both can do basically the same thing. Of course there are situations where one of them will be a best fit for some project.
Besides the technical differences are not so big, the concept of how do things in the framework are not so big either.

The big difference comes in form of community. The rails community is bigger and better than Grails. I don't want in any aspect to degrade the Grails community. They are just like any open source community. But rails community is just different. There are some idealism and they  honor  that in each blog post or each initiative.

A great example is the Rails Magazine. They have a great magazine with actual articles and still offers the PDF version for free (check http://railsmagazine.com/).
Now, Groovy/Grails has a great magazine as well (http://groovymag.com/) but these are not free. The difference in this case is that for Groovy Magazine you have to pay USD $4,99 for the PDF version.

What others differences you see from these communities? What you have to say in favor of Groovy/Grails community?

PS: Please, note that I'm not saying that GroovyMag is wrong in charge. They have this right. I just want to highlight how free and idealist is the Rails community using this example.

Railsmagazine128x128

Filed under  //   community   rails  

How about posterous?

I'm not sure yet if I'm confortable with posterous. Looks a interesting idea, but I think I would have to forget about my custom design. At least for now. So, what are the diferences from use posterous and blogger or word press? I still have to figure out.

This unconfort is probably caused by my need to control everything (techincal). I'm looking for a Blog engine, but somehow, the so used engines, ready to use are not the same as somehting I created or at least that I installed. That's why I'm thinking on Mephisto.

Anyway, I'll probably let you all know where I'll publish my notes.