Life at TUDelft

QRIt is hard to believe that six months passed since I was stepping, worried, out of the terminal in the Schiphol airport, in Amsterdam. Meanwhile I went home once but this is another story. What am I doing at the Technical University of Delft? Well… It’s simple: “I’m busy”. I work, now, on 4 projects, all software related. Mostly sure you are not interested in what I do with distributed algorithms or domain specific languages. So, I’ll present the most interesting project. The QR.

The QR is a Quad Rotor Unmanned Aerial Vehicle developed by another department from the University. We are struggling to do doing the software that will make it fly. The software is made of two parts: one part running on a PC and another running inside the QR. The device is not yet advanced. Currently it has the minimum necessary in order to stabilize in air (gyroscopes, accelerometers and engines). In future, cameras, wireless interfaces and other gadgets will become available.

Today was an important day because we had the first engine test. The first try was not successful but after a bug was fixed we managed to throttle a little the engines (see the movie below). The device cannot fly yet because the stabilization routines are not implemented and no human will be able to control it for more than a few seconds without digital assistance. You may wonder how can one control it: through a joystick that is connected to a PC.

Read the rest of this entry »

Part of my plan: Books (Update 1)

In December I was writing about my plan of reading 16 books. Today I offer a status of the plan and my impression about two books.

From that list I read “The Inmates are Running the Asylum” and “The Design of Everyday Things”. Actually from the last one I read just 3/4 because the the book is too theoretical (psychology) and, even though I like psychology, it was a little too boring much – don’t get me wrong, the author offers valuable information about the things used every day and how simple is/should be the design, but the mix of practical and theoretical has a wrong ratio.

However, the former book is absolutely fascinating. Alan Cooper shows that whatever has a computer is actually a computer (or at least has that complexity). He also shows that programmers tend to increase the complexity of the software in order to make the development easier or, just because they can and see this a challenge. One of the main ideas of the book is that programmer cannot design simple software; they always design software that is supposed to be used by people with a lot of technical knowledge, who enjoy complicated things. Cooper’s suggestion is that developers should create software that is as simple as possible to operate, for the end user and, usually, the design must be made by a designer (a person who is able to understand how an experienced person will act).

Currently, my attention is on “Surely You’re Joking, Mr Feynman”. The book has a nice introduction about the first years of Richard Feynman’s life, but things may change as I progress with the lecture. I postpone any conclusion until I read the last page of the book.

The Game of Life

A few days ago I was getting bored and decided to to something fun. Yes, you can get bored at TUDelft… Well, actually you don’t get bored, you get sick of all the work you have to do (apologies to anyone offended by this). So in a quest of something fun but still productive I found Conway’s Game of Life.

Game Of Life

The Game of Life is not really a game because no one plays it. It is a cellular automaton, a zero player game in which the only human interaction is the initial setup. Then the game evolves by itself under the constraint of some rules, until it gets to a stable state.

The game’s world is a 2D grid in which each node is a place that can hold one individual. Each individual can be dead or alive. Basically you can see the world as a black, white grid in which black represents living individuals and white dead ones (the figure on right).

Each grid represents a single generation. In order to get a new generation the current one must evolve. This process implies that every individual (dead or alive) node will be evaluated and, based on the result, will survive, die or resurrect. The evaluation function takes in consideration the number of alive neighbors a node has (a node can have up to 8 neighbors):

  1. If one individual has less than two neighbors alive, it will be dead in the next generation because of underpopulation.
  2. If one individual has more than three neighbors alive, it will be dead in the next generation because of overcrowding.
  3. If one individual is alive and has two or three neighbors alive, it will survive in the next generation.
  4. If one individual is dead and has three neighbors alive, it will resurrect (be alive) in the next generation.

That’s all. Based on this transition, each individual gets from one state to another, from generation to generation. There are two situations in which no more changes will be made between generations:

  1. All individuals are dead.
  2. All individuals are in a stable state from which they cannot die. The square on right is a stable population that cannot change because all alive individuals have two or three neighbors and all dead individuals have at most two neighbors alive so they cannot resurrect.

The fun part was to implement this myself. I created a small MFC application that is able to load files with predefined configuration or to generate random populations up to 10.000 individuals. If you download the sample be aware it will crash if you load invalid files and do strange things – it is just a prototype.

Read the rest of this entry »

Using UAC with C# – Part 3

After a long period since I wrote part 2 of this article I decided to add some extra information. There is one thing that was missed by the previous two articles: the design of UAC enabled applications.

If you use Windows Vista/7 then you know that buttons and links which elevate privileges are preceded by a shield icon. This is the way Microsoft decided to inform the user about the effect of clicking that control.

The first idea that might pop up is the reinvention of the wheel (or shield). In other words you could draw the shield on a button. This is OK except that:

  1. Is not easy
  2. Will require you to recompile the interface if Microsoft decides to change the icon
  3. You need the icon in many sizes 16×16, 24×24, 32×32, etc. (extract it from MS’ DLLs)
  4. Will create a lot of overhead with layout (position icon relative to text size/position)

The second method is easier, safer and recommended by MS. All you need to do is send a specific message (BCM_SETSHIELD) to the button if the user has limited privileges and pressing that button will trigger the UAC window. Actually there is a second, tricky, thing that must be done: the style of the button must be “System” (in C# “System.Windows.FlatStyle.System”). Without this you will not be able to see the shield.

The code provided in part 1 of this article will be modified in order to display the shield on the two buttons. Moreover, the shield will be displayed only when the user runs under an account with limited privileges or non-elevated administrator.

In order to display the shield one needs to send the BCM_SETSHIELD (=0×0000160C) message to the button. This can be done by using the SendMessage function from user32.dll. This article will not cover what is and how to use SendMessage, if you need more information about it follow the previous link.

To set the shield of the “Elevate this application” button one needs to send the message in the following way:

SendMessage(btnElevate.Handle, BCM_SETSHIELD, 0, 1);

The first parameter is the handle of the button, the second one is the message, the third one is not used and must be ‘0′ and the last argument must be non-zero in order to draw the shield, zero otherwise.

If you try this it will not work :) Remember the ‘tricky’ thing told before? This is the full code to display the shield for btnElevate:

btnElevate.FlatStyle = FlatStyle.System;
SendMessage(btnElevate.Handle, BCM_SETSHIELD, 0, 1);

There is only one thing that must be done in order to work properly. Remove the shield if the user has elevated privileges. I don’t know if this is against MS’ recommendation but in my opinion one must not be shown information that cannot be used in that context; in our case don’t show the elevate shield if there is nothing to elevate.

Part 1 described how to check if a user has full rights. Now we are just using that boolean variable:

if (!hasAdministrativeRight)
    SetUACShields();

Where SetUACShields will send the message to all buttons that require the shield drawn.

The full updated code from Part 1: Download IconUAC Code 3 (10.13 KB)

Happy New Year

Happy New Year

See you in the next year…

Tip #8: Make Firefox Better

What I want from a browser

  1. To show the pages correctly
  2. To show as much as possible from a page (to remove the need of scrolling)
  3. To provide me with an easy way of accessing pages.

What I don’t like at Firefox

  • The search bar is superfluous. I really like what Chrome is doing (and the latest version of Opera?): use the address bar as search bar.
  • There is no ad blocker
  • There is a lot of wasted space: bookmarks toolbar, menu bar (just think how often you use the top menu), big icons

After a few tweaks I got a browser looking like the one in the picture below that satisfies almost all my needs.

Tweaks applied and how/why to use them

Read the rest of this entry »

Part of my plan: Books

I decided to read books (real books!) and many of them. For those (geeks) that don’t know what books are I will remind that books were used before the computers age, by people (!), to store and transmit high quantities of information. :-)

Today books are used to add extra height to different objects ranging from computers and laps to … babies. Books can be also found on shelves. If you find yourself between many shelves with many books it means you are in a library or a book store.

OK, funny enough. I tried to gather, from different sources, the high rated titles (tech and non-tech geeky books). The reading process will take me a few months (years maybe) but it worth.

It is obvious that one cannot enjoy all the books people recommend. Many times I found horrible a book rated by many with five stars. I am sure that from the list of books I want to read at least 10% will be abandoned after the first few pages. Some books just don’t have that… sparkle… that makes you want to continue the lecture.

Each book will get one of the following ratings:

  1. “Must read” (these books will get on the Books page)
  2. “Good book”
  3. “Mediocre”
  4. “Bad book”

Currently I am reading the first book in the list and seems to be a good one. Here goes “The List” in random order.

The Inmates are Running the Asylum: Why High-tech Products Drive Us Crazy and How to Restore the Sanity Practices of an Agile Developer: Working in the Real World The 7 Habits of Highly Effective People: Powerful Lessons in Personal Change Cryptonomicon

Working Effectively with Legacy Code Godel, Escher, Bach: An Eternal Golden Braid Coders at work Peopleware: Productive Projects and Teams

“Surely You’re Joking, Mr Feynman” The Design of Everyday Things Nineteen Eighty-Four Getting Things Done: The Art of Stress-Free Productivity

Structure and Interpretation of Computer Programs, 2nd Edition The Art of Computer Programming: Fundamental Algorithms The Mythical Man Month and Other Essays on Software Engineering Code: The Hidden Language

Did you read one of these books? Help me prioritize the list by telling your opinion about that book.

To visualize or not to visualize

VSImageVisualizer is one of my free open-source projects. Basically, it is debug visualizer for images for Visual Studio 2008 that allows developers to inspect the graphical representation of Image objects while in Debug mode.

Check the project page for more info.

11-11-11-11 Contest Winners

The winners of the contest are:

1st place (HandyBackup Professional): Timotei Dolean

2nd place (HandyBackup Standard): tisi, Ursul

Winners: please check your e-mail Inbox and Junk folder.

11-11-11-11 Contest

First Place
(Handy Backup Professional – $99)

pro

Handy Backup Professional is an advanced backup software designed for small and medium businesses. It extends functionality of the Standard edition with the following functions:

  • Backup to SFTP servers
  • Image backup
  • Database backup via ODBC connectivity

2 x Second Place
(Handy Backup Standard – $39)

standard

Handy Backup Standard is a simple PC backup and data synchronization utility for home and small office. It lets you easily back up all specifics of your system and your favorite applications:

  • Outlook backup
  • My Documents backup
  • Desktop backup
  • Windows Registry backup
  • Individual files and folders backup
  • Program settings, playlists, skins, etc.

The rules of the contest are simple:

  • Write here (as a comment) or on another site (with link to this post) the most unusual way in which you could lose your data.
  • The text must be written in English.

Contest period:

  • Starts on October 27th, 2009 at 11:11 AM GMT
  • Ends on November 11th, 2009 at 11:11 AM GMT

Why 11-11-11-11?

  • Because the contest ends on 11/11 at 11:11.

Prizes:

  • Handy Backup Professional license
  • 2 x Handy Backup Standard license

Winning conditions:

  • The best 3 texts win.

Winners will be announced on November 12th.

Reviews of Handy Backup:

Remarks:

  • If you post as comment make sure you enter a valid e-mail address so I can contact you in case of winning.
  • If you post on another site make sure there are some contact details there.

Read the rest of this entry »