<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Aenima blog - Home</title>
  <id>tag:blog.aenima.pl,2010:mephisto/</id>
  <generator uri="http://mephistoblog.com" version="0.8.0">Mephisto Drax</generator>
  <link href="http://blog.aenima.pl/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://blog.aenima.pl/" rel="alternate" type="text/html"/>
  <updated>2008-12-08T13:52:18Z</updated>
  <entry xml:base="http://blog.aenima.pl/">
    <author>
      <name>tomash</name>
    </author>
    <id>tag:blog.aenima.pl,2008-12-08:17</id>
    <published>2008-12-08T12:00:00Z</published>
    <updated>2008-12-08T13:52:18Z</updated>
    <category term="ruby"/>
    <category term="authorization"/>
    <category term="base_auth"/>
    <category term="plugin"/>
    <category term="rails"/>
    <category term="ruby"/>
    <link href="http://blog.aenima.pl/2008/12/8/base-auth-a-complete-tutorial-to-securing-your-rails-application" rel="alternate" type="text/html"/>
    <title>Base Auth - a complete tutorial to securing your Rails application</title>
<summary type="html">&lt;p&gt;This one's going to be a big one, be prepared for reading it in parts.&lt;/p&gt;

&lt;p&gt;Base Auth's readme is of course available on its &lt;a href=&quot;&quot;&gt;GitHub page&lt;/a&gt;, so make sure you have it open for reference.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;This one's going to be a big one, be prepared for reading it in parts.&lt;/p&gt;

&lt;p&gt;Base Auth's readme is of course available on its &lt;a href=&quot;&quot;&gt;GitHub page&lt;/a&gt;, so make sure you have it open for reference.&lt;/p&gt;
&lt;h1&gt;Authorization By Controller&lt;/h1&gt;

&lt;h2&gt;Guest User&lt;/h2&gt;
&lt;p&gt;First things first: make sure you have current_user method available in your controllers. If you're using &lt;a href=&quot;http://github.com/technoweenie/restful-authentication/tree/master&quot;&gt;Restful Authentication&lt;/a&gt; or &lt;a href=&quot;http://github.com/binarylogic/authlogic/tree/master&quot;&gt;Binarylogic's Authlogic&lt;/a&gt; for authentication - and you definitely should - you already have it and we can move to the next point.&lt;/p&gt;

&lt;p&gt;Now, Base Auth generally uses instance methods of current_user, even for checking for guest user, and since implementing a &quot;guest user&quot; model is generally a good idea (default name like &quot;Anonymous Coward&quot; etc.), let's make it work:&lt;/p&gt;

&lt;p&gt;app/models/user/guest.rb (yes, it's in user subdirectory - we're namespacing after all):&lt;/p&gt;

&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;class User::Guest &amp;lt; User
  def validate
    errors.add(nil, 'Guest user cannot be saved.')
  end
end&lt;/pre&gt;

&lt;p&gt;app/models/user.rb:&lt;/p&gt;

&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;class User &amp;lt; ActiveRecord::Base
  def is_guest?
    self.class == User::Guest
  end
end&lt;/pre&gt;

&lt;p&gt;Now, because we need to have a current_user always available, even if not logged in, let's add one more possibility of getting current_user. Here's the version for restful_authentication users - you can put it in ApplicationController class or AuthenticatedSystem module:&lt;/p&gt;

&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;@current_user ||= (login_from_session || login_from_basic_auth || login_from_cookie || User::Guest.new) unless @current_user == false&lt;/pre&gt;

&lt;p&gt;Now we can begin our adventure with Base Auth by protecting one of our controllers from guest users:&lt;/p&gt;

&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;class NotForGuestsController &amp;lt; ApplicationController
  deny :user =&amp;gt; :is_guest?
end&lt;/pre&gt;

&lt;p&gt;Of course it's theoretically equal to before_filter :login_required, but instead of redirecting to login form, it throws an Authorization::PermissionDenied exception, with which you can do whatever you like. For example:&lt;/p&gt;

&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;class ApplicationController &amp;lt; ActionController::Base
 
  rescue_from ActiveResource::ResourceNotFound, :with =&amp;gt; :resource_not_found
  rescue_from ActiveRecord::RecordNotFound, :with =&amp;gt; :resource_not_found
  rescue_from Authorization::PermissionDenied, :with =&amp;gt; :permission_denied
  
  def permission_denied
    render :text =&amp;gt; &amp;quot;You don't have permissions to access this page.&amp;quot;, :status =&amp;gt; 403, :layout =&amp;gt; true
  end
  
  def resource_not_found
    render :text =&amp;gt; &amp;quot;This page doesn't exist&amp;quot;, :status =&amp;gt; 404, :layout =&amp;gt; true
  end
end&lt;/pre&gt;

&lt;p&gt;I must admit, guest user handling is not where Base Auth shines. It does when it comes to securing user-owned content though.&lt;/p&gt;

&lt;h2&gt;User-owned content&lt;/h2&gt;
&lt;p&gt;This can be accomplished in two ways. One of them is to explicitly call allow! (or deny! if our app has a twisted and negative verification) in given action for a given resource:&lt;/p&gt;
&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;class TasksController &amp;lt; ApplicationController
  deny :user =&amp;gt; :is_guest?
  def edit
    @task = Task.find(params[:id])
    allow! :user =&amp;gt; :owns?
  end
end&lt;/pre&gt;
&lt;p&gt;We're RESTful, right? Our app's too, so it means our controllers are a very thin layer between client and our models, so we usually name our controllers after the models they expose.&lt;/p&gt;
&lt;p&gt;Base Auth is going to automagically guess the name of instance variable to check against current user, by singularizing controller's name and prepending it with &quot;@&quot;. This way in TasksController it's going to look for @task variable, but we can of course tell base_auth to authorize using different variable:&lt;/p&gt;
&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;class TasksController &amp;lt; ApplicationController
  def edit
    @something = Task.find(params[:id])
    allow! :user =&amp;gt; :owns?, :object =&amp;gt; @something
  end
end&lt;/pre&gt;
&lt;p&gt;This one takes a lot of coding and we'll usually have to repeat it through (almost) all the actions, so it's better to use base_auth as before_filter and grab the resource in another before_filter. You probably did it already (DRY!), and base_auth can make good use of it:&lt;/p&gt;
&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;class AccountsController &amp;lt; ApplicationController
  before_filter :get_resource
  allow :show, :edit, :update, :destroy, :user =&amp;gt; :owns?
  deny :user =&amp;gt; :is_guest?
  
  protected
  
  def get_resource
    @account = Account.find(params[:id]) if params[:id]
  end
end&lt;/pre&gt;

&lt;p&gt;There's still one thing to implement: User#owns?(object) method:&lt;/p&gt;
&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;class User &amp;lt; ActiveRecord::Base
  def owns?(target)
    #return true if self.is_admin?
  
    if target.respond_to?( :owned_by? )
      target.owned_by?( self )
    elsif target.respond_to?( :owner_id )
      self.id == target.owner_id
    else
      false
    end
  end
  
  def owner_id
    self.id
  end
end&lt;/pre&gt;
&lt;p&gt;Of course you can implement it differently, or make use of user_id field instead owner_id. Or make owner_id an alias to user_id in owned resource... or do anything you like. User#owns?(target) has to work and that's the only constraint.&lt;/p&gt;

&lt;p&gt;Not even that - you can use different method name passed to base auth's allow (like :user =&gt; :can_edit? and implement User#can_edit?(target)) to implement some more complex authorization logic.&lt;/p&gt;

&lt;h1&gt;Authorization By Model&lt;/h1&gt;
&lt;p&gt;This one has a pretty humble implementation at the moment, but lets you authorize by model and keep amounts of authorization code in your controllers as small as possible. That's basically the way it works:&lt;/p&gt;
&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;class TasksController &amp;lt; ApplicationController
  deny :user =&amp;gt; :is_guest?
  def edit
    @task = Task.find(params[:id]).authorize!(current_user)
  end
end&lt;/pre&gt;

&lt;p&gt;All you have to implement is Model#authorize(user) method in given model's class. For instance:&lt;/p&gt;

&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;class Task &amp;lt; ActiveRecord::Base
  def authorize(user)
    user.user_id == self.owner_id
  end
end&lt;/pre&gt;

&lt;p&gt;And even that only if your Model#authorize method is going to differ from base_auth's default implementation:&lt;/p&gt;

&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;module ModelAuthorization
  module InstanceMethods
    #re-implement this in your model if you check authorization in a different way
    def authorize(user)
      user.id == self.user_id
    end
  end
end&lt;/pre&gt;

&lt;p&gt;More complex authorization logic in authorize-by-model, like authorize_for!(:edit, current_user) about to become implemented in base_auth after some testing.&lt;/p&gt;

&lt;h1&gt;Ending&lt;/h1&gt;

&lt;p&gt;Base Auth is not perfect as in &quot;drop in and use automagically without step 3 - perfect&quot;. We didn't want to overload it with convenience methods and defaults, as authorization is a pretty serious topic and working differently across different applications. That's why there has to be some code in the application, because everything that was common to our applications is already in base_auth. The rest has to be decided by application developer. We just wanted authorization to follow the KISS principle.&lt;/p&gt;

&lt;p&gt;We're open to suggestions though, so feel free to comment and contact us with questions and ideas.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.aenima.pl/">
    <author>
      <name>tomash</name>
    </author>
    <id>tag:blog.aenima.pl,2008-12-05:14</id>
    <published>2008-12-05T10:10:00Z</published>
    <updated>2008-12-05T12:10:27Z</updated>
    <category term="ruby"/>
    <category term="authorization"/>
    <category term="base_auth"/>
    <category term="plugin"/>
    <category term="rails"/>
    <link href="http://blog.aenima.pl/2008/12/5/base-auth-grown-up-to-0-2" rel="alternate" type="text/html"/>
    <title>Base Auth grown up to 0.2</title>
<content type="html">
            &lt;p&gt;A long, long time ago (a year in Rails world is almost a geological period)  &lt;a href=&quot;http://robzon.aenima.pl/&quot;&gt;Robzon&lt;/a&gt; has published and announced &lt;a href=&quot;http://robzon.aenima.pl/2007/12/base-auth-is-out.html&quot;&gt;Base Auth&lt;/a&gt;, his first serious Rails plugin. &quot;Base&quot; actually stands for &quot;Best Authorization System Ever&quot; and while it's of course tongue-in-cheek, simplicity and power of this plugin are sometimes simply stunning. We've been using it in most of our projects here and not only because Robzon is one of the founders and bosses ;) &lt;/p&gt;

&lt;p&gt;I didn't like some of the approach that Base Auth forced on programmer, namely putting everything in filter and throwing the whole burden of authorization on controller's back. I want to keep my controllers thin and put as much as possible into the model, goddamit! For a few weeks now I've been trying to convince Robzon to add model-based authorization to Base Auth, preferably using as much common code with already implemented controller-based authorization as possible. After some perseverance I finally heard &quot;YOU can implement it, especially since we moved base_auth to Github&quot; and after getting such green light there wasn't much more to do than just sit and implement what I wanted to see there.&lt;/p&gt;

&lt;p&gt;So there it is: &lt;a href=&quot;http://github.com/aenima/base-auth/tree/master&quot;&gt;Base Auth 0.2&lt;/a&gt;, available on GitHub, has now a pretty simple yet powerful and extensible support for model-based authorization. Just install, check and define Model#authorize (if default implementation doesn't suit you) and use model-based authorization this way:&lt;/p&gt;

&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;Class ItemsController &amp;lt; ApplicationController
  def edit
    @item = Item.find(params[:id]).authorize!(current_user)
  end
end&lt;/pre&gt;

&lt;p&gt;Of course it's just the tip of an iceberg, as there's the whole world of controller-based and views-usable authorization methods available in Base Auth, of course compatible and interchangeable with the model-based one. Read the README and wait for a full tutorial here.&lt;/p&gt;

&lt;p&gt;One last thing: you should gracefully rescue from exception thrown when authorization fails:&lt;/p&gt;

&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;Class ApplicationController
  rescue_from Authorization::PermissionDenied, :with =&amp;gt; :permission_denied
  
  def permission_denied
    render :text =&amp;gt; &amp;quot;You don't have the permissions for this&amp;quot;, :status =&amp;gt; 403, :layout =&amp;gt; true
  end
end&lt;/pre&gt;

&lt;p&gt;Same of course applies if you use allow! and deny! with controller-based authorization. Anyway, a bigger Base Auth tutorial is about to follow. Stay tuned!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.aenima.pl/">
    <author>
      <name>tomash</name>
    </author>
    <id>tag:blog.aenima.pl,2008-12-04:12</id>
    <published>2008-12-04T10:40:00Z</published>
    <updated>2008-12-04T10:40:31Z</updated>
    <category term="ruby"/>
    <category term="github"/>
    <category term="narn"/>
    <category term="newsletter"/>
    <category term="plugin"/>
    <category term="rails"/>
    <link href="http://blog.aenima.pl/2008/12/4/narn-a-rails-newsletter-that-doesn-t-suck" rel="alternate" type="text/html"/>
    <title>NARN - a Rails newsletter plugin that doesn't suck </title>
<content type="html">
            &lt;p&gt;Sticking up with the &lt;a href=&quot;http://rails-engines.org/&quot;&gt;Engines&lt;/a&gt; theme and &lt;a href=&quot;http://blog.aenima.pl/2008/12/4/aep-beast-a-modern-beast-forum-fork&quot;&gt;&quot;stuff that many of our clients want in their applications&quot;&lt;/a&gt;, there's one small plugin we did some time ago in cooperation with developers from outside the company. We all needed a pluggable newsletter engine that would be easy to install, maintain and upgrade.&lt;/p&gt;

&lt;p&gt;That's when &lt;a href=&quot;http://github.com/aenima/narn/tree/master&quot;&gt;NARN&lt;/a&gt; was created. It's a pretty small, but very useful Rails Engines plugin. It's on GitHub of course, so feel free to grab, test, modify and &lt;a href=&quot;mailto:tomasz.stachewicz@aenima.pl&quot;&gt;send suggestions and patches&lt;/a&gt;. You know you'll need a newsletter in some of your apps one day ;)&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.aenima.pl/">
    <author>
      <name>tomash</name>
    </author>
    <id>tag:blog.aenima.pl,2008-12-04:11</id>
    <published>2008-12-04T09:09:00Z</published>
    <updated>2008-12-04T09:10:08Z</updated>
    <category term="ruby"/>
    <category term="forum"/>
    <category term="github"/>
    <category term="plugin"/>
    <category term="rails"/>
    <link href="http://blog.aenima.pl/2008/12/4/aep-beast-a-modern-beast-forum-fork" rel="alternate" type="text/html"/>
    <title>Aep Beast - a modern Beast forum fork</title>
<content type="html">
            &lt;p&gt;There's been a lot of talk about Rails applications not being modular-able, forcing developers to copy-paste code instead of plugging it in in a true DRY spirit. Despite these claims, some developers believed they can make RoR apps modular and created &lt;a href=&quot;http://rails-engines.org/&quot;&gt;Engines&lt;/a&gt;, one of the best and most innovative Rails plugins ever.&lt;/p&gt;

&lt;p&gt;Most web applications come today with some ways to socially interact with other users. I believe they call it Web 2.0, although I saw this term used to label to many, many different things, including AJAX and standards compliant HTML and CSS. Anyway, there are a few means of such social interaction, including commenting (any or most of users' content), wikis and - my personal favourite - forums.&lt;/p&gt;

&lt;p&gt;To the point. First there was Beast, an attempt to do functional RoR forum in 500 lines of code. Then came Rails 2.0 and together with it William B. Harding wrote &lt;a href=&quot;http://www.williambharding.com/blog/rails/savage-beast-20/&quot;&gt;Savage Beast&lt;/a&gt;, a RoR 2.0 compliant Beast fork. It's great (thanks, William!), but the code wasn't perfect: it didn't work properly with Rails 2.1, used outdated will_paginate (everyone's using &lt;a href=&quot;http://github.com/mislav/will_paginate/tree/master&quot;&gt;Mislav Will_Paginate&lt;/a&gt; currently, right?). We needed a working Rails forum solution, preferably pluggable (so we could reuse the code given to our clients and let them upgrade forum engine painlessly), so we've forked Savage Beast, corrected a few imperfections, called it &lt;a href=&quot;http://github.com/aenima/aep_beast/tree/master&quot;&gt;Aep Beast and put it on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The best thing about GitHub in specific and Open Source in general is that anyone can grab the code, use it, fork it / modify it and make Aep Beast even better, cleaner, leaner and easier to use. So, everyone - feel free. GitHub awaits :) &lt;/p&gt;

&lt;p&gt;If you have any suggestions, put it in the comments. Or, especially if you have a patch, &lt;a href=&quot;mailto:tomasz.stachewicz@aenima.pl&quot;&gt;mail me&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;PS. What's the origin of &quot;Aep&quot; before the &quot;Beast&quot;? Well, it was supposed to be a part of &quot;Aenima Platform&quot;, sort of RoR application scaffold and set of plugins we were going to reuse in many of the applications. But this idea got scraped when awesome &lt;a href=&quot;http://www.rubyrailways.com/hot-in-edge-rails-generate-rails-apps-from-templates/&quot;&gt;Rails Generator&lt;/a&gt; came by. Now &quot;Aep&quot; means &quot;from, coming from, derived from&quot;, from the Elder Speech - a language created by &lt;a href=&quot;http://en.wikipedia.org/wiki/Andrzej_Sapkowski&quot;&gt;Andrzej Sapkowski&lt;/a&gt; in his books about the Witcher. We're (most of us) fantasy geeks anyway here. And if you haven't read his books about the &lt;a href=&quot;http://en.wikipedia.org/wiki/The_Witcher&quot;&gt;Witcher&lt;/a&gt;, it's right about time.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.aenima.pl/">
    <author>
      <name>tomash</name>
    </author>
    <id>tag:blog.aenima.pl,2008-06-07:9</id>
    <published>2008-06-07T08:50:00Z</published>
    <updated>2008-06-07T08:53:07Z</updated>
    <category term="ruby"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="snippets"/>
    <link href="http://blog.aenima.pl/2008/6/7/serving-html-erb-files-from-a-controller-the-easiest-method" rel="alternate" type="text/html"/>
    <title>Serving html(.erb) files from a controller - the easiest method.</title>
<content type="html">
            &lt;p&gt;Suppose you'd like to have some &quot;static&quot; (as in html.erb, without content in the DB) pages on your Rails site. And to have some nice path, like mydomain.com/articles/somearticle, pointing to a file somearticle.html.erb somewhere in your app directory.&lt;/p&gt;

&lt;p&gt;Well, this is the simplest and probably nicest of the options (and it's very &quot;Ruby Way&quot;). &lt;b&gt;But&lt;/b&gt; I have to test it a bit more to clear some security questions - use at your own risk.&lt;/p&gt;

&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;class ArticlesController &amp;lt; ApplicationController
  def method_missing(name)
    path = &amp;quot;#{RAILS_ROOT}/public/articles/#{name}.html.erb&amp;quot;
    render :file =&amp;gt; path, :layout =&amp;gt; true
  end
end&lt;/pre&gt;

&lt;p&gt;The best thing about it? 100% Globalize compatible, i.e. Globalize will automatically try to prepend extension with two-letter language code as usual with view files.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.aenima.pl/">
    <author>
      <name>tomash</name>
    </author>
    <id>tag:blog.aenima.pl,2008-06-07:8</id>
    <published>2008-06-07T08:42:00Z</published>
    <updated>2008-06-07T08:43:30Z</updated>
    <link href="http://blog.aenima.pl/2008/6/7/euruko-2008-day-two-sunday" rel="alternate" type="text/html"/>
    <title>EuRuKo 2008 - day two (sunday)</title>
<content type="html">
            &lt;p&gt;Sunday started pretty funny actually (wasn't so funny back then) - we forgot about daylight saving one-hour switch and after finally getting up we've realized that we don't have over 90 minutes until my talk, but only half an hour. We rushed into the Charles University with me leading, as getting late on one's first conference talk ever is definitely a bad idea. I managed to get on time, mostly thanks to my predecessor stretching his talk a bit and coffee break. After some fighting with xrandr (thanks Karel!) I was ready to go. Well, at least technically.&lt;/p&gt;

&lt;p&gt;11.30: Tomasz Stachewicz - &quot;Sharing the load&quot;. It's not a good idea to write about my own talk. Let's just say it went well I think, put some light onto OpenWFEru (which I wanted to do the most) and showed that BackgrounDrb isn't the only way to go.&lt;/p&gt;

&lt;p&gt;After doing some lunch break (and first beer that day) we were back at Euruko, to listen to some more talks.&lt;/p&gt;

&lt;p&gt;14.30: Tim Becker - &quot;Lessons Learned Writing Native Extensions&quot;. A good one. Not a lot of jokes, but very decent from technical standpoint and definitely worth the time. Could start from some higher level (as in &quot;higher than explaining C types&quot;), but for some this revision of basics was very refreshing and it's always better to start explaining from too low than from too high level. Tim Becker is on my Ruby radar - I think he's going to write some good stuff.&lt;/p&gt;

&lt;p&gt;15.00: Matt Ford -  &quot;Aspect Oriented Programming in Ruby&quot;. I always wanted to learn a bit about AOP in Ruby and this walk was just what I needed. Enough said :) &lt;/p&gt;

&lt;p&gt;After some more lightning talks we had to rush to train station. I've just managed to tell Karel and Peter that it was a perfect conference (exactly - perfect: I wouldn't like to improve anything) and we'd like to organize Euruko 2009 or 2010 in Poland, in Krakow to be precise.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.aenima.pl/">
    <author>
      <name>tomash</name>
    </author>
    <id>tag:blog.aenima.pl,2008-06-07:7</id>
    <published>2008-06-07T08:41:00Z</published>
    <updated>2008-06-08T17:00:31Z</updated>
    <link href="http://blog.aenima.pl/2008/6/7/euruko-2008-day-one-saturday" rel="alternate" type="text/html"/>
    <title>EuRuKo 2008 - day one (saturday)</title>
<content type="html">
            &lt;p&gt;First week of june seems like a perfect time to write about &lt;a href=&quot;http://www.euruko2008.org/&quot; title=&quot;Euruko site&quot;&gt;EuRuKo&lt;/a&gt;, a conference held at the end of march. Well, sarcasm aside &#8211; starting a company/group technical blog (and by starting I mean &#8220;populating with content&#8221;) isn&#8217;t the easiest thing we&#8217;ve been doing.&lt;/p&gt;


	&lt;p&gt;Disclaimer: this one is written by me (Tomash) and presents only my personal perspective. I&#8217;m trying to talk other guys into writing their own impressions.&lt;/p&gt;


	&lt;p&gt;Enough babbling, time to start with the report.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Saturday.&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;It was a good morning. Well, a decent at least, considering some partying after reaching Prague on friday. After breakfast, registration and letting our girlfriends visit Prague on their own we were ready for our first Ruby conference. As we all know from &lt;a href=&quot;http://www.euruko2008.org/pages/2-program&quot; title=&quot;program&quot;&gt;EuRuKo Program&lt;/a&gt;, it all started with Matz.&lt;/p&gt;


	&lt;p&gt;10.00: Yukihiro &#8220;Matz&#8221; Matsumoto &#8211; &#8220;Keynote&#8221;. This one was great, definitely one of the best talks during this Euruko. Not (only) because it was Matz who gave it, but mostly because it perfectly balanced some technical details and jokes. Matz turned out to be a pretty good English speaker (definitely better that what I&#8217;d expect from Japanese), at least comparing to Koichi that was about to follow&#8230;&lt;/p&gt;


	&lt;p&gt;11.00: Koichi Sasada &#8211; &#8220;Ruby meets VM&#8221;. Now, Koichi is a great man and he deserves a lot of respect for task as daunting as writing VM for Ruby. His talk was great from a technical point of view. At least from what I understood. And there we are, at the weakest point of his talk&#8212;some slides were in japanese and Koichi is simply&#8230; well, let&#8217;s say that he&#8217;s definitely better at Ruby than speaking english ;)&lt;/p&gt;


	&lt;p&gt;Because we actually knew JRuby, we&#8217;ve decided to have a walk through Prague Old City (it&#8217;s beautiful) and try some more of famous Czech beer. Being Polish we&#8217;re actually a bit picky about beer from other countries, but the beer we drank in Prague was &#8211; regardless of brand &#8211; just great and, I dare say that, even better than beer in Poland.&lt;/p&gt;


	&lt;p&gt;After getting back and having some great lunch at the conference we were prepared for next set of talks.&lt;/p&gt;


	&lt;p&gt;14.30: David A. Black &#8211; &#8220;Per-Object Behavior in Ruby&#8221;. Definitely the most enlightening talk amongst the ones I&#8217;ve listened to. Writing more about it would be a waste of time, just grab the &lt;a href=&quot;http://www.avc-cvut.cz/avc.php?id=6828&amp;amp;#38;language=en_US video&quot;&gt;video&lt;/a&gt; and watch it. Made me a better Ruby programmer.&lt;/p&gt;


	&lt;p&gt;15.15: Nic Williams &#8211; &#8220;Meta-Meta-Programming with Ruby&#8221;. I was disappointed. If I had to give it &#8220;the most&#8221; title, it would be &#8220;the most disappointing talk&#8221;. Dr Nic is a well-known man in Ruby and Rails community, and  &#8211; to say the least without writing pages about great things he&#8217;s done &#8211; he definitely deserves his fame and thus I was looking forward to listening to a talk by someone of such format. But, as I wrote earlier, I was disappointed. Dr Nic put too much weight on making his talk easy, witty and full of jokes and, well, hasn&#8217;t put a lot of technical knowledge into his talk. Sure, it was a bit philosophical, but definitely not worth 45 minutes of Ruby conference.&lt;/p&gt;


	&lt;p&gt;After spending some time on Lightning Talks (few were great, few weren&#8217;t) we&#8217;ve decided to get some more of Prague&#8217;s views and beer (I also had to give my talk a few finishing touches and some polish), and thus left Euruko until sunday.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.aenima.pl/">
    <author>
      <name>tomash</name>
    </author>
    <id>tag:blog.aenima.pl,2008-06-07:6</id>
    <published>2008-06-07T08:33:00Z</published>
    <updated>2008-06-07T08:34:03Z</updated>
    <link href="http://blog.aenima.pl/2008/6/7/railsconf-2008-is-over-so" rel="alternate" type="text/html"/>
    <title>RailsConf 2008 is over, so...</title>
<content type="html">
            ... so let's publish my impressions from march'08 EuRuKo. Finally, that is.
          </content>  </entry>
  <entry xml:base="http://blog.aenima.pl/">
    <author>
      <name>tomash</name>
    </author>
    <id>tag:blog.aenima.pl,2008-04-14:4</id>
    <published>2008-04-14T09:32:00Z</published>
    <updated>2008-04-14T09:34:35Z</updated>
    <category term="ruby"/>
    <category term="translations"/>
    <link href="http://blog.aenima.pl/2008/4/14/you-can-write-fortran-in-any-language" rel="alternate" type="text/html"/>
    <title>You can write FORTRAN in any language</title>
<content type="html">
            &lt;p&gt;This is a translation of &lt;a href=&quot;http://radarek.jogger.pl&quot;&gt;Radarek&lt;/a&gt;'s &lt;a href=&quot;http://radarek.jogger.pl/2008/04/14/you-can-write-fortran-in-any-language/&quot;&gt;excellent article&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;You can write FORTRAN in any language&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;A language that doesn’t affect the way you think about programming is not worth knowing&lt;/i&gt;&lt;/p&gt;
&lt;h3&gt;You can write C code in Ruby:&lt;/h3&gt;
&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;Car = Struct.new(:model, :color, :opt)

CAR_MODEL_BWM       = 0
CAR_MODEL_AUDI      = 1

CAR_OPT_GAS         = 0x01
CAR_OPT_AIR_COND    = 0x02
CAR_OPT_ROOF_RACK   = 0x04

CAR_COLOR_BLACK     = 0
CAR_COLOR_RED       = 1
CAR_COLOR_GREEN     = 3
CAR_COLOR_BLUE      = 4
CAR_COLOR_WHITE     = 5

CAR_MODEL_NAMES = [
  &amp;quot;BMW&amp;quot;,
  &amp;quot;AUDI&amp;quot;
]

CAR_COLOR_NAMES = [
  &amp;quot;black&amp;quot;,
  &amp;quot;red&amp;quot;,
  &amp;quot;green&amp;quot;,
  &amp;quot;blue&amp;quot;,
  &amp;quot;white&amp;quot;
]

def car_create(model, color, opt = 0)
  car = Car.new
  car.model = model
  car.color = color
  car.opt   = opt
  return car
end

def car_print(car)
  printf(&amp;quot;[Car] model: %s, color: %s\n&amp;quot;, CAR_MODEL_NAMES[car.model], CAR_COLOR_NAMES[car.color])
  printf(&amp;quot;Options: \n&amp;quot;)
  if car_has_gas(car)
    printf(&amp;quot; - gas\n&amp;quot;)
  end
  if car_has_air_cond(car)
    printf(&amp;quot; - air condition\n&amp;quot;)
  end
  if car_has_roof_rack(car)
    printf(&amp;quot; - roof rack\n&amp;quot;)
  end
end

def car_max_speed(car)
  case car.model
  when CAR_MODEL_AUDI
    return 200
  when CAR_MODEL_BWM
    return 220
  else
    return -1
  end
end

def car_has_gas(car)
  return (car.opt &amp;amp; CAR_OPT_GAS) != 0
end

def car_has_air_cond(car)
  return (car.opt &amp;amp; CAR_OPT_AIR_COND) != 0
end

def car_has_roof_rack(car)
  return (car.opt &amp;amp; CAR_OPT_ROOF_RACK) != 0
end

car = car_create(CAR_MODEL_BWM, CAR_COLOR_BLACK, CAR_OPT_AIR_COND)
car_print(car&lt;/pre&gt;

&lt;h3&gt;You can write Java code in Ruby:&lt;/h3&gt;
&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;class User
  def initialize(name, age)
    self.setName(name);
    self.setAge(age);
  end
  
  def setName(name)
    @name = name;
  end
  
  def getName()
    return @name;
  end
  
  def setAge(age)
    @age = age;
  end
  
  def getAge()
    return @age;
  end
end

class Iterator
  def initialize(array)
    @index = 0;
    @array = array
  end
  
  def hasNext()
    return @index &amp;lt; @array.length();
  end
  
  def getNext()
    @index += 1;
    return @array[@index - 1];
  end
end

array = [User.new(&amp;quot;john&amp;quot;, 20), User.new(&amp;quot;ala&amp;quot;, 30), User.new(&amp;quot;dave&amp;quot;, 15)];
it = Iterator.new(array);
while (it.hasNext())
  user = it.getNext();
  puts(&amp;quot;Name: &amp;quot; + user.getName() + &amp;quot;, Age: &amp;quot; + user.getAge().to_s());
end&lt;/pre&gt;

&lt;h3&gt;You can write Perl code in Ruby:&lt;/h3&gt;
&lt;pre class=&quot;syntax-highlight:ruby&quot;&gt;while gets
  chomp
  next if /^#/ or /^!/
  break if /quit/
  
  if /(\d+)/
    print $1
  end
end&lt;/pre&gt;
&lt;p&gt;The purpose of this note: if you want to program in Ruby, learn the language properly, not just the syntax with standard library. Learn it long enough (or effective enough) until you learn it's style, mindset, idioms and nuances. Then write your Ruby programs using these idioms, standards, way of naming and structing and so on. Don't stop until you learn almost all about it - and when you do, you'll find a lot more to be learned about. You probably already know what OOP is, so put emphasis on non-obvious basics, like method-calling, mixins, includes, extends, metaclasses and so on. Experience life without static typing, experience the power of Ruby's metaprogramming possibilities (and dangers).&lt;/p&gt;
&lt;p&gt;Otherwise there'll be a chance you're not writing Ruby, but some other language using simply Ruby syntax. If so - why pretend to write Ruby?&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://blog.aenima.pl/">
    <author>
      <name>tomash</name>
    </author>
    <id>tag:blog.aenima.pl,2008-03-31:3</id>
    <published>2008-03-31T09:05:00Z</published>
    <updated>2008-04-03T09:09:24Z</updated>
    <link href="http://blog.aenima.pl/2008/3/31/back-from-euruko-2008" rel="alternate" type="text/html"/>
    <title>Back from Euruko 2008</title>
<content type="html">
            &lt;p&gt;We just got back from Prague after attending to &lt;a href=&quot;http://www.euruko2008.org/&quot;&gt;European Ruby Conference&lt;/a&gt;. Promise to write a review after we get everything running smoothly again (including this blog).&lt;/p&gt;
          </content>  </entry>
</feed>
