Macbook 2,1 Alt Gr key on Kubuntu 10.04

Posted May 3, 2010 by William
Categories: General

Tags: ,

Last weekend I updated my laptop to the fresh Kubuntu Lucid Lynx. As on every update I lost the Alt Gr key functionality. So, I came to my blog to check how I solved it with the previous release. Unfortunately that didn’t work, for some reason I don’t know the xkb rules are ignored. It took me sometime to find out how to solve it but finally I succeeded. I guess it might work out on any other Macbook family laptop.

Go to System Settings>Regional & Language > Keyboard Layout

Check Enable keyboard layouts and then go to Switching Options. After that press the button next to the text 3rd level shortcuts and select the option Right Win under the section Key to choose 3rd level. Works immediately.

I hope you find it useful.

The Mythical Man-Month: Essays on Software Engineering

Posted May 3, 2010 by William
Categories: Book reviews

Tags:

For those who doesn’t know The Mythical Man-Month, it is a must read classic that all software engineers should read at least once. That way I was convinced to start reading it. Besides, I’ve seen so many recommendations over the internet and so many references to it in the literature that I was ashamed I hadn’t read it yet, until now.

It was written by Frederick P. Brooks, Jr.  in the 1975 after he had worked as a project manager  for the IBM System/360 computer and later for OS/360 development in the 60′s, both huge pieces of engineering for the time. Brooks tries to collect all the best practices and rules of thumb in software development and project management of complex projects that he learned during those experiences.

The anniversary edition (2nd edition), the one I’ve read, includes a few new chapters besides the original essay. Those are the No Silver Bullet (which itself would need another post) and a few others that review the propositions of the book some time later.

In this post I’m going to highlight a few things I liked about the book as a reminder to my future self. The bellow bullet points are  fragments from the book (in italics) followed by my comments about them.

  • The man-month is a fallacious and dangerous myth, for it implies that men and months are interchangeable. This is the argument that gives title to the book. Many tasks during the development of a program cannot be partitioned due to its inherent sequential constraints and even when tasks could be carried in parallel there is always an overhead in communication between workers.
  • Brooks’s Law:  Adding manpower to a late software project makes it later. This is a consequence of all the communication that is generated and all the time needed to train the new people.
  • All programmers are optimists. Thank god it wasn’t just me.
  • Conceptual integrity is the most important consideration in system design. To achieve it, the design should proceed from one mind or a small group of minds.
  • The second is the most dangerous system a person ever designs; the general tendency is to over-design it. As normally an architect has not the confidence to implement all the ideas that come up to him during its first design. During his second design, an architect will try to implement all the stored ideas from his first design.
  • Plan to throw one away, you will anyway. It is very important to prepare the design for changes because valid changes in objectives may certainly arise during development.
  • How does a project get to be a year late? … One day at a time. Brooks gives some great advices about preventing a schedule slippage.

There are many other interesting topics in the book like the importance of communication and organization of groups or how to scale small groups to design and implement large systems.

Overall it is a very good book even if you aren’t really interested in software management.

Macbook 2,1 Alt Gr key on Kubuntu 9.10 rc

Posted October 27, 2009 by William
Categories: General

Tags: ,

I’ve spent a lot of time looking for a solution to enable the Alt-gr key in my Macbook 2,1 and here it is the magic line:

sudo sed -i~ ‘/xkb_symbols “ralt_switch” {/a  include “level3(rwin_switch)”‘ /usr/share/X11/xkb/symbols/level3

This makes the right Apple key to work as Alt Gr.I found it here.

Google Chrome for Linux (quick review)

Posted June 6, 2009 by William
Categories: General

Last Friday, 5th June, I saw on slashdot the following post: Google Announces Chrome For Mac and Linux Dev Builds. The announcement said something that immediately caught my attention and made me wanna try it:

DON’T DOWNLOAD THEM! Unless of course you are

a developer or take great pleasure in incomplete,

unpredictable, and potentially crashing software.

So, I downloaded the ubuntu package from their dev channel and after a while trying it I found it very satisfactory.

From the things that doesn’t work yet the one I miss the most is the flash plugin. If your language is other than English you’ll find that input methods doesn’t work neither (no accents for now). Besides the missing features I haven’t had a single crash (yet) or any rendering issue. Web pages with javascript seems to go fast but not surprisingly fast, maybe I was expecting too much.

I guess there might be many blogs out there with good reviews of the Windows version, so I’ll just show a few snapshots I took.

New tab

New tab

The above picture shows how a new tab looks. As you can see it shows the most visited pages and the recently bookmarked and recently closed ones. It is still not possible to manage bookmarks or to add a bookmark bar.

Incognito mode

Incognito mode

Por…, I mean, Incognito mode already works :)

Find in page

Find in page

Something that bothered me at first is that the find in page bar is located at the right upper corner.

Omnibox

Omnibox

Omnibox is working although it is not possible yet to configure the search engines.

Download manager

Download manager

I like the clean look of the download manager.

A lot of configuration options are still missing but my conclusion is that it’s nearly usable for every day use. I just wonder why it took so much time for Google to develop the Mac and Linux versions. Was it just because of technical difficulties? Was it a lack of interest? Or a mix of both?

Conway’s Game of Life

Posted May 29, 2009 by William
Categories: Programming

Tags: , ,

For those who don’t know the Game of Life, it is a cellular automaton invented by the mathematician John Conway in the 70′s. The game consists in watching the evolution of a set of cells that interact with each other following 4 simple rules:

  1. Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
  2. Any live cell with more than three live neighbours dies, as if by overcrowding.
  3. Any live cell with two or three live neighbours lives on to the next generation.
  4. Any dead cell with exactly three live neighbours becomes a live cell.

It’s amazing to see the amount of literature available about this game. You can check the wikipedia article for an example.

So, a few weeks ago our professor on High Performance Computating challenged us to implement a Game of Life without if statements. The difficulty lies in all the special cases to take into account when you use a matrix data structure to represent the cells. The special cases are those cells that have less adjacent neighbours than the normal cells, like corners and cells in the borders of the matrix. Avoiding conditional branches inside large loops is usually a very good practice to improve the performance of your code, since a branch instruction is a very costly operation for the cpu.

The challenge itself wasn’t very difficult, so a few weeks ago when I was bored I decided to implement it using Qt 4 toolkit. It was also an excuse to try the new QtCreator IDE, which, by the way, I found amazing.

Let’s take a look at my solution:

void GameOfLifeWidget::setMatrices()
{
    m_lifeMatrix = new int*[ m_rows + 2 ];
    m_nextMatrix = new int*[ m_rows + 2 ];
    for( int i = 0; i < m_rows + 2; i++ )
    {
        m_lifeMatrix[i] = new int[ m_cols + 2 ];
        m_nextMatrix[i] = new int[ m_cols + 2 ];
        for( int j = 0; j < m_cols + 2; j++ )
        {
            m_lifeMatrix[ i ][ j ] = 0;
            m_nextMatrix[ i ][ j ] = 0;
        }
    }
}

void GameOfLifeWidget::iterate()
{
    int neighbours = 0;
    int **aux;
    int currCell;
    for( int i = 1; i < m_rows; i++ )
    {
        for( int j = 1; j < m_cols; j++ )
        {
            neighbours = m_lifeMatrix[ i - 1 ][ j - 1 ] + m_lifeMatrix[ i ][ j - 1] +
                         m_lifeMatrix[ i + 1 ][ j - 1 ] + m_lifeMatrix[ i - 1 ][ j ] +
                         m_lifeMatrix[ i + 1 ][ j ] + m_lifeMatrix[ i - 1 ][ j + 1 ] +
                         m_lifeMatrix[ i ] [ j + 1 ] + m_lifeMatrix[ i + 1 ][ j + 1 ];
            currCell = m_lifeMatrix[ i ][ j ];
            m_nextMatrix[ i ][ j ] = !( currCell == 1 && ( neighbours   3 ) ) &&
                                    ( currCell == 0 && neighbours == 3 );            

        }

    }
    aux = m_lifeMatrix;
    m_lifeMatrix = m_nextMatrix;
    m_nextMatrix = aux;
    update();
}

To avoid the special cases we can create a matrix with extra borders. We will never iterate over these borders, but they make the actual borders a common case with 8 adjacent neighbours just like every other cell.

The method iterate is called every 500 milliseconds and it calculates the matrix of cells  for the next iteration. It does so by looping through the matrix and counting the number of neighbours for every cell. Then it applies AND’s and OR’s operations that combine the 4 rules of the game to find out if the cell must live or die.

And now the mandatory snapshot:

Game of Life Snapshot

Game of Life Snapshot

You can also download the source code from here and, if you can make it compile, spend hours watching how life evolves.

Note: There is an issue with Qt re-painting the whole grid on every iteration which makes the cpu go high, I know why it happens but I haven’t had the time to fix it, but you can do whatever you want since it’s GPL ;)

Recurring Dreams

Posted May 21, 2009 by William
Categories: Real Life

Since I got to college I’ve started to have this recurrent dream where I have to go back to high school and retake a couple of subjects. It’s very embarrassing since I’m the oldest guy in class, everybody laugh at me and stuff like that.

Last night I had the dream again and it was very convincing. The funny part comes when in the dream I have this talk with a friend.

- Hey, do you remember that dream I told you about going back to high school?

- Yeah, I do, you’ve told it so  many times.

- Yeah, I know, But this time it came true!!! I told you it would happen someday.

GEB Recursive

GEB Recursive

It was such a relief when I woke up.

Still alive and some updates.

Posted November 3, 2008 by William
Categories: kde/amarok

It was some time since my last post. GSoC ended and then I had to take care of my real life for a while. But now I’m trying to get back and help Amarok developers by solving some easy bugs and polishing a little bit the context view.

Today I come with some nice stuff I’ve done recently. The first one is a nice user feedback by highlighting the context pages under the mouse in zoom out mode. Easy to implement and nice to have.

Context highlighting

Context highlighting

The other nice stuff is the current track showing the last tracks played when in stopped state.

Last played tracks

Last played tracks

It’s a little update but helps me to get back to work.


Follow

Get every new post delivered to your Inbox.