Archive for the ‘Ruby’ Category
Posted by stephan on 28. July 2009
While working on some tree structure a couple of unit tests failed, when creating some form of summary of said tree structure. First of all here’s a condensed form of the code:
require 'sequel'
DB = Sequel.sqlite
DB.create_table :items do
primary_key :id
String :name
String :foo, :default => 'NOT SET'
Integer :item_id
end
class Item < Sequel::Model
one_to_many :items
def summary
if items.empty?
return [ { self.name => self.foo } ]
else
items.inject( [] ){ | r, sub_res | r << sub_res.summary }
end
end
end
r1 = Item.create :name => 'R1'
r2 = Item.create :name => 'R2'
r1.add_item r2
r2.foo = 'Ding'
#r2.save
[ r1, r2 ].each{ |i|
puts "Item : #{ i.id }"
puts "Direct Foo: #{ i.foo.inspect }"
puts "Summary : #{ i.summary.inspect }"
puts
}
Notice, that I’ve commented out saving r2. The output is:
Item : 1
Direct Foo: "NOT SET"
Summary : [[{"R2"=>"NOT SET"}]]
Item : 2
Direct Foo: "Ding"
Summary : [{"R2"=>"Ding"}]
What I didn’t expect – and why the unit tests failed – is the ‘NOT SET’ in the r1 summary.
One way to end up with what I originally expected is to save r2. Another way is to set r2.foo before adding r1 to r1:
r2.foo = 'Ding'
r1.add_item r2
How ever I’m still not sure whether this is intended behaviour and why it should behave like this. (If it is, I’d like to know why.)
What do you think?
Posted in Ruby, testing | Tagged: Ruby, Sequel, tree | Leave a Comment »
Posted by stephan on 25. May 2009
Since its 0.9.2 release on 18th of May 2009, Sinatra doesn’t automatically reload files anymore – not even in development mode.
To achieve this use ’shotgun’
sudo gem install shotgun
and then start the server using:
shotgun <your_applicationname>.rb
The effect is essentially the same (apart from avoiding the issues the ‘traditional’ way of reloading apparently had – which is why it was removed).
Thanks for pointing this out in this thread @ rubyforen.de.
Posted in Programming, Ruby | 1 Comment »
Posted by stephan on 18. May 2009
Posted in Ruby | Tagged: readline, Ruby, Windows | Leave a Comment »
Posted by stephan on 12. May 2009
These two days with Ruby enthusiasts form all over the world not just Europe was great. Nicely located at citilab, with very good public transportation to the city centre of Barcelona, there was enough space inside as well as out side the building to talk to the other attendees, just relax in the sun or work with the notebook. Two wi-fi networks inside and outside the building could deal well with all the notebooks and mobile phones connected to it. This worked very good indeed.
The presentations I liked most where the ones introducing really exciting and new stuff. First and foremost there’s Rhodes, which enables the creation of native mobile applications with Ruby and HTML. And of course Matz’ keynote was very entertaining as well. More really new stuff was about Adhearsion a way to build voice enabled application with Ruby (and Rails). Then some of the presentations were a really good show. Most notably Javier’s talk about gosu, a framework for games and Pablo’s presentation about Archaeopteryx which was probably the loudest presentation I’ve ever heard.
The only thing that was a tad bit disturbing for me was that I didn’t have one of the mobile microphones available and was kind of stuck behind the table as well as the phones themselves, as they seemed to go silent now and then. Aslak dealt with this best I think, repeatedly saying “Hello?” directly into the microphone whenever it went silent.
I think this year was the first time Twitter was heavily used during Euruko, reusing a bot made for Scotland on Rails. and this helped enhancing the communication and connecting people even more than in previous years. A special “Thank you” to all for the other attendees who gave me direct feedback about the presentation as well as the corresponding discussion about it, including but not limited to: Andrew Miller, Tim Becker, Mike Just, Dave Frey. Thanks a lot, indeed.
More summaries are available from Javier and Tomasz.
Next year Euruko will take place in Krakow, Poland and I’m already looking forward to going there.
Posted in EURUKO, Programming, Ruby | Tagged: Adhearsion, Barcelona, citilab, EURUKO, gosu, Ruby | Leave a Comment »
Posted by stephan on 9. March 2009
Over at euruko.org the registration is now open. The conference is on the 9. & 10. of May 2009 in Barcelona, Spain. It seems they collected quite a few exciting talks – and mine.
Really looking forward to going there.
Posted in EURUKO, Ruby | Tagged: Barcelona, Euruko 2009, Ruby, Spain | Leave a Comment »
Posted by stephan on 31. January 2009
Posted in Programming, Ruby | 1 Comment »
Posted by stephan on 12. November 2008
Posted in Ruby, Ruby on Rails | Tagged: München, Munich, Rails, Ruby | Leave a Comment »
Posted by stephan on 21. September 2008
I regularly fire up the same applications: TextMate, a browser or two, mail programs, iTunes, a shell, irb and others. Now, while Quicksilver is excellent for firing up applications (and a lot of other things), I’d still be busy typing and/or mouse-pointing and clicking. And doing that is boring, cumbersome and not what I like to do anyway. I shouldn’t (have to) do it. And, in fact, I don’t. A little bit of Ruby code will do it:
#!/usr/bin/ruby
%w( <full_application_paths_go_here> ).each{ | app | system "open #{app} &" }
Replace <full_application_paths_go_here> with a list of space-delimited full application paths, save it into a file (in ~/bin presumably), make it executable and there you go. Actually, the language doesn’t matter at all here. The only thing that does matter is to fire up the applications.
Starting all most used applications is now just a few key strokes away. There’s certainly a very similar way to do this on other *nix OSes and Windows.
Posted in Mac, Programming, Ruby, Work Environment | Tagged: Efficiency, Productivity | Leave a Comment »
Posted by stephan on 28. August 2008
A year has passed and it’s Rails time again: I’ll be at RailsConf Europe in Berlin next week. Actually I’ll be in Berlin on Sunday already. So if any of you Rails and Ruby folks likes to have a beer or something, just drop me an e-mail.
Posted in Ruby | Tagged: 2008, Berlin, RailsConf Europe, RailsConfEurope2008, RailsEurope2008 | Leave a Comment »
Posted by stephan on 6. April 2008
It’s time for a new Ruby (and Rails) meeting in Munich. We’ll meet on Wednesday 9th of April starting at 19:00 (CEST) in the Pizzeria Michelangelo.
If youre’ coming, please answer via e-mail or comment by Tuesday (08.04.2008) 12:00 CEST (in order to make a reservation for enough tables).
Possible topics are: A short report from Euruko2008 which happened in Prague in late March, actually any other Ruby related topics.
Posted in Ruby | Tagged: Meeting, Munich, Ruby | 2 Comments »
Posted by stephan on 8. March 2008
Euruko 2008 is in Prague this year. Here’s the Euruko 2008 website where you can register, submit a proposal for a talk etc. Matz will be there. And of course a few other guys. Including me
Posted in EURUKO, Ruby | 1 Comment »
Posted by stephan on 1. November 2007
The (at the time of this writing) new Mac OS X 10.5 Leopard is now installed on my MacBook for a week. Time enough to find the way through a few of the new features. Time Machine is of course an easy way for backing up the system.
Anyway, to me Spaces (virtual desktops) are a lot more important, since I missed this feature before. Of course there was VirtueDesktops (which even featured desktop switching via the motion sensors). However with Spaces you can assign an application to a certain Space.
Terminal now comes with tabs instead of many windows, which also helps keeping the desktops clean. And last but not least Mac OS X now also includes Subversion, Ruby and of course Ruby on Rails, including – but not limited to – gems and Rake.
Only issue: The background image of the login screen needs to be replaced. In case you also like another picture, LoginWindow Manager might be useful for you.
Posted in Ruby | Tagged: Leopard, Mac OS X, Ruby | Leave a Comment »
Posted by stephan on 15. October 2007
Wow, there are already 46 registrations for the European Ruby Conference, and 9 people who “might come”. That’s great, as we were already at the capacity for the room with that number last year. Obviously Ruby gained quite a bit of interest within the last year. Apparently it was a Good Thing to have a larger room this year: The room can take 100 people “easily” and 170 “squeezed in” (hope I got the translation right).
Currently there are already 19 people willing to give at least one talk, some even offered giving two. So there’s no problem filing to full days with interesting stuff about what’s going on in the Ruby world. I really looking forward to this, especially the Koichi’s talk about YARV and Ruby 1.9.1. How exciting is that? And then there’s something about Ragel, a state machine compiler. And, doing test automation myself, of course I’m interested in the talks about automation. These are going to be exciting days.
All that for a conference fee of just about 20 Euro.
Posted in EURUKO, Ruby | Leave a Comment »
Posted by stephan on 11. September 2007
After a few weeks of struggling to find a location we finally found a place. In fact we also found a new date:
Euruko 2007 will be located in Vienna, Austria on Saturday & Sunday 10th and 11th November 2007.
This was also announced on ruby-talk as well as the Euruko wiki … and a few other places.
If you’re planning to attend or to give a presentation, please use the wiki to register.
Posted in EURUKO, Ruby | 4 Comments »
Posted by stephan on 2. July 2007
We’ve now set up a Basecamp. Contact me with any requests for a login, if you’re interested to help getting the conference organised.
And if you couldn’t remember a single additional login, why not letting us know by commenting here or sending me an e-mail? May be you have an idea about a talk you’d like to hear or, dare I mention it, a presentation you’d like to give.
The EURUKO is not a commercial conference, it’s meant to follow the Open Source spirit: If you like to contribute – well – do it.
Posted in EURUKO, Ruby | 5 Comments »
Posted by stephan on 25. June 2007
Summary form the EURUKO 2007 planning meeting:
- Location: Very very likely to be Munich, Germany
- Date: Very likely to be the 10./11. or 17./18. November 2007
- Improved organisation compared to last year.
- Ideas for keynotes, precise location and more.
Stay tuned for more later.
Posted in EURUKO, Ruby | Leave a Comment »