Csabi's blog

Software Craftsmanship, Agile, and other Ideas about Programming

Subscribe to RSS feed

Din seria "Cartierul Meu" - 2

Creative Commons License
All pictures published on this blog by Patkos Csaba are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Roses Bouquet

Creative Commons License
All pictures published on this blog by Patkos Csaba are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Din seria "Cartierul Meu"

Creative Commons License
All pictures by Patkos Csaba published on this blog are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Au inceput sa infloreasca trandafirii prin Timisoara

Creative Commons License
All pictures by Patkos Csaba published on this blog are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Prezentare Agile, Unit Testing & TDD - ITFest 2012 Timisoara

Prezentarea se va incarca la accesarea postului. Aveti rapdare, are 12MB!
Click pe imagine pentru a o vedea ca prezentare. (posibil sa nu mearga in IE)

Read more...

Just Discovered digiKam

I just discovered digiKam. It looks like a very cook image manipulation, album management and camera management program.
Here is a picture of it in action:

And here is the picture from the above picture. I kind of like how this Kodak ZD710 sets the colors. They are almost like in real life.

Rolling Release Distros - The Agiles of The Linux World?

I was wondering the other day. All those old har-core Linux distributions seems so faded out, so forgotten. If you look at the distrowatch top distributions, rolling release distributions are getting more and more love each time. Distributions like Arch, PCLinuxOS, Sabayon, etc. are coming fast and they are as good or better than the old ones. Slackware, Gentoo, Fedora are loosing, little-by-little against these newcommers.

I can't keep my self continuously make the analogy that old distros which are releasing once or twice a year, usually with delays after many QA weeks, look exactly that the old Waterfall model.

On the other hand, rooling release distros are pushing tested update weekly or so, they do not concentrate their effort on specific releases, they upgrade continuously and a release is just an ISO build at a random week so that there is some way to install directly the newest version. They are pretty stable, they have relatively new software and most of all I like that I will never need to reinstall the whole system again.

So, are rolling-release distributions the "Agiles of the Linux World?"

Installing fonts in Sabayon LInux

  • copy the fonts to ~/.fonts
  • cd ~/.fonts
  • fc-cache


That's all.

PS: if you want to install system wide, for all user, do the same as root in /usr/share/fonts.

When the prezis die...

So, it seems like out-of-process-plugins in browsers on Linux are messed up. For example, no more right click in Prezi prezentations, meaning you can't copy/paste anything, meaning you can't finish your presentation.

But fear not! I just discovered Sozi, a great extension for Inkscape that lets you do all the zoom / slide / pan stuff that Prezi offers. You also have the advantage of an advanced SVG editor and the possibility of offline editing. The Sozi plugin is not that 'ergonomic' that the Prezi interface, but it does it's job and the result is a SVG standard file with some javascript inside. Works in all modern browsers (IE is not one of them).

Click here for an example. Navigate with mouse left/right buttons or keyboard left/right arrows.

How many slides per minute?

I had an argument with my colleagues today about how many slides per minute should be in a presentation. The opinions differed from person to person, ranging from 30 sec/slide (aka 2 slides/minute) up to at most 10 slides in total regardless of the time taken for the presentation. Obviously there was no consensus at the end of the discussion, we are an agile software development team after all, we do not or rarely agree on anything p

However the discussion made me curious as I am about to keep a presentation for some students and I want to prepare it the best I can. Doing some research on the Internet (yes ... googling for 'how many slides per minute') led me to many great articles and even more opinions and comments to those articles.

As I expected, there doesn't seem to be a general rule, however after reading all those articles I can conclude some personal opinions:
- regardless of what is contained in your slide, it should never stay on the screen more than 3 minutes
- slides with graphics / schemas are the most time intensive, the public needs time to understand the schema
- a slide should contain as less text as possible because people read 5 times faster than they talk. So if you have too much text in a slide the audience will reed ahead and what you say will be boring.
- I still think that a slide should not be displayed for more than 30 seconds unless in one of the first to ideas above
- if you use pan & zoom, the time between the steps can be as less as 5 seconds, but take no more than 3 minutes to 'navigate' over the whole slide representing the main idea
- 1 slide per idea (maybe read as sub-idea)
- about 3-5 slides per main idea
- one main idea should be presentable in 3 minutes
- use sequential slides where possible, thus building the idea step-by-step and reaching a final 'slide' or 'image' or 'schema'

I will not give many links, you can find a lot of sites about slides with google, but I really loved this presentation ... about presentations. It is entitled 'Effective Presentations', it has 41 slides shown in 12 minutes, meaning 3.4 slides / minute on average and it is not even fast-paced.

Enjoy: Effective Presentations

How Comes Sci-Fi is in Decline?

If you look at the present and upcoming movies this year, there is very little sci-fi. Maybe five or so titles. Also, sci-fi on television is in clinical death. There is not even one tv show with space ships.

But still, in the All-Time Top 5 Grossing Films (Worldwide), two are real sci-fi, two are fanatasy/sci-fi and if you count Titanic as sci-fi....

1. Avatar 2009 $2.78 billion
2. Titanic 1997 $1.84 billion
3. Harry Potter and the Deathly Hallows, Part 2 2011 $1.33 billion
4. The Lord of the Rings: The Return of the King 2003 $1.13 billion
5. Transformers: Dark of the Moon 2011 $1.11 billion

Source: World wide box office via Airlock Alpha

Nvidia GForce GT430 vs. 8600GT

I just installed a Zotac Zone GT430 into my system and run the same benchmarks I did some time ago for my previous card: 8600GT results.

Here are the results. Benchmark setups are as before:

Unigine Sanctuary
- 8600GT: 1600 points / avg 37.5 FPS
- GT430: 2246 points / avg 53 FPS

Unigine Tropics
- 8600GT: 210 points / avg 9 FPS
- GT430: 836 points / avg 33 FPS

Nice update... bigsmile

Selecting the Proper OpenGL Vendor

Selecting the proper OpenGL vendor after a kernel and nvidia drivers update can be tricky. For some reason, my Sabayon Linux decided that I should use an opensource OpenGL implementation with the proprietary nvidia drivers instead of the proprietary nvidia OpenGL implementation. So, I had to fix the problem and I did thanks to my friend EAndrasi
# eselect opengl set nvidia

CD DVD Tray won't Stay Open

In case your system decides to not keep you CD/DVD tray open so you cant put/remove disks, and the button on the device doesn't work either....
dev.cdrom.autoclose = 0
dev.cdrom.lock = 0
Put the above lines in /etc/sysctl.conf and then reload the file with
# sysctl -p

Thunar Send to BlueTooth Device with ObexFTP

, , , ...

Pair your computer with your device using whatever BT manager your system has. Make sure you have obexftp installed, than create a new "Send to" file for Thunar and put into it something like this:
[Desktop Entry] 
Type=Application
Version=1.0 
Encoding=UTF-8 
Name=Bluetooth Send to LG Viewty 
Icon=bluetooth 
Exec=/usr/bin/obexftp -b 00:00:00:00:00:00 -p %f
Replace 00:...:00 with your blue tooth device's address (use "hcitool scan" to find it)Save the file to ~/.local/share/Thunar/sendto/Your-Great-BT-Script.desktop

Easy Way to AutoLogin into X on Sabayon Linux

, , , ...

So, it took me 3 days to find this very simple solution for an auto login into X on Sabayon Linux.

Install SLiM Simple Log-in Manager
equo install slim

Set xdm to use slim by modifying /etc/conf.d/xdm
DISPLAYMANAGER="slim"

Make sure xdm starts at default level
rc-update add xdm default

Change /etc/slim.conf to select a default user and log in automatically. Find and modify the following lines:
default_user        your_user_name_here
auto_login          yes

Also change the login method to use ~/.xinitrc in the same /etc/slim.conf file
login_cmd           exec /bin/sh - ~/.xinitrc %session

Make sure your ~/.xinitrc starts the proper DE. I am using Enlightenment E17, and I have this single line in my .xinitrc
exec /usr/bin/enlightenment_start

That's all. Now reboot to see it in action.

Ruby's Watchr Configuration for ShUnit2

, , , ...

require "erb"

watch('tests/.*Test\.sh') do |md|
  clear_console
  run "#{md[0]}"
end

watch('source/(.*)\.sh') do |md|   # runs test when source code changes
  clear_console
  testpath = "tests/" + md[1] + "Test.sh"
  run "#{testpath}"
end

def clear_console
  puts "\e[H\e[2J"  #clear console
end

def run cmd
  result = `#{cmd} 2>&1`
  if result.match(/FAILED\s+\(failures=/)
    notify_failed cmd, result
  elsif result.match(/ERROR/) or result.match(/command not found/)
    notify "#{cmd}", result, "pending.png", 6000
  elsif result.match(/\nOK\n/)
    notify "#{cmd}", "<font size=4 color=lightgreen><b><i>Tests Passed Successfuly</i></b></font>", "success.png", 1000
  else
    notify "#{cmd}", "Unknown error: 
" + result, "pending.png", 3000
  end
  puts result
end

def notify_failed cmd, result
    ft = result.match(/.*(test.*)\nASSERT:(.*?)\n/m)
    first_failing_test = defined?(ft[1]) ? ft[1] : "no match"
    first_failure_message = defined?(ft[2]) ? ft[2] : "Critical"
 
    notify "#{cmd}", "<b>" + first_failing_test + "</b> failed!\n" +
      "<font size=3 color=pink><b><i>" + ERB::Util.html_escape(first_failure_message) + "</i></b></font>", "failure.png", 6000
end

def notify title, msg, img, show_time
  images_dir='~/.autotest/images'
  system "notify-send '#{title}' '#{msg}' -i #{images_dir}/#{img} -t #{show_time}"
end

Using Ruby's Watcher for Continuous Bash (shUnit) Testing

, , , ...

So, did you ever TDD a Bash script? ... Very well, I thought so. But, what about continuous testing with shUnit? You know, the cool automatic tests we run when programming in Ruby wink

Yeees! You can do that with any language with the help of Ruby's Watchr gem. If you are on Linux, you will want libnotify also. So, how do you do it? Take a look at the script below, adjust the parameters to your needs and run watcher like this: 'watchr autotest_file_you_just_wrote'

watch('tests/.*Test\.sh') do |md|
  clear_console
  run "#{md[0]}"
end

watch('source/(.*)\.sh') do |md|   # runs test when source code changes
  clear_console
  testpath = "tests/" + md[1] + "Test.sh"
  run "#{testpath}"
end

def clear_console
  puts "\e[H\e[2J"  #clear console
end

def run cmd
  result = `#{cmd}`
  if result.match(/No tests failed/)
    notify "#{cmd}", "<font size=4 color=lightgreen><b><i>Tests Passed Successfuly</i></b></font>", "success.png"
  else
    first_failing_test = result.match(/^.*:\s+(.*)\s+E/)[1]
    first_failure_message = result.match(/^(.*)failed/)[1]
    notify "#{cmd}", "<b>" + first_failing_test + "</b> failed!\n" +
      "<font size=4 color=pink><b><i>" + first_failure_message + "</i></b></font>", "failure.png"
  end
  puts result
end

def notify title, msg, img
  images_dir='~/.autotest/images'
  system "notify-send '#{title}' '#{msg}' -i #{images_dir}/#{img} -t 3000"
end

Have fun smile

Ruby Plasmoid and Qt::Timer (time events)

, , , ...

In the past couple of days I was working on a simple plasmoid for KDE and my NVidia video card. This time it is written in Ruby.

However I had a big problem. I lost more than a day to figure out how to use a timer in Ruby in a plasmoid. There are several tutorials and examples out there but all I could find is outdated and not working. Finally, I found a working ruby plasmoid and adapted a solution from it. It is, as everything in Ruby, more simple than anyone would expect. So, here it is.
In your 'def init' write this:
@refresh_interval = 10000
start_timer(@refresh_interval)

And than define a timer event:
def timerEvent(event)
	# your code to be run every @refresh_interval miliseconds
end


My plasmoid can be found on kde-look:
http://kde-look.org/content/show.php/Simple+NVidia+Info+v2?content=147669

A Couple of Words. The Pragmatic Programmer

Now Reading

So I started reading The Pragmatic Programmer about a month ago, but I did not write about the book yet. It is an interesting reading. The book was written a couple of years before Agile and it reflects the techniques and ideas of late '90s. I can't keep not comparing it with The Clean Coder.
Both books talk about similar things. About how should professional programmers behave, work and live. The Clean Coder is more person oriented, more team oriented, it's more about 'sentimental' principles. On the other hand The Pragmatic Programmer is more about programming. Many of the principles and techniques presented in the book are common knowledge our days, but back in 1999 it was like Agile and Clean Code is today.

So, even if the information is more than 12 years old it is still valid and the book is a joyful reading.

Fun Day Testing Views

So, what (how) do you test when you test views? It is easy to find a lot of technical information about how do you test a view in Rails. You can find so many code and examples that you do not even know where to start. This is good, but there is a problem.

Which parts of a view should you test? This is a much harder question and there is no general answer for it. Me and my colleagues had a long talk about this and we concluded 3 main ideas:
  1. test only conditionally shown parts of a view (this includes text shown dynamically from objects or variables)
  2. do not test for HTML tags or CSS selectors (only in special circumstances)
  3. always try to match a text that should be visible

These 3 simple principles led us to much clearer views, conditional rendering being extracted in helpers and method calls tested on views. You almost can read a view as well written prose.

Extracting 'render' statements into helpers also helps a lot. You can test the call in the view to the appropriate helper method. Then, you can test the helper and check that the method calls 'render' with the desired parameters. Unfortunately you can't directly test a call to 'render' in a view. This is an intensional limitation of RSpec 2. But, this is, after all, a good thing. It forces you to decouple any logic, including render and partial render logic, in the views. Any other view can this way use the helper and render all that stuff easily ... also some code duplication is reduced.

Code Retreat was Fun!

, , , ...

Last Saturday (3rd Dec 2011) there was the Global Code Retreat. It was my first participation on this event and I very much enjoyed it. It was one of the best coding days of my life. I never thought that coding just for fun with a bunch of strangers can be so much fun and also educational.

What is Code Retreat:
http://coderetreat.com/

Romania was the first non US country to hold a Code Retreat, in may-june 2009:
http://photos2.meetupstatic.com/photos/event/8/9/6/e/highres_75515182.jpeg

What Makes a Program Object Oriented?

Many may argue, but the most important thing that makes a program really object oriented is the "Dependency Inversion Principle". If you do not invert your dependencies you are just writing traditional procedural code "masked" within classes and objects.
Inverting dependencies is not enough but it is necessary for any application for it to be truly object oriented.

Dependency Inversion Principle:
  • High-level modules should not depend on low-level modules. Both should depend on abstractions.
  • Abstractions should not depend on details. Details should depend on abstractions.

More details:
http://www.objectmentor.com/resources/articles/dip.pdf
http://www.oodesign.com/dependency-inversion-principle.html

Ruby or not Ru-(be)

It is one week since my first contact with Ruby (and with Rails), and it is time for some first impressions.
As every beginning, this one also was hard. Ruby is so different from what I've used so far, but that does not mean it is bad. In fact Ruby is quite nice. What I have problems with is Rails. First I had to better understand the whole concept of MVC, than learn the conventions, then discover all the "magics" Rails do for you. Unfortunately this is a very steep learning curve and with very little results at the beginning. For example, it can take days just to figure out how to output a form with nested attributes. Of course, I could hardcode it in 30 minutes, but that would defeat the point.

Another dilemma is what IDE to use for Ruby and Rails? First of all, let's point out that editors are not IDEs.
If you are looking for Ruby editors, TextMate, Vim, Komodo pops up as first choices.
However I was looking for IDEs, where I have advanced features, refactorings, unit testing support and so on. There are only a few cross-platform solutions: Ecplipse + some plugins, Aptana for Ruby (based on Eclipse), NetBeans + RubyPlugin, RubyMine from IntellyJ.
Now, each of these has it's pros and cons. Ecplipse and Aptana are quite strange and with hard to change presets which makes you loose a considerable amount of time for setup. Also Eclipse based IDEs are pretty slow. The effective Ruby and Rails support is good, though.
RubyMine is the most advanced IDE I've found, unfortunately it has 2 major drawbacks: it does not run well on OpenJDK (note that even Sun recommends OpenJDK on Linux instead of the sunJDK) and it is commercial (it has a $99 price, which is pretty fair).
So, I ended up with NetBeans (again) and Ruby plugin. This one is the best I could find, the only (temporary) problem is that the plugin is not yet ready for NetBeans 7.1 which in turn is in RC state at the moment of writing this post. As far as I know there is some work going on to port the Ruby plugin to the new NetBeans 7.x API and it should be available in the near future, let's hope it will be there when 7.1 will be released.

Programmers Should Use the SHELL

After all, can't you do everything equally well by pointing and clicking?
The simple answer is "no". [...] A benefit of GUIs is WYSIWYG - what you see is what you get. The disadvantage is WYSIAYG - what you see is all you get.

The Pragmatic Programmer, by Andrew Hunt and David Thomas