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.

GSoC weekly report – issue 11

Posted August 14, 2008 by William
Categories: kde/amarok

Tags: , , ,

Here I am again, this time from aKademy 2008 in Belgium. It is my first akademy and as an experience it was awesome. The best part was meeting the people behind the nicknames. The community is great and it’s huge. Over 300 people came to the event, what is overwhelming. I’ve learnt many things, talked to many experienced people who really knows what they are talking about.

The organization of the event was perfect, there were many interesting talks, it’s a shame I’ve had to miss some of them. The social event sponsored by Nokia and the boat trip today were really really awesome (free beer, free food, what else could you ask?).

The only bad thing was that it was not really very productive in terms of code but it was really helpful to meet some of the plasma guys who were really kind to me and helped me a lot.

What was also very cool was the n810 that Nokia gave to some of us (a lot of us). It has become the favorite toy arround akademy. It would be really nice to have amarok playing on one of those with an adapted UI for the touch screen. Maybe someday, who knows ? ;-)

As for the Summer of Code program, well, it’s coming to an end and I still have lots of things to do, what is making me feel a little bit worried. I’ll have keep coding after deadline (18th august) to go as further as I can.

No snapshots this week, sorry :P

GSoC weekly report – issue 10

Posted August 7, 2008 by William
Categories: kde/amarok

Tags: , ,

I can’t believe how fast time has passed these last weeks. Today  I come with fresh snapshots of the new toolbox menu I’ve been developing the last week. It still has some bugs but I can already show it to the public:

Toolbox menu

Toolbox menu

Toolbox

Toolbox

The menu appears after clicking in the plus icon in the toolbox. If you click in one of the entries of the menu it adds the applet to the current containment or, if the applet was already added, it takes you to the containment where the applet is. There isn’t the possibility of removing an applet from this menu but it’s something that I’m not sure that we want/need from this menu, I wanted to keep it simple so we will see what happens.

I’ve also changed the toolbox look a little bit, added some animations here and there and did some refactoring and a lot of changes in the code. Oh, and you may also have noticed that there has been a lot of visual changes in the application. This is because we have Nuno Pinheiro collaborating as an artist. Thanks to Pinheiro we now have our new own plasma theme as you may have noticed in the Context View. The current track applet doesn’t look so well now and we will probably need to redesign the applet to fit with the new theme.

In a few hours I’m taking a plane to Belgium to attend to aKademy. It will be a week of hacking that I hope will be very productive. See you soon.

GSoC weekly report issue 9

Posted August 1, 2008 by William
Categories: kde/amarok

Tags: ,

This week I can finally deliver and show what has kept me busy a long time (more than desired, as always).

I delayed the post publication a few days to have it a little bit more polished and to prepare markey’s birthday present. The present comes a little bit late but I know you’ll like it markey:

New ContextView toolbox and markey's birthday present

New ContextView toolbox and markey's birthday present

I hope you like. Sorry for the short post, more updates and snapshots after the weekend.

GSoC weekly report issues 7 and 8

Posted July 24, 2008 by William
Categories: kde/amarok

Tags: ,

Two weeks have passed since the last update mostly because I haven’t anything exciting to tell you.

Last week I did start implementing a new toolbox for the context view but many things got in the middle so I decided to dedicate time to fix pending issues. Some small issues, others not so small and in the end everything gets very complicated and I find myself dedicating a lot more time than I expected.

Everything might look somehow the same but it’s in the little differences that you can perceive some improvements. One thing you may notice now is that the context view status is saved on exit and restored back on start up with all the applets you had added. Also now the applets try to resize occupying all the available space in the context view area. We also have now the current track applet added on top of the first containment.

It’s a little bit late but I have finally everything set up so I can finally say:

Im going to aKademy

GSoC weekly report – issue 6

Posted July 10, 2008 by William
Categories: kde/amarok

Tags: ,

I come a little bit late since the last post because real life got in the middle.

This week we’ve got brand new zooming animations. Took me quite some time to figure out how to deal with Plasma animators but once you learn how to deal with it it’s quite simple. It was a little bit difficult to center the scene to the current containment while zooming in/out. The animation is set to 30 frames per second, it would look more smooth with higher fps but I wonder how it would behave on slow machines, so we still need some testing. I can’t show you this improvement since I still need to learn how to do screencasts.

And now, the long awaited new current track applet mandatory screenshots.

current track applet

current track applet new look

Now it’s possible to rate songs in the current track. As you can see it’s pretty much like the mockups we had except for the rating stars that I had some problems trying to set a custom one. But hey, the default looks good too. By the way, I’m using Nepomuk’s KRatingPainter and an adapted version to my needs of KRatingWidget. It’s a shame that I wasn’t on time to include the rating widget for the alpha release. Haven’t I told you? We’ve got an alpha release, please digg it.

This is it for now, I hope you like it.