Home Home
Sign up | Login

Deprecation notice: openSUSE Lizards user blog platform is deprecated, and will remain read only for the time being. Learn more...

Author Archive

Ruby: Do not use += in loops

October 8th, 2014 by

My motivation for writing this blog post is to have one simple place where I can point everybody using += in a loop. I will describe here why it can kill the performance of any application or library and will also show some measurement to demonstrate it. (more…)

No forgotten patch to YaST anymore

January 17th, 2014 by

As I wrote in the last blog post, we try try to open YaST development as much as possible. When I thought what is the most annoying thing for me when contributing to an open source project, then it is when my contribution is ignored. So if I send a patch and do not get any response or I get response, but my patch is not merged without any reason, then I do not contribute again as I see it as a waste of time. To prevent such situation in YaST I’ve created an automatic reminder of pending pull requests for the YaST repos at GitHub.

How it is done? I want to have it transparent, reusable and automatic. The core component is a small ruby script I wrote to fetch pending requests for an organization on GitHub. It uses the GitHub API and tries to find any pull request without activity for three working days.

This script is handled by our public Jenkins server where it pulls the latest version of the script every working day and if there is any pending pull request it will send an email with its result to the YaST mailing list.

After a month of sending emails we have handled all longer running pull requests we have for YaST, so none of them have gone without activity longer than a month. I hope it encourages developers to create more pull requests as they will not be forgotten. We plan also to deploy such reminder for the libyui organization.

Continuing Opening YaST

December 16th, 2013 by

YaST switched to the GPL license back in 2004, but there were still a lot of obstacles to easy contributions to the project. There was a bunch of changes in the past to improve contribution to the project, like switching from the openSUSE subversion server to GitHub, generating documentation to doc.opensuse.org or having public IRC. But we are not satisfied and do even more steps to make it easy to contribute to YaST.

The most visible action in the last year was the conversion from YCP to Ruby. We found that having a special language just for YaST made some sense in the past, but now becomes useless and makes obstacles for newcomers which must at first learn a language before they can change anything. Ruby is a well known language with a nice ecosystem around including benchmarking, profiling, debugging or testing frameworks. The latest mentioned testing framework is quite important, because good test coverage allows reducing of fear from changes. For tests we chose the well known framework RSpec, so people coming from the Ruby world know it and others find it intuitive.

Related to tests are also continuous integration that tests code after each code change and automatically sends new packages to the devel project and to Factory if needed. We make our CI node publicly visible on the openSUSE CI server, so everyone can see if build succeeded and what is the reason if it failed.

We also decided to help newcomers with a quick introductory documentation. One page recently updated to reflect the current state is about code organization which helps newcomers to orient in current YaST modules. The content is a bit terse and a minority of pages links to some old tutorials and documentation, but we take care to quickly react to questions and suggestions.

Another change is deletion of the internal YaST IRC channel and now all communication happens on the #yast Freenode channel. This change really increases the chance that you catch YaST developers on IRC. Others ways are the YaST mailing list, Bugzilla, GitHub or openSUSE feature tracker.

So let’s start hacking YaST and if you find any obstacle, contact us, so we can remove it.

Ruby: Why to use symbols as Hash keys ( and why not )

May 24th, 2012 by

I have often read that for hash keys it is better to use symbols than strings. So I was interested why and what is performance impact. It is quite easy to create a test scenario to measure it. The blog post also contains technical explanation and shows potential security problem. (more…)

CLI to upload image to openstack cloud

April 18th, 2012 by

I work on automatic testing of one of our products that creates other projects.
And because there is a lot of clouds everywhere I want to use them too. We
have internally an OpenStack cloud (still Diablo release). So I need to solve
automatic uploading of images built in the Build Service. Below I describe my working version.


Temporary overwrite method for specific task

March 18th, 2011 by

today I must solve issue with not well structured code. Problem is that one method return last correct version, but in one specific case it needs to return newest version (even incorrect). There is many calls between top level method which know what needs to call and target method which is called from generic code. Now I need to fix it and code is not well tested and quite sensitive to changes ( this fix is fix of another fix :). So what is the safest way to change it?
I decide that the best solution which doesn’t change almost nothing ( but is suitable just for maintenance update, for trunk I create better solution ) is temporary overwrite of target method to change its behavior. Now how to do it?
There is simple example:

class T
  def test
    puts "test"

  def lest
    puts "lest"

  def m

T.send(:define_method,:m_a) { lest }
T.send(:alias_method, :m_old, :m)
T.send(:alias_method, :m, :m_a)
T.send(:alias_method, :m, :m_old)
T.send(:undef_method, :m_a)
T.send(:undef_method, :m_old)

as you can see after modification class is exact same as before ( except if there is method a, but it is possible to handle it via introspection and dynamic choose of method). I don’t need to change whole stack of calls to add parameter or introduce new singleton class which can have flag.
I hope it help someone with his fix of not so well written piece of software.

Easy scripting actions with susestudio alias new rubygem studio_api

December 23rd, 2010 by

Now I work for SLMS ( Suse Lifecycle Management Server ) project. It cooperate with SuSE studio and use its API. I get idea that more people could benefit from easy access to studio API from ruby so I extract functionality and improve behavior, documentation and testing and now there is new rubygem studio_api.
Why you should use this gem?

  • ActiveResource Behavior
  • Actively maintained ( and will be due to SLMS support )
  • Tightly developed with guys from studio team
  • Well documented with yard
  • Good test coverage


Hackweek 5 – LXDE

June 8th, 2010 by


as hackweek continue I want to present my contribution for this year event. My plan is to support our the youngest supported desktop environment LXDE. So I contact our LXDE guy Andrea Florio and he ask lxde developers. Then we communicate directly and I found as the most intersting idea to replace gnome gvfs which is needed to have usable gio interface in glib ( geek-deserialization: allow easy access remote systems, zip archives in file manager like it is part of filesystem). Motivation for replacement is quite big gvfs dependency and system resource requirements. It choose it because I can learn something new, can return to programming in C from Ruby on Rails which is used for webyast and last not least I think it is usable also for another lightweight environment xfce4.

Code can be located in pcman git repository. Idea of implementation is quite simple. Don’t use daemons and special code to handle different backends. Instead use fuse and its already written fs based on fuse. As first I start with ftps and its sshfs implementation. Code for single fs is simple and short. Today I finish first working proof of concept of gvfs extension and its gfile extension. It can query and copy file on gvfs as you can see in file gfusevfs.c where is testing program. Main problem which I still see is that fs is not umounted so it takes some sources, but umount it after file operation can lead to annoying behavior like passing password on each file operation.

I welcome any comments and ideas about this project.

Encrypted directory

December 3rd, 2009 by

I have notebook which contain private data and I don’t want anyone to read it even if my notebook will be stolen. Encrypted whole home partition is too much as my home directory contains also svn or git repositories which could anybody read. So I create encrypted directory in home directory which contain all private data and rest is normal accessible. So how to do it? (more…)

Ruby on rails, Ajax and memory watching

May 14th, 2009 by

As work on webinterface for YaST is in progress we must learn new technologies suitable for web development. WebYast will be written in ruby and ruby on rails framework. Also because WebYast is new interface it could contain AJAX features for better user comfort. Today I found that ajax support in RoR is on good level and with documentation it takes few minutes to create first example which show current used memory on server. It is not connected anyhow to YaST because I want to focus on AJAX.
And here is a code. It update page every fifth second (but not refresh only update div, on bigger page it is really significant):
<%= javascript_include_tag :defaults %>
<h1>Hello world!</h1>
<%= periodically_call_remote(:url => { :action => 'get_averages' }, :update => 'avg',:frequency => '5') %>
<div id="avg">
Memory usage is X MB </div>
class HomeController < ApplicationController
   def index
   def get_averages
     output = `free -m` # bash solution - | sed 's/Mem:[^0-9]+[0-9]+[^0-9]+([0-9]+).*$/1/;2q;1d'`
     output = $1 if (output =~ /.*n(.*)n.*n.*n/) #let live second line
     output = $1 if (output =~ /.*:s+S+s+(S+)s+/) #second field
     render :text => "Usage mem is "+output+"MB RAM."

And thats all to watch your server usage.