xvfb backround info
X Virtual Framebuffer
http://de.wikipedia.org/wiki/Xvfb
e.g. use it to create screenshots.
For a basic implementation, see this:https://github.com/leonid-shevtsov/headless/blob/master/lib/headless.rb
Working in Cucumber with New lines and have_content
Problem:
expected there to be content "\n2\n" in "\n2\n" (RSpec::Expectations::ExpectationNotMetError)
Research:
https://github.com/jnicklas/capybara/issues/56
Answer: WTF!
Solution:
page.find(".#{count_name}-count").text.strip.should == "\n#{count}\n"
Ruby Interactive Editor
just stumpled upon this in the redmine gemfile
Extracting the filename of a url, that can have additional params
/\/((?:[\w\-\_]+\.\w{3,4}))(?:\?.+)?$/
or vs ||
i never use 'or' so i found this interesting.
Beginner Error in Rails: confusing an attribute of ActiveRecord instanze with an instance variable
As Ruby programmer you are used to write code like this, if you want to have a default value or rather make sure, that something is an Array or Hash, in order to rely on that for later treatment
def filters
@filters ||= { }
end
In Active Record that does not work, cuz:
@query.instance_variable_get :@filters
=> nil
@query.attributes
=> {"name"=>"_", "column_names"=>nil, "group_by"=>nil, "project_id"=>1, "sort_criteria"=>nil, "user_id"=>0, "search_mode"=>"all", "filters"=>{:subproject_id=>{:value=>[], :operator=>"*"}}, "is_public"=>false}
there is also obie's great post about this: http://www.jroller.com/obie/entry/default_values_for_activerecord_attributes
just for fun defining ruby modules inside classes
Usually you would rather define classes inside modules, but if you are left with a class and you want a module namespaced....
suung@q2:~$ suung@q2:~$ irb irb(main):001:0> class Foo irb(main):002:1> module Bar irb(main):003:2> def baz irb(main):004:3> puts 'baz' irb(main):005:3> end irb(main):006:2> end irb(main):007:1> end => nil irb(main):008:0> lass Baz NameError: uninitialized constant Baz from (irb):8 from :0 irb(main):009:0> class Baz irb(main):010:1> include Foo::Bar irb(main):011:1> end => Baz irb(main):012:0> Baz.new.baz baz => nil irb(main):013:0>
Something is a valid calculation parameter (number so to say)
irb(main):013:0> "22.2".match /^\d+(\.\d+)?$/ => #<MatchData "22.2" 1:".2"> irb(main):014:0> "22.".match /^\d+(\.\d+)?$/ => nil irb(main):015:0> ".22".match /^\d+(\.\d+)?$/ => nil irb(main):016:0> "2.2".match /^\d+(\.\d+)?$/ => #<MatchData "2.2" 1:".2"> irb(main):017:0> "2..2".match /^\d+(\.\d+)?$/ => nil irb(main):018:0> "2.2.2".match /^\d+(\.\d+)?$/ => nil
Schema Free SQL
A lot of people speak a lot of time about no sql databases.
The common sense seems to be, that no sql let's us work with out planning, thinking, it just works.
If your main problem is, that you don't want to plan your columns, consider reading this article http://www.igvita.com/2010/03/01/schema-free-mysql-vs-nosql/