Euruko 2008 - Day one
the conference started smoothly, despite not enough power cords (lucky me with my iPod touch) and the Prague marathon right outside the university. The keynote was hold by Matz and reeally grew in the second half where it was about m17n and issues with that. Koichi showed some benchmarks and details from his YARV.
Charles and Thomas from the JRuby announced the brandnew version 1.1 and outlined it's new features and optimisations. They'll second part was writing GUI apps, a five-liner for a swing-frame including a button and an event many LOC less than pure Java. The Rail part was kept short and featured a few references of production sites running JRuby. After a short break to their mac's problems and questions from the audience about testing the ruby-specs, the finished with demoing ruby-processing (this great graphics library) samples running them on JRuby.
Euruko 2008
It's only a day and I'll be sitting in the trains (seven hours) to Prague for the "Euruko 2008":http://www.euruko2008.org/ where Matz will hold the keynote and the continent's ruby hackers will gather for two days.
Things I'm really looking forward for:
* living without my Macbook for a whole weekend
* David A. Black on „Per-Object Behavior in Ruby“
* Nic Williams — „Meta-Meta-Programming with Ruby“
* Tim Becker — „Lessons Learned Writing Native Extensions“
* all those lightning talks
* and of course the parties on Friday and Saturday
Google chart
I stumbled accross (well, let's say it was on delicious popular) about "gchartrb":http://code.google.com/p/gchartrb/ (why didn't he leaf out the "a"?) which is a Ruby API for Google Charts and the only place to work it into was my good old "ananasblau.de":http://ananasblau.de/
The examples from the API are quite simple and when I tried to do a chart for the last twenty days I was in big trouble. Here's my source which uses some rarely used Date methods and by far to many
collects. Basically I get my models data, create a hash with date-keys, fill it up, sort it (afterwards it's an array for some reason) and for the two axis I collect and max on the array.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
stats = MyModel.find(:all, :group => 'date', :order => 'created_at ASC', :select => ['count(id) as count, DATE_FORMAT(created_at, "%Y-%m-%d") as date'], :conditions => ' created_at > from_unixtime(unix_timestamp() - 3600*24*21)') unless stats.empty? @dates = {} Date.parse(stats[0].date).upto(Date.today()){|d| @dates[d.strftime('%Y-%m-%d')] = 0 } stats.collect { |c| @dates[c.date.to_s] = c.count.to_i } @dates = @dates.sort{|a,b| a[0] <=> b[0]} # note, it's an array from here on # d[0][8,2] for day only. d[0][5,5] for month and day @chart = GoogleChart::BarChart.new('700x100', "", :vertical, true) @chart.axis :x, :labels => @dates.collect{|d| d[0][8,2] }, :alignment => :left @chart.axis :y, :range => [0, @dates.max{|a,b| a[1] <=> b[1]}[1]] @chart.grid @chart.data "", @dates.collect{|d| d[1]}, '55CC88' end |
Deutschsprachige Monate in Ruby
Nicht gerade neu der Tipp, aber ich brauchte einfach nur die deutschen (bzw. österreichischen) Monatsnamen und schneller als so kann’s nicht gehen:
1 2 |
Date::MONTHNAMES = [nil] + %w(Jänner Feber März April Mai Juni Juli \ August September Oktober November Dezember) |
Das ist doch immer wieder das schöne an Ruby, nur weil’s ne Klasse oder eine Konstante ist heißt das nicht dass man nicht hinterher nochmal was dran ändern könnte. Einfach herrlich bequem.