xvfb backround info

Angelegt von suung Mon, 28 Nov 2011 14:26:00 GMT

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

Angelegt von suung Tue, 15 Nov 2011 21:30:00 GMT

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

Angelegt von suung Mon, 31 Oct 2011 16:24:00 GMT

just stumpled upon this in the redmine gemfile

https://github.com/jberkel/interactive_editor

Extracting the filename of a url, that can have additional params

Angelegt von suung Wed, 26 Oct 2011 17:26:00 GMT

/\/((?:[\w\-\_]+\.\w{3,4}))(?:\?.+)?$/

The future of education lies in technology

Angelegt von antje Sun, 23 Oct 2011 08:50:00 GMT

or vs ||

Angelegt von suung Wed, 19 Oct 2011 13:24:00 GMT

i never use 'or' so i found this interesting.

Beginner Error in Rails: confusing an attribute of ActiveRecord instanze with an instance variable

Angelegt von suung Wed, 19 Oct 2011 11:56:00 GMT

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
and
 
@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

Angelegt von suung Tue, 11 Oct 2011 10:29:00 GMT

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)

Angelegt von suung Mon, 10 Oct 2011 19:22:00 GMT

 

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

Angelegt von suung Sat, 08 Oct 2011 20:49:00 GMT

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/