Rails reporting: dead simple reports now supports excel directly
April 12, 2008 on 9:44 pm | von Alexander Lang | keine Kommentaredead simple reports is a Ruby on Rails plugin that allows you to create reports from your application data within minutes. As of now it can not only generate HTML tables and CSV files but also M$ Excel spreadsheets. This is possible through the use of the spreadsheet-excel gem. You can grab a copy from the git repository or just download it from there.
Monitoring the internals of your Rails application with Nagios
April 10, 2008 on 10:03 am | von Alexander Lang | 2 Kommentare
autoki has recently grown into a more and more complex application. Besides two clusters of mongrels and the mysql database we have a memcached server, ferret and starling plus clients for asynchronous processing. WIth so many services running (and sometimes not running) the need to monitor all these grew. We decided to set up nagios on one of the servers - it’s ugly but it lets you monitor all sorts of stuff pretty easily via remote agents that run on each monitored server.
With nagios we have access to quite a number of monitoring plugins, e.g. for monitoring TCP ports (e.g. for checking memcached is still alive), HTTP, server load, free disk space etc. Yesterday I came to a point where I wanted to monitor something nagios couldn’t: When a user uploads a bunch of photos, the task of creating copies of the photos in different sizes is put in a starling queue for asycnhronous processing. If something with that processing goes wrong and the queue gets too big I want nagios to pick this up and notify me. Time for my own nagios plugin.
Nagios plugins are actually very simple. All you have to provide is something that can be executed in a shell and that returns either 0, 1 or 2 for an OK, Warning or Critical state of the monitored service. So here’s the source code for monitoring the number of photo uploads in the queue (RAILS_ROOT/lib/check_photo_uploads.rb):
At autoki the server that runs the asynchronous processes is called jobs1 and this is also where the queue should be checked, so I added this to the /etc/nagios/nrpe.cfg file (the config file for the remote nagios agent):
Then I had to add the service to the nagios configuration on the monitoring server:
Well, that was it, and this is how it looks - ugly but it works

(I recently signup with scout - looks much prettier and the setup is much easier than nagios, plugins are written as ruby classes and it comes as a ruby gem - sweet concept so far, could have been my idea, more on that later)
upstream goes open source: dead simple reports
March 3, 2008 on 4:48 pm | von Alexander Lang | keine KommentareNa endlich. Nach all den Jahren des nur-Geldverdienens und Open Source-Ausnutzens haben wir es geschafft, ein paar erste Zeilen Code in die Freiheit zu entlassen: dead simple reports, ein Rails-Plugin, das Reports generieren kann. Mehr dazu im neuen Bereich Open Source
TextMate Snippet Power für gettext
February 17, 2008 on 2:58 pm | von thilo | 2 KommentareEs ist super wenn die Werkzeuge, die man verwendet mit einem wachsen. Deshalb bin ich von Ruby und TextMate begeistert.
Für die, die TextMate nicht kennen: TextMate ist ein TextEditor für OS X, der sich in meinen Augen durch zwei Besonderheiten als Entwicklungswerkzeug hervortut. Erstens die leistungsfähige Live-Suche, die alle Mausklicks zum Navigieren im Projekt überflüssig macht. Zweitens die wirklich mächtigen Skriptingmöglichkeiten, die ich wohl noch lange nicht erfasst habe.
Jedenfalls musste ich Rahmen der Internationalisierung eines Projekts alle Strings in eine Übersetzungsmethode von gettext wrappen. Also ggf. Texte in den Views in Inline tags und in doppelte Anführungszeichen zu packen. Das gewünschte Ergebnis sieht etwa so aus: <%= _("Zu übersetzender Text") %>. Die ganze Arbeit ist ziemlich stupide, ließ sich aber mit TextMate auf simples Markieren des entsprechenden Textes und das Drücken des Tastenkürzels ctrl+alt+t reduzieren.
weiterlesen…
EURUKO 2008
February 13, 2008 on 7:53 pm | von Alexander Lang | keine KommentareDie Konferenzsaison fängt an. Kurz vor der re-publica geht’s am 28./29.3. nach Prag zur European Ruby Conference. Letztes Jahr in Wien war ziemlich lustig. Damals hatten wir in der Nacht zwischen den zwei Konferenztagen ein Twitter-basiertes Rätselspiel (twizzer) geschrieben.
Falls jemand auch da hinwill, wir hätten evtl. noch Plätze im Auto frei.
RSpec 1.1 with StoryRunner coming?
December 12, 2007 on 1:12 pm | von Alexander Lang | 1 KommentarThe latest update from the rspec trunk changed the version.rb file indicating a 1.1 Release Candidate 1 version. Will there finally be a stable RSpec version that has StoryRunner? That’d be a great present for christmas.
Random links: smalltalky ruby & quietbacktrace
December 4, 2007 on 9:54 am | von Alexander Lang | keine KommentarePatt Maddoxx recently blogged about a ruby hack to avoid the dreaded nil-if, e.g. if user.comments.first; user.comments.first.title;. instead you can now do: user.comments.first.if_not_nil?{|c| c.title}.
http://evang.eli.st/blog/2007/11/22/smalltalky
dan croak has written a precious little ruby gem that filters the noise from you exception backtraces:
http://giantrobots.thoughtbot.com/2007/12/3/shhh-your-test-unit-backtraces-are-too-noisy
Euruko 2007 Review
December 3, 2007 on 10:45 pm | von thilo | 1 KommentarLast weekend (10. to 11. November) we were at the Euruko, the European Ruby Conference in Vienna. The conference wasn’t nearly as big as the Railsconf Europe, but the ad hoc character adapted very well to demands of the attendees and the topics were more academic. Here is a round up of the presentations I attended.
The Keynote was about the future of ruby with a look back to its beginnings by Hal Fulton. About the upcoming ruby 1.9 he said, that it wouldn’t change that much, but will gain performance by having its own virtual machine. Another aspect of his talk was the shift to enterprise use.
The following talk was about the Database Library Dbrb, it is basically a wrapper for ruby dbi to make it easier to work with it. Interesting if you have to do data crunching closer to the relational domain.
David Anderson shows a structured wiki, where you can build simple Applications with forms and so on.
Ramine Darabiha, Sven C. Köhler show their Javascript based content distribution/mashup system MySit.es which is still under heavy development.
After the lunch break Christian Neukirchen showed Rack, a simple and modular web server interface specification. It basically wraps the status, headers, and body in a array. Following the rack specification you can add middleware between your server and the web framework, e.g. log file generation or URL rewriting.
An alternative to watir, a in browser testing framework, was shown by Kingsley Hendrickse, the Ruby IE Scripting System (RIESS) and AutoGUI.
The powerfull, but hard to learn, web site scraping framework scRUBYt was introduced by Peter Szinek.
The last talk of that day was about the use of Domain Specific Languages and how easy it is to build one, held by Martin Grund.
In the evening we had an excellent dinner in the ‘Universitätsbräu’. My personal dish recommendation ‘Schöpfsteak’.
We took the opportunity and input from the conference to try out some new stuff in a late night coding session, although I had had just 4 hours of sleep the night before. But alex will write some more about our twitter mashup twizzer.
On Sunday we missed the first talks. So i can’t tell you anything about it
The first I joined again was from Tim Becker, who showed DTrace. DTrace is an integrated tracing framework for debugging applications or the OS itself. It is integrated into Solaris and the latest Mac OS 10.5 ‘Leopard’.
What Trees are good for, was explained by Paul Battley. For example they are good for faster best match search using the Levenshtein distance. But I have to admit, I didn’t followed that talk very well.
Then Stephan Kämper talked on Quality in code, and shows some exaple of good and bad code.
Hal Fulton filled the little gap before the lunch break with his proposal for an in operator in Ruby.
After the lunch it got even more academic with Ragel, a state machine compiler, presented by Ry Dahl
Then we showed our results from the coding session.
The last presentation of the Euruko was held by Sasch Schlegel about the ebXML Messaging System called Hefeweizen. I liked the MAMAs and PAPAs analogy
Before we caught our flight home, we had another dinner at the ‘Universitätsbräu’.
I enjoyed the Euruko very much, I will try to attend next year again. Maybe in Prague then.
Implementation Patterns emerging
December 3, 2007 on 10:33 pm | von Alexander Lang | 4 KommentareI recently read Kent Beck’s new book Implementation Patterns - it was a nice read and I guess it somehow strengthened my senses towards patterns a bit. Unfortunately it is written with Java in mind, and as we all know Patterns are language specific. The following can’t really be applied to Java as far as i know (having stopped writing in Java with 1.5).
So I discovered a kind of implementation pattern I had used a few times in the last weeks. Maybe everyone has already written about it but I want to stress that I discovered it myself
Here it is:
The Selector Pattern
When to use it: When you have a complicated if-elseif-elsif-else or switch clause and want to replace it with something more elegant.
When not to use it: It works well for limited complexity. I things get more complex you may want to use class inheritance instead.
What it does: Put the each condition and the according logic into a hash. Then iterate through the conditions to find a match and execute its logic.
Example
Suppose you have a class Video that represents a video on youtube or some other hosting provider. Its purpose is to render the neccessary HTML tags to embed it into a document. The generated HTML differs depending on the hosting provider, e.g. youtube.com or vimeo.com. The code could be expressed like this:
Using the selector pattern it might look like this:
With only 2 providers this doesn’t make too much sense but with something like 5 your elsifs start to get really ugly and the selector pattern offers a more ligtweight way to replace these than creating an entire hierarchy of subclasses for every case.
Using and Testing ActiveRecord/Rails Observers
October 27, 2007 on 2:31 pm | von Alexander Lang | 2 Kommentare
We recently introduced a new feature in autoki called the social feed. It’s basically a yellow box displaying any events on the platform relevant to the current user, like a friend has posted a new photo, or a new interesting car was uploaded. The data model behind this is pretty straightforward, we have a FeedEvent class and all kinds of subclasses, e.g. a MessageReceivedEvent. Each event belongs to a user and an event source, in this example the user would be the user who received the message and the event source would be the message itself. For each user, we simply display all the events that belong to him or her.
Now the question was this: How do we create these events? The most straightforward way would probably have been to create them in the models, so the Message model would have an after_create callback that created the event. What we didn’t like about this solution was that we would put a whole bunch of logic into the models that didn’t really belong there. Why would a Message care if there was some kind of event feed? Plus these events would be all around in our unit tests and make the bloated and probably sloooow (again). So we wanted to use the observer pattern to remove the creation of the event from the models.
Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^
post to del.icio.us



