New project published

Ruby code repository at Bitbucket.orgI have recently published a small project at Bitbucket, called “view_reports”. This small project allows people to connect to a database and get a tiny report of a table from that database. The main key is that uses Yubikey [1] [2] for two-factor authentication (a Yubikey and a PIN). Other than that is a very simple application now (and I want to keep it like so). I have used Sequel, Sinatra as main components. Comments are very welcome :)

Cheers :)

Posted in Programación, Ruby, Software, Software Libre | Tagged , , , , | Leave a comment

Me suena este portátil

librebootx200Hoy me entero de que el portátil que utilizo para trabajar (con el que estoy encantado por cierto) está avalado por la FSF. Leyendo la noticia en veo además que la configuración avanzada es muy similar a la que tengo yo: 8GBs de RAM, disco SSD, etc.

Este línea de portátiles (la X y también la T) de Lenovo son muy agradables de uso, robustos, troteros y con prestaciones mas que suficientes para un uso habitual. Yo he conseguido localizarlos a través de varios proveedores, ya que se suelen retirar de empresas que los tenian en renting y demás.
Además, Lenovo (al menos las series X y T) están enfocadas al uso profesional y disponen de multitud de elementos para complementar el propio portátil, además de manuales de uso y reparación que denotan bien a las claras para que se han construido: para ser reparados, y no para ser tirados a la basura ante el menor problema, como sucede con otros fabricantes o modelos.

Si te encuentras uno por la calle, no lo desprecies porque sea negro y cuadradote, al contrario: dale cariño y verás como el también te cuida :D


Posted in Ubuntu | Leave a comment

Query SQLite looking for boolean records

rubyToday I have needed to ask an SQLite DB to get some records with a field set to true, and all my first attempts to do it have been failed. Finally I have achieved it, and I would like to share this little achievement :)

NOT working:

Model.find(:all, :conditions => 'field = true')

NOT working:

Model.find(:all, :conditions => 'field = "true"')

NOT working:

Model.find(:all, :conditions => 'field = 1')

NOT working:

Model.find(:all, :conditions => 'field = "1"')

and finally working:

Model.find(:all, :conditions => 'field = "t"')

The solution has consisted on looking at DB level, which is the real data stored on it. Cheers :)

Posted in Programación | Tagged , , , , , , , | Leave a comment

Dinamyc callbacks on Rails, is it possible?

Today I have tried to do this: let any application application, and among all the tables to storage the data of your model estructure, there is one called “Configuration”. As you can suspect, this table will storage some configuration options for your application. For some configuration options you need to execute certain code, and here is what I’ve tried:

class Configuration < ActiveRecord::Base
# These next lines are related to Hobo gem, and are just 
# an expression to define the model (you can imagine what they do for sure)
  fields do
    name :string
    value :string
    callback :boolean, default => false
    callback_name :string

after_update self.callback_name.to_sym, :if => self.callback?
... here comes the definition of each callback ...

For some reason this is not allowed. I think this is a nice solution to hook configuration options within code, but it doesn’t seem to work :/

If any of you get something like this working, please let me know, I will own a beer (no alcohol obviously :)

Cheers, Ibon.

Posted in Programación | Tagged , , | Leave a comment

Capybara screenshot on ancient Rails 2.3.X projects

Recently I’ve been playing with some tests on an old Rails Project. In terms of actual Computer Science Mesure Units or CSMUs, this is quite old (remember that one CSMU is the time used by a user to change his/hers iPhone :)

Some failures on the test forced me to look up for some solutions and Capybara-screenshot was one of the elected ones, instead of being playing around with messages on the log file. The sad side of recent versions of this gem is that it seemed not to play well with Rails 2.3 infrastructure. There is a Rails 2.3 compatible version but some of the usual methods of Capybara-screenshot were not working well.

What I have founded is this recipe running for me: install capybara-screenshot 0.3.14, then require it on your spec_helper.rb file. When your test fails the screenshot is not being automatically taken (at least in my case), but you can use it manually, before the offending line by putting “screenshot_and_open_image” :)


Posted in Programación | Tagged , , , | Leave a comment