RSS

Slides from RS on Rails 2010

0 Comments | This entry was posted on Aug 31 2010

Rs on Rails 2010

On August, 21st of 2010, at RS on Rails 2010, I and Robson Mendonça gave a talk about a game development framework for Ruby called Chingu. Our main goal with this talk was to show that you can have fun with pure Ruby without riding Rails. I believe we successfully achieved that! :D

For those who might have interest, below are our slides (Portuguese only).  Our game’s source code you can find at zukunftsalick’s github.

Ah, one more thing: On September, 12th, I and Carlos Villela will be giving a talk at qCon São Paulo. We’ll be presenting “Especificações de Fora pra Dentro Usando BDD e Selenium 2” roughly translated to “Specifications from outside-in using BDD and Selenium 2″. See you guys there!

View sql queries in your console

3 Comments | This entry was posted on Mar 22 2009

Don’t you think it’s really irritating when, in the console, you are testing your model’s methods and everytime you need to check how each SQL query was formed you need to go to another tab to visualize the log ???

Your frustation is over. Just add the following lines in your .irbrc file:

def log_to
  ActiveRecord::Base.logger = Logger.new($stdout)
  ActiveRecord::Base.connection_pool.clear_reloadable_connections!
end

You can change the method’s name to whatever suits your needs. After that, every time you are in your application’s console you just type log_to and you’re ready to go:

>> log_to
=> []
>> MyModel.count
  SQL (1.8ms) SELECT count(*) as count_all FROM "mymodels"
=> 10

This hint I got it from Pratik Naik while doing pair programming with him at the company I work.

How to Run Just one Test Method from your Terminal

0 Comments | This entry was posted on Oct 01 2008

Many times I found myself running all tests just after modifying just one test method. Depending on the size of your project and its test ratio, it can be a very boring waiting for it to finish.

It can be even worse: Imagine you have other tests failing. How can you improve your productivity ?  Just use the “-n method_name” parameter for the method you want to test.

ruby path_to_your_test_case -n method_you_want_to_test

A real example, I want to test the “test_should_do_stuff” method inside my “stuff_controller_test.rb”:

ruby test/functional/stuff_controller_test.rb -n test_should_do_stuff

Worth remember that stills load your fixtures and preforms setup, it only won’t execute the other test methods.

RailsConf Europe 2008 – Primeiro Dia

2 Comments | This entry was posted on Sep 03 2008

Ontem foi o Tutorials`s Day da RailsConf, mas só hoje que começou oficialmente a RailsConf Europe. Este ano tendo a presença do criador do framework Rails, (David Heinemeier Hansson) para apresentar o Keynote de kick-off da conferência.

No keynote, David falou sobre código legado. A primeira parte da palestra teve um tom mais filosófico, que tem sido (em minha opinião) uma presença cada vez mais constante nas apresentações do David. Ele comentou sobre a importância de termos código legado, que segundo ele, um bom programador é um bom programador se ele tiver escrito bastante código legado. É impossível escrever código que não se torne legado, por isso David defende que código legado deve ser mudado lentamente, sempre que for preciso corrigir algum bug ou implementar uma nova funcionalidade em um código legado, você deve aproveitar a oportunidade para deixar o código melhor e mais bonito. Durante a apresentação ele mostrou exemplos práticos de como refator código legado. O legal foi que ele mostrou isso, usando o código do Basecamp, que é a primeira aplicação feita em Rails, logo código mais legado que isso não tem heheh. Ele comentou sobre a importância de saber onde colocar as coisas em sua aplicação, dando exemplos do que tinha no Basecamp, como um Global Controller, que agregava muitos métodos que só foram parar lá por não saber onde colocar.

Logo em seguida, foi o break e aproveitei pra conhecer pessoalmente o Michael Koziarski que é um dos membros do core team do Rails. Ele é um cara bastante acessível e conversamos sobre o RailsSummit no Brasil. Ele disse que adoraria participar do RailsSummit, mas que tem viajado demais e não iria poder comparecer.

Após o break, escolhi ir na palestra “Hacking the mid-end: Unobtrusive Scripting and advanced UI techniques in Rails” apresentada pelo Michael Bleigh e Chris Selmer, ambos da Intridea. Eles apresentaram, em dois casos de uso, como usar Jquery e comportamento lowpro para manter separados comportamento (funcionamento) e markup de uma aplicação. Basicamente, os dois exemplos trataram de garantir o funcionamento da aplicação com e sem javascript, sem colocar lógica nos views.

Em seguida, assisti a palestra “Rails Software Metrics” feita Roderick Van Domburg da Nedforce, uma empresa holandesa de solucões Rails. Foi apresentado um conjunto de ferramentas para analisar a sua aplicação em termos de métricas de software. Flog, que é uma gem para auxiliar refactoring, falu do Rcov e seu plugin para rails, do Heckle que parece bem legal, pois ele além de analisar a cobertura de testes em sua aplicação, também altera o código dinamicamente. Lembro de ter visto algo parecido em uma palestra chamada “Machucando seu código” que o Fábio Akita disponibilizou traduzida em seu blog. Terminou a palestra comentando sobre o metrics_fu, que são um conjunto de tarefas Rake para usar com o software de integração CruiseControl.rb. Fiquei surpreso com a quantidade de pessoas que disseram usar CruiseControl, assim que possível vou dar uma atenção a isso. É claro que todas essas técnicas de medição de software não valem nada se você não definir metas e procedimentos para analisar elas, caso contrário, serão somente números soltos.

DHH e eu

Após o almoço, assisti “Intellectual Scalability – Solving a large problem with multiple  cooperating rails apps” dada por Frederick Cheung e Paul Butcher, ambos da Texperts. Apresentaram um caso de uso real enfretado por eles na Texperts, onde eles precisaram encontrar uma solução escalável para uma aplicação que iria crescer muito.  A solução (muito semelhante a usar Rails Engines) consistiu em dividir a funcionalidade entre diveras pequenas aplicações. Certo, mas como eles fizeram isso ? Eles mostraram com uma aplicação bem simples o funcionamento do “framework” próprio criado por eles para encarar o problema. Foi uma palestra bem técnica, com bastante código sendo feito ao vivo. Gostei bastante.

Em seguida, não havia nenhum assunto que me interasse e acabei assistindo “Scaffolding an application from schema.rb” dada por Tomaso Minelli. O Tomaso é Italiano e tinha um sotaque carregado, que deixou a palestra um tanto “arrastada”. Foi uma palestra bem iniciante, onde ele apresentous as principais soluções de scaffolding do mercado e apresentou sua própria solucação de scaffolding que é apartir do schema.rb. Ele basicamente redefiniu o método ActiveRecord::Schema.define.

A última palestra o dia foi “Stories on a cloud – Distributed browser testing with selenium” dada pelo Martin Sadler. Com o javascript cada vez mais sendo usado hoje em dia, é preciso termos como garantir que nossas aplicações funcionem bem independente de navegador ou sistema operacional. Ele mostrou o Webrat e RSpec Stories, e logo em seguida mostrou como unir o melhor de cada um atrelando a um servidor Selenium distribuído em vários computadores usando um sistema de mensagens para executar os testes em cada computador. Foi bem bacana, só faltou um exemplo ao vivo pra me convencer.

No momento que escrevo este post, Jeremy Kemper, outro membro do core team, está dando um keynote de encerramento. Se for legal, posto o que ele falou mais tarde.

=D

Portal UCA

0 Comments | This entry was posted on Aug 20 2008

Portal UCA

Está quase pronto o Portal UCA ( um computador por aluno) o qual irá agregar os estudos de caso realizados durante o projeto piloto com o laptop XO.

Após o término do mesmo irei disponibilizar, em alusão ao portal, um estudo de caso de como foi desenvolvido, plugins utilizados, problemas enfrentados e demais questões enfrentadas no desenvolvimento para ajudar quem está iniciando no mundo Rails, pois é uma aplicação bem simples, mas que apresenta bons detalhes pra quem está recém se aventurando com Ruby on Rails.

Outra novidade: irei participar da minha primeira RailsConf e vai ser na europa, mais precisamente em Berlim. Para saber mais sobre a conferência acesse o link que está na minha barra lateral aqui do blog. Pretendo é claro fazer uma cobertura do que eu presenciar por lá, fiquem no aguardo.

Writing Opinionated Software

3 Comments | This entry was posted on Jul 28 2008

Sometimes I got myself thinking what makes a software have its own opinion and be considered “optioned software”. Would it be related to the language philosophy or to the programmer itself, or both of them?

People usually say Rails is a good example of optioned software. I can say I take part of the same opinion, but I’d like to take this point a little more further by not emphasizing only the software, but the programmer and how its culture could be incorporated (and not avoided) in the software it produces.

Out there, in the software market, when hiring people, companies usually claim they give plenty of room for people to innovate, share ideas and try new things and all that cool stuff we usually hear from Googles’s employees about independence and space to build your own skills and develop ideas within the job. But what we found most in the reality is the same copy & paste philosophy everywhere. The programmer usually don’t have time to try new things, because he is stuck with a pile of tedious tasks to complete and the deliverable is always behind schedule, which appears to be a endless cycle, project after project.

I believe, Ruby on Rails came to “save” the people from these kind of starving companies, which likes to hire young and “virgin” employees to mold them to the “Software Factory” style. Ruby on Rails lets the programmer surpass most of the tedious tasks, so it lets the programmer have free time to innovate in other areas of the software. It depends, of course, on the company philosophy, but when companies envise the real profit they can benefit from having a happy employee and tailoring the software for the user real needs, the companies will would like to have adopted the Ruby on Rails earlier.

Ok, but where the programmer opinion comes in ? I strongly believe by having more time to think, the programmer can not only fix issues, but can also suggest new features, test and present them very quickly and best of all, he also can earn more as people usually like to pay for what’s well done.

All in all, writing optioned software is not about yelling what’ s your favorite band, but it’s all about programming and being happy.  I am a happy programmer and you ??

[update 08-01] Thanks Soleone for your suggestion

Ultrasphinx bug?

1 Comment | This entry was posted on Jun 15 2008

It seens Ultrasphinx plugin for Ruby on Rails doesn’t know how to deal with Decimal data type from MySQL.

You can use a Decimal column for indexing, but when you need to make thecolumn sortable it comes the problem. As you know, faceting is on for numeric and date fields and to add the sortable feature to it, we need to pass a hash with

{:sortable => true}

Ok, then you run rake tasks to rebuild your configuration file and indexes and try to sort the search by the Decimal column and we got an error saying our column isn’t sortable.

You can check isn’t generating the _sortable sufix by looking the ultrasphinx configuration file. All other sortable fields have their _sortable sufix added to ti, except by the decimal field.

I’ll report it as soon as possible to Evan Weaver, the plugin’s owner, or maybe try to fix it by myself.

Updated: June, 16

I fixed by adding  ‘decimal’ => ‘float’ in the TYPE_MAP inside the fields.rb file of ultrasphinx plugin.

RELEASED – “Rails 2.1 – What`s new ?” Book

2 Comments | This entry was posted on Jun 09 2008

Book Cover

The Book Rails 2.1 – What`s new ? Made by Carlos Brando and Tapajós was released last week. It was the very first book presenting Rails 2.1 and its new features, in Portuguese, and best of all, it was released free of charge ( like free beer).

But Carlos Brando and the Brazilian rails community were very upset because most Railers of the world couldn`t read portuguese so they couldn`t rejoice the book like us. So I and other fellows, lead by Carlos Brando got together to translate the book to english, so all people could read and use it.

I`m very proud of being part of this community that made the translation and reviewed it in less than 2 days. You can download the book here or from Carlos Brando blog.

I and these guys are who made this task possible, so please thanks us and if you like our work, please recommend us in in Working With Rails:

Rafael BarbosaRecommend
Made Introduction and chapter 1

Caike Souza – Twitter: @caike
Made Chapter 2

Pedro Pimentel (Myself) – Recommend
Made Chapters 3-8 and 10-13

Abraão CoelhoRecommend
Made Chapter 9

Ricardo S YasudaRecommend
Made Chapter 14

And last, but least, don`t forget to thanks and recommends the authors if you haven`t did yet.

Recommend Carlos Brando

Recommend Marcos Tapajos

More information about the original book can be found in Carlos Brando blog.

Download the book here

Open Source Rails

0 Comments | This entry was posted on Jun 02 2008

Para quem gosta de aprender olhando código existente ou prefere não reinventar a roda toda vez que for criar um sistema em rails, temos agora a oportunidade de pesquisar e baixar sistemas rails completos.

A iniciativa é do railer Jacques Crocker, que criou o site Open Source Rails, onde ele compila grande parte dos sistemas rails open source do mercado, como por exemplo, Mephisto, Typo e Lovd By less. Ele convida a comunidade a se cadastrar no site e a mandarem novos sistemas para lá. Vale a pena conferir o projeto e contribuir, pois é importante para a comunidade rails!

Open Source Rails – http://www.opensourcerails.com/

Jacques Crocker – http://www.railsjedi.com/

FISL 9.0 – First day

0 Comments | This entry was posted on Apr 17 2008

XO
That’s me on the right

The first day at FISL (forum internacional de software livre) freely translated as International Forum of Free Software had begun extremely packed with people. The lines in front the main entrance area were huge and the waiting time so long that the event organization decided to allow everybody to access the talks without their credentials.

Our stand booth looks better than i expected, we hanged some XO’s in the roof, turned them on and put it on webcam mode. I wasn’t expecting so much attention to our stand this year, because the XO’s laptops aren’t in the mainstream news, but i was completely wrong. People stops in our booth and still ask a lot about the hardware, software, how we use it in the school and many other questions.

FISL 9.0

I’m also happy with the kick off of the Game Jam 2008 i was organizing. We have 8 teams developing the game right now. I think they are having big fun! Friday night they’ll return the XO’s borrowed to me and i’ll give them to the children evaluation. Like i said, the funniest game is going to be the winner!

I met a lot of people there, maybe most of them i won’t talk again, some other i’ll keep in touch, but there’s one guy i liked very much to know: Fábio Akita, one of the rails gurus here in Brazil. He is a very accessible and easygoing guy. It’s a shame i’m tired and can’t join him and other railers to the pharmacy students party. Maybe next year here at FISL or in a rails related conference.

That’s all for now. Tomorrow begins again!