My blog has been moved to ariya.ofilabs.com.

Saturday, December 27, 2008

graphics dojo in 2008: a wrap-up

If you show some friends an ancient trick to multiply two numbers in your head within seconds, typically you would either get a dismissal ("Fast? A calculator or Google is faster!") or an excitement ("How useful!"). Each response is justified. In our daily activities, we seldom face the situation that force us to only multiply two numbers and right at that moment you don't have a calculator (or Google) at your disposal. However, knowing such an art can help you to improve your overall math skill, cast away the unnecessary fear, build your passion for math, and makes you ready for the next level. As Louis Pasteur once expressed, "In the field of observation, chance favors the prepared mind".

The same goes for some of the graphics examples I have written for that Labs Graphics Dojo corner, and also what I have shown in my Developer Days talk. The most common comment is "Blazing-fast? Just use OpenGL!" That is very true, and I could not agree more. However, googling for 27*31, which gives the answer one second faster than my brain, will not make me fall in love with math. The concern of the talk was more about the tricks and the passion behind them. It could be only me, but I feel that developers start to lose passion for graphics, even though they have to deal with lots of user interface stuff. We are practical enough already, we know when to use Google or when to do it ourselves, but we can not afford to let the passion goes away. After all, Zack started it under the name Graphics Dojo not e.g. Graphics Oracle, as it is merely a training place rather than a collection of solutions.

Although it is implicitly stated, if I were Louis Pasteur, I would have gone further and said "chance favors the prepared and passionate mind".

That is, 2008 is coming to its end. Around mid 2008 Samuel and I agreed to resurrect our beloved Graphics Dojo corner. I hope our attempt did not fail (miserably), in particular since I was new to this wonderful world of graphics.

Squeezing a couple minutes here and there, making the best out of rainy weekends, firing vim to code during some sleepless nights (instead of browsing the web aimlessly), redirecting my passion to graphics between fixing WebKit bugs, here is a list of biweekly Dojo examples that I managed to pull off this half-year:

And while you are there, check out examples written by my fellow Trolls:

Happy New Year!

Sunday, December 21, 2008

oh, Clifford

"You could not live without quaternion, could you?", so was the impression of my advisor.

William Hamilton and William Clifford are my heroes. I fell in love with quaternion some time ago and used it with passion in my dissertation (check the summary). Those who had done extensive polarization analysis using matrix and quaternion would come to the usual conclusion: for this context, quaternion and polarization analysis is a marriage made in heaven.

Now I realize that few days left until 2008 is gone. This would mark my biggest failure for this year. Sadly, I fail (again) to learn Clifford algebra in depth.

Saturday, December 20, 2008

fragrances

I decided to ask her. "Sorry if I'm rude, but isn't your perfume Escada Moon Sparkle For Men?"

She smiled. "Yes, and it is wonderful. " She continued smiling. "I got it from a customer, I work in a bank."

"Ah, I see."

"Don't you also use Bruno Banani Pure Woman?", her turn now to ask me.

"Oh, yes I do. So I feel that my other half is always there."

One second passed. Then we shared a laugh.

Thursday, December 18, 2008

code less. create more. with Qt Creator.

Congratulations to the Qt Creator team for the Beta release! In case you live under the rock, Qt Creator is the new-IDE-on-the-block. It is now open source and it has just reached beta, so just download it (Windows, Mac, Linux) or learn more about it. For the braves, check also its shiny new open repository, start git cloning and hack on it!

Monday, December 15, 2008

genie in a bottle

Let us start with a screenshot:

For the code, the hack behind it, and a screencast/video, check out my Qt Labs blog entry.

Saturday, December 13, 2008

every day a false start and it burns my heart

This week in Oslo we have visitors, as evidenced from this picture:


(Zoltan, Holger, Simon, another Zoltan, Enrico, Tor Arne, Ariya).

Basically we are doing a QtWebKit hackfest. Beside the usual three musketeers of us (Guardians of QtWebKit here in Oslo), we have also two Zoltans and Akos (not in the picture) coming from University of Szeged, as well as Holger (WebKit open-source developer) and Enrico (Italian ueber-hacker).

We managed to nail down a lots of stuff, among other the discussion about development workflow using git, a heavy round of final API review, brainstorming on the DOM API, ACID3 patches merge and some font handlings, lots of bug fixes and touches such as fix for annoying focus problem, cursor flashing, proper non SVG build, multiple file chooser support, state save and restore signals, native plugins instance lifetime, file extension for images, autogenerated inspector qrc, fix for Enter does not work, missing plugin icon, and many other stuff, including non-technical ones.

It is a fun hackfest and we certainly need to do this more often :-)

Monday, December 08, 2008

knocked out

The beauty of taking a trip from/to South East Asia is simply its ridiculous journey. In the last 72 hours, I have been in 6 different airports, gone through 7 hours timeshifting, trapped 3 times in inhuman traffic jams, exposed to 40 Kelvin temperature drop, and of course enjoyed only sporadic in-flight sleeps and food.

For my aging, weak body, it hardly comes as a surprise that I am K.O.

Tuesday, November 18, 2008

scrolling through the paragraphs, clicking through the photographs

I heard that seven is a magic number. I am seeing the seventh winter in my life. How magical.

For roughly 300 weeks I stay in Europe already. And I will still be here for some time to come. But after reaching some of my goals, missing many others, I decided I will pay my home country a visit.

Bracing for the impact of reverse culture shock.

Sunday, November 16, 2008

the sky will be my shroud, a monument of cloud

Things are still exciting as ever. In two weeks, I will be in Bali. Yes, I will be there for the Workshop on Open Source and Open Content (WOSOC) that is held in conjuction with IEEE Conference on Signal-Image Technology and Internet-based Systems.

Check out the full schedule, find the invited talk: Qt for Rapid Mobile Application Development, and enjoy some demos that I will premiere there. Update: the talk is actually one of the keynotes.

So, if you are around and want to have a snack or a chat, just let me know! Mail me at ariya.hidayat@gmail.com.

everything is better when you hear that shout

In Oslo? Don't miss Mithas The Sweethouse (Grønland 2A Oslo)!

sweets

Photo by this girl.

Saturday, November 15, 2008

Flickify!

As Harry entered the room, he saw Ron hopelessly fighting with his magic tablet. Ron was desperately trying to look for something using the tablet. Harry pulled his wand and then "Flickify!"

The Qt Everywhere mantra means that Qt will be available in more and more platform, including of course mobile devices. For example, the recently announced Qt S60 means that 80 million devices can become the target market for Qt application developers.

In another front, touch screen seems to be the future direction. Nokia 5800 XpressMusic (better known as Tube) starts the new generation of S60 devices with touch screen. As introduced by Apple on iPhone, navigating a long list in a device with touch screen is best done using flickable list. The scrolling effect is also often known as kinetic scrolling.

Though up to now Qt does not offer an official mean to flick-enable your list, apparently it can be done without too much effort. Heck, you do not even need to modify your code. Flick Charm, my latest graphics example exactly demonstrates the idea. The trick is to use an event filter to hijack the mouse events and then to scroll the widget properly. This simple charm apparently works on any QAbstractScrollArea subclasses, including all the ItemViews and of course QGraphicsView as well as QWebView. Check out the following screencast for the proof:

(Screencast is also available for direct watch at blip.tv or YouTube).

Friday, November 14, 2008

Scrolling QWebFrame programmatically

Here is a challenge: how to scroll QWebFrame programmatically, if the scroll bars are invisible? At first you might think: Aha, let us just set the value of the scroll bars! The idea looks great, however it does not work that way (since QWebView is not a scroll area). Though you can change the value of the scroll bars, they are not reflected in a scrolled view. Because the need for this, in Qt 4.5 there will be functions to get and set the scroll offset, regardless whether the scroll bars are hidden or visible. But then, what about the customers for Qt 4.4?

JavaScript to the rescue. Using the rather infamous hook QWebFrame::evaluateJavaScript, doing the task is rather trivial:

QWebFrame *frame = page()->mainFrame();
frame->evaluateJavaScript(QString("window.scrollTo(%1,%2);").arg(x).arg(y));

For a more complete example, see what I show in our graphics corner lately: WebView and panning support.

Thursday, November 13, 2008

Tinting through composition

Another example that I showed in Developer Days was an alternative way to tint an image. Suppose you want to have a little feedback to the user when s/he puts the mouse on an icon, what you can do is to colorize the icon while the cursor is still on top of it. Changing the overall tone of the color of an image can be done in different ways. One obvious way is to convert every pixels from RGB to HSV, perform some manipulations on the hue and perhaps also saturation, then convert back the result to RGB, which will be the final color of those pixels. A rather different and less correct approach (though the result is still visually good) is to convert the image to grayscale and then overdraw a big rectangle with certain composition modes, check out my latest entry on Qt Labs Blogs exactly on that matter: Colorize an image via painter composition.

The included example can also take an image from the web, e.g. drag and drop from Flickr. In case you want to know the trick and/or look for a simple example of QNetworkAccessManager, then follow the simpler code for image viewer with support for remote URL.

Wednesday, November 12, 2008

Gmail video chat

It does not work on Linux (yet), but this video and voice chat right inside Google Mail will be definitely a killer!

Tuesday, November 04, 2008

visual google

Remember the tradition that I started in Redwood City? Well, the parallax sliding demo was for the graphics talk. For my QtWebKit presentation, the challenge was different. Basically it boils down to a visual version of Google Search. Instead only getting the hits and some text snippet, you should also get the web snapshot of the hits. There are apparently browser extensions out there which implement this kind of functionality.

Before going further, let us see first how we can get a preview of any web page. With QtWebKit, it is as easy as creating a QWebPage and using it to render the content to a painter that operates on an image. Check out websnap example, if you think this is not easy enough. Running websnap to several popular web sites gives the following:

Coming back to visual search. So while rehearsing my talk in the night before, I created the search and snap demo. What is presented as the next dojo example is however a slightly better version (afterall, I have more than just one night to polish it), as I added some text snippet to make it more attractive. The result is as follows, the code can be checkout from the usual graphics corner. As you can see, a third of the code is just reusing the WebSnap class.

A screencast is worth a thousand screenshots. Thus, for your pleasure, check the following 1-minute video, too. Or view it on blip.tv (high quality), YouTube (low quality, more bandwidth-friendly), or download the Ogg Theora file (3.3 MB).

So who is going to turn it into a plasmoid?

world fastest optical polarization tracking

Once a while, somebody asked me about my dissertation. Since I am working in software industry these days, it is a bit awkward to mention my previous physics and electrical-engineering related work. Now the job becomes easier. I can point those curious guys to the following paper:

High-speed endless optical polarization stabilization using calibrated waveplates
and field-programmable gate array-based digital controller

This 8-page text is basically a condensed version of my dissertation, the 2.5 MB PDF file is available for download (free). It would appear in the upcoming Vol. 16, Issue 23 of Optics Express, one of the leading peer-reviewed journal in optics (impact factor last year: 3.709).

In a nutshell, the paper consists of two parts: optical retarder characterization and implementation of FPGA-based controller. The first part deals with modelling and estimation of characteristics of off-the-shelf lithium-niobate polarization transformers, then the characterization result is used to calibrate the respective retarders. It uses a new approach based on quaternion analysis. Learning quaternion is a life-changing experience for me, and it seems natural to use it in this context. Unfortunately, as a footnote in my dissertation says "Although, rather surprisingly, quaternion is hardly employed in literature on polarization analysis".

The second part is a bit about the controller itself. It comprises an FPGA, some peripherals, and few optical components. The implementation employs a lot of tricks that were imaginable at that time so that the controller can run as fast as possible (control iteration time of 2 us) and in limited resources available on Xilinx Spartan 3. It was a hard task for the few of us. Finally we pulled it off and made it work reliably in a series of experiments. To date, the 15 krad/s stabilization experiment that is reported in that paper is still the fastest endless optical polarization tracking ever recorded on this planet.

Even these days, I often ask myself, what was in my mind when I decided to pick up this challenge back then?

Monday, November 03, 2008

Android-like parallax sliding

At Redwood City Qt Developer Days (also where, BTW, a bunch of KDE geeks made a funny group photo), I started a tradition: throw an idea for a demo and I will implement it for the talk. The challenge for my graphics talk was the subtle effect in the Android's home screen. We saw T-Mobile G1 the night before and recalled again the good old games in the eighties. So the next morning I waked up earlier both to rehearse my talk (again) and to implement this parallax sliding. It turned out to be almost trivial to implement (200 lines of code) so just check it out!

For the lazy, do enjoy the screen capture below, or see also the screencast on YouTube or blip.tv or just grab the Ogg Theora video (4.2 MB).

Happy parallaxing!

Summer of Code 2008 Mentor Summit

Squeezing the time between the busy schedule, with other three Trolls (Simon, Thiago, Olivier), I attended the Google Summer of Code 2008 Mentor Summit at Googleplex in Mountain View. On the KDE side, we also met Jason and Leo. On the second day, the mentors and the organizers had two group pictures, one in the staircase and one in front of the big Android statue. The six of us from KDE also took a nice picture with the Android background.

My general impression of the summit: it was awesome! The venue was great, the talks were interesting, the food was nice, the snacks were abundant, and of course the opportunity to try out Toto E200 - the infamous 14-button toilet - was priceless. Surely the organizers did a very good job!

What is also great from Mentor Summit is the chance to meet great people. Since at Qt Software we switched from Perforce to Git, it was nice to be able to talk and discuss matters with Shawn Pearce. He happens to work on Google Android these days, unsurprisingly Android project is of course using git. Still related to Android, there were two talks about it: the story behind and the application development. Also of a great interest is Gerrit, the Python-based code review tool used Android development. According to Shawn, Gerrit is an improved fork of Rietveld, a similar tool written by Guido von Rossum. The mystery of both names is solved if you check out this Dutch architect.

I myself was so glad to be able to have a short chat with one of my personal legends, Sam Lantinga, the man behind the fantastic libsdl. He works for Blizzard and likely you know the game he is working on, as it is called World of Warcraft. As for libsdl itself, the new adventure is SDL for iPhone (which is one of its SoC projects). When finally it is released, I can't wait to see how many SDL-based games will be then available on iPhone. Plus, if you write an SDL-based application, now you have an interesting fast-growing target market as well.

I also followed a discussion from the 12-year old Dmitri Gaskin. He is the youngest mentor, he is actually too young to participate as a student (the age cut-off is 18). If you are a fan of Google Tech Talks, surely you are aware of his jQuery talk. So we discussed about JavaScript unit test, it involved a lot of coding from his side. I am not a jQuery expert so I just gave my opinions based on my little knowledge on the JavaScript engine in WebKit. I am eager to see how the unit test framework would evolve.

At the end of the summit, many of us were exhausted. But of course, we look forward to having the next-year mentor summit!

Android meets KDE guys


Sunday, November 02, 2008

I chose this mortal life

I wonder if this juice is available somewhere in Oslo, or even Norway, or even Scandinavia, or even mainland Europe...

Saturday, October 18, 2008

lamb pizza

By popular demand, here is a quick and easy recipe to make a home-made, fresh, delicious lamb pizza. For faithful Planet KDE readers who are sick of my occasional food ramblings, please skip this one (again).

lamb pizza

A little story about this pizza. Signor Portale (better known as Alessandro), our beloved Italian-German Troll who was in Oslo for a visit, once wisely described the typical pizza sold in the common pizzeria as a bread with homeopathic tomato sauce, simply because the crust is so thick (like a bread) and is not even covered properly by those few accidental tiny drops of the tomato sauce. And let us not even talk about the toppings, usually so thin it is more a bread spread then the well-deserved pizza toppings. Hence, the subsequent real-pizza-making sessions with him. BTW, the result of the following recipe has been surely tested by some Trolls, including Signor Portale himself. As a matter of fact, only from him I could complete my amateurish skill by having to learn the magical charms of love and passion, the two most important cooking ingredients ever!

Ingredients

For the dough:
400 gr all-purpose flour
1 small-pack of yeast
300 ml warm water
a few drops of olive oil
a pinch of salt

For the meat:
500 gr minced lamb
1 tbsp garam masala
1/4 tbsp curry powder
few drops of vinegar
1 tbsp lime juice
2 tbsp olive oil
1 large onion
2 shallots
3 cloves of garlic
2 well-beaten eggs
4 tbsp sweet soy sauce
4 stems lemon grass
10cm piece ginger
2 tbsp tomato ketchup
4 basil leaves
1 coriander leave
40gr dried or chopped parsley
salt and black pepper to taste
chili pepper (optional)

For the toppings:
200 ml tomato sauce
1 medium aubergine
400 gr ripe tomatoes
1 bunch basil
200 gr corn kernels
a handful of oregano
some pizza cheese
200 gr fresh rocket leaves

It always start with the cooperation between human and microorganisms. Mix the yeast with warm water. Then mix with the flour and some salt and form a dough. Occasionally drop the olive oil. Set it aside, e.g. for one hour, in a warm place until it doubles its size. For the lazy (who isn't?), just place the dough in a warm (but not too hot) oven and after few minutes, pull it when it already grows.

To prepare the meat, sprinkle a generous amount of salt and pepper to the minced meat. Mix garam masala and curry powder, pour in the vinegar and lime juice and then set aside the meat for 1-2 hours. Crush the garlic and chop the onion and shallots, sautee them with olive oil. Mix the eggs as if you would make a scrambled egg. Then finally put the meat. Next are sweet (not salty) soy sauce, tomato ketchup, sliced basil and coriander leaves, bruised lemon grass, ginger cubes. Continue to cook everything with a low heat for one more hour. If necessary, pour in a glass of water and let the water vapors slowly with the heat. You know you are successful when it does not have the typical often-annoying smell (of lamb meat) anymore. Add chopped chili pepper if you like it hot and spicy. Taste and correct seasoning.

For the toppings, first of all you need around a glass of thick tomato sauce. If you're lazy or in a hurry, use a ready-made one. Otherwise make it yourself: peel fresh tomatoes, chop them in a food processor, mix the result with sauteed onion and garlic with olive oil, blend some basil, chopped spring onion, and of course salt and pepper to taste. Give another few seconds in the food processor. While waiting for the sauce to blend its taste, slice the aubergine, rub each piece with a drop of olive oil, spray some salt and then bake it (e.g. 5 minutes at 200 C) until it softens.

Now knead the dough. Roll the dough into a pizza base. My preference is usually a very thin one (after all, we're making a pizza here, not a bread) but some favor to have a thicker crust on the side. Lay the base on a baking sheet, then spread the tomato sauce and sliced fresh tomatoes as well. After that, add chopped basil, already-prepared-and-well-cooked minced lamb, oregano, baked aubergine slices, corn kernels, and the cheese. As with any other pizza, you are of course free to experiment with your own favorite toppings. For example, olive halves, fine-sliced tuna, pepperoni, sliced onion, mushrooms, preboiled shrimps, or cubes of tofu could be a very nice extra. Never hesitate to build your pizza vertically!

Bake your pizza, say at 250 C for 10 minutes. It really depends on your oven, so check it every now and then quickly pull the pizza when the cheese completely melts and the crust looks ready. Serve with few rocket leaves (in some places, better know as rucola) and you are done!

Legal notice: You are free to copy, alter, and/or distribute the verbatim or modified copies of this recipe. In fact, do whatever you like with it. This recipe is also provided without any expressed or implied warranties, including if your pizza is burnt or you experience any other casualties.

Credit: the gorgeous picture is thanks to this girl and her Sony Alpha.

bye, Munich. see you in US!

I am back in Oslo for a short rest before flying again to US. Of course, I am still having symptoms of sleep deprivation, in the last 5 days in Munich I managed to accumulate only 19 hours of sleep. Though the schedule was tight, I could squeeze few hours of sight-seeing, among others to visit Castle Neuschwanstein and Viktualienmarkt.

At least in my opinion, Qt Developer Days 2008 in Munich was a success. Our fellow Trolls who organized this event did a great job. We announced a fresh Qt IDE called Greenhouse and also the first Pimp My Widgets contest (the pimp himself was there on-stage), ate a piece of the 5-years DevDays cake, had a wonderful dinner with the partners and customers, and of course enjoyed a lot of talks and discussions with them as well.

I was quite content with my technical talks: QtWebKit: Present and Future and Beautiful and Blazing-Fast Graphics with Qt. The room was jam-packed for both of them. Lots of questions in the QA session, even more after the talks.

In about 10 days I will be in Redwood City for US Qt Developer Days 2008. Looks like I will be in around in San Francisco even from the weekend before. In addition, next week I will be in Boston for another business trip. Thus, if you are around and want to have a snack or a chat, just mail me at ariya.hidayat@gmail.com!

Friday, October 17, 2008

message from the pumpkins

Don't skip Viktualienmarkt, a 200-years-old food market in a square in Munich downtown (Viktualien apparently means food, or rather Lebensmittel in German). In those hundreds of stalls, you can find a lot of things, from fresh organic vegetables (and pumpkins, see above) to a wide selection of ready-to-eat seafood.

Tuesday, October 14, 2008

Pimp My Widgets

You think you are good? Why don't you try to win a Segway or some N810. Head straight to:

http://trolltech.com/pimpmywidgets!

Update: our pimp announced the contest right after dinner here at DevDays 2008:

Monday, October 13, 2008

through my fingers into cold sunlight

Castle Neuschwanstein

"The view from up above is enchanting, especially the view from the Marienbrücke of the castle,..."

-- King Ludwig II

Castle Neuschwanstein from Marienbrücke

the map of my world gets smaller as I sit here

Last weekend, when the weather was just about perfect, there was "Norwegian food in the streets" (official website is www.matstreif.no). It comprised quite a number of stalls that sell (and offer you to sample) products such as honey, fresh organic vegetables, crabs, organic salmon and many others.

Sunday, October 12, 2008

magnificent skyline out of my reach

As I mentioned before, few hours more until Qt Developer Days 2008 at Hilton Munich Park. Feel free to contact me at ariya.hidayat@gmail.com if you are around!

/me is getting ready for the flight.

Tuesday, October 07, 2008

I fashioned you from jewels and stone

These days, here at Qt Software (nee Trolltech) we are as busy as working bees. Not only due to a point release, but also because the exciting, upcoming Qt 4.5 is in the horizon. Some of us have blogged about its new features, such as Cocoa support and Qt Falcon. As part of the QtWebKit team, we integrated a fresh version of QtWebKit into 4.5, which you might notice already when you monitor our snapshots. In the past few months, we wrote a bit about QtWebKit development, but hopefully we can still present an overall summary once time permits.

From my side, I just completed the first 6-month period in Trolltech. Things are exciting as ever. In one week, I will be in Munich. In three weeks, Redwood City is the next stop. Yes, I will be there for the Qt Developer Days 2008. I'd have two talks in the technical tracks: QtWebKit: Present and Future and Beautiful and Blazing-Fast Graphics with Qt. See the abstracts for details. Actually, just skip the abstracts and enjoy some demos that I will premiere there.

So, if you are around and want to have a snack or a chat, just let me know!

Saturday, October 04, 2008

waiting for a revelation, for someone to count me in

Just welcoming the autumn equinox, several things happened in Oslo. Some worth noticing were river walk by torchlight along Akerselva, the 8 km river in Oslo, Culture Night with its closing fireworks, and of course Oslo Marathon right at Aker Brygge.

fireworks

fireworks

Also, check out the photo sets for torches and fireworks.

(Credit: photos are taken by this girl)

Wednesday, September 24, 2008

fresh waffle

waffles

By popular request, here is a quick and easy recipe for making waffles. It is so easy, it would never fail.

Ingredients:
2 whole eggs, beaten
300 gr all-purpose flour
160 gr butter
140 gr sugar
1 teaspoon baking powder
100 ml milk
vanilla, to taste

Of course, you also need a waffle iron.

(Photo is taken by this girl)

Monday, September 22, 2008

on passion and reason

If passion drives you, let reason hold the reins.

-- Benjamin Franklin

Autumn in Paderborn

Tuesday, September 16, 2008

on CrossOver Chromium (a way for Chrome on Linux)

CrossOver Chromium is a nice and easy approach to run the famous Google Chrome browser under Linux (while waiting for the official Linux version and if you don't want to mess around with Wine). I tried it on my OpenSUSE machine, it works pretty well. There are minor glitches, like maximized window could not be restored anymore (because Chrome skips normal window management), a status bar that does not appear and disappear properly, the omnibox rendering problem, and similar other small annoyances. But all in all, for 11 days of work, it is an amazing achievement.

Checking its JavaScript performance using SunSpider, it is only up to 40% slower. However, it still feels smooth and fast. Definitely worth a try.

Saturday, September 13, 2008

curiosity kills the cat

The unverified reason Irn-Bru is not available in Germany is because the ingredients label and so on are only English, not in German. Usually this is remedied by sticking another label in whatever language it should be. No idea why it doesn't work out.

Apparently, this famous Scottish soda is available in Norway.

Sunday, September 07, 2008

on karma (in this zen-like moment...)

How people treat you is their karma; how you react is yours.

-- Wayne Dyer

Berry

Friday, August 29, 2008

sushi (again)

Still in the same Sushi Factory. As usual, the fried prawn rolls quickly become my all-time favorites.

Sunday, August 24, 2008

Mela Festival, Oslo

There is Mela Festival this weekend in Oslo. Lots of food, dance, music, fashion, stalls, as well as some interesting children activities. Too good to miss!

selling chicken tikka

Elephant at the Mela Festival, Oslo

(see some more pictures)

Saturday, August 23, 2008

Qt 4.4 and Maemo

After playing a while with Qt 4.4 on my N800 (will be the same for N810), the impression of "slow" (like latest Adam's latest post) is something that I predicted will soon come out. So far, my very brief investigation reveals that the cause for this is both simple and sad: the Maemo's X is running 16-bit visual (N8xx's display is Highcolor only, not Truecolor). Thus, if you do something fancy with 32-bit stuff, like running a QPainter on a Format_ARGB32 or Format_ARGB32_Premultiplied QImage, then basically you force a 32-to-16 conversion every time you blit the image.

Take a look at PictureFlow, the infamous clone of Cover Flow. You can just checkout it, run qmake and make as usual and start to have some fun (all inside Scratchbox, and after that transfer it to the N8xx).

Surprisingly, it runs horribly slow, probably less than 5 fps. Consider than PictureFlow does its magic by straight pixel manipulation and then just blit the result, this looks really weird. However, it was found out that Qt needs to perform the conversion from 32-bit image to 16-bit pixmap for every single frame, hence the terrible slow down. In short, there is more CPU power wasted for the blitting vs for the rendering. Check your callgrind output to confirm this.

Good news: this is something that can be fixed (both in the application level and probably inside Qt). Personally this one is my favorite aim for Qt 4.5. Once we start to see ported Qt apps for Maemo, we can't afford to allow a potential performance penalty like this, it would just give a wrong impression of Qt. Don't you agree?

Sidenote: 16-bit can be useful because (on a non-accelerated graphics system), you can perform faster full-screen update (less transferred bytes). 32-bit is however easier to handle because each color component lives in a separate byte.

Sunday, August 17, 2008

Yes, honey (or the beauty of double meaning)

A sunny morning in a small coffee shop.

"Hi!"
"Hi!"
"I'd like one chai latte, please".
"OK."

The girl went on to prepare the order. After a while,

"Do you want honey or sugar?"
"Yes."
"Yes what?"
"Yes, honey."

One second passed. Then we shared a laugh.

(Just like in a [HB]ollywood movie)

dirgahayu

August 17th is Indonesia's independence day. Merdeka!

Wednesday, August 06, 2008

svg-to-png using (Qt)WebKit

Related to the recent discussion on some problems of Qt SVG renderer when drawing the Oxygen icons, I decided to sit down and wrote an example of yet-another SVG renderer by using QtWebKit (available since Qt 4.4.0). Check out the code if you're interested, it is part of the Graphics Dojo examples.

The major difference between this WebKit-based tool compared to QSvgRenderer is that it should handle SVG features which are supported by WebKit. Note that QtSvg limits itself only to SVG Tiny 1.2 without DOM API and scripting (due to various reasons). On the other hand, SVG support in WebKit will be improved over the time. Yes, fancy stuff like filter effects are not fully implemented yet (at least, in QtWebKit), but we are working towards that.

For those who can't wait for the DOM API in QtWebKit, you can see the example of poor man's way of doing it, i.e. by (ab)using evaluateJavaScript() of a web frame. Here it is used to get the SVG width and height attributes. As a hint, if you are unsure about the DOM tree, its elements and/or their attributes, then open the SVG in e.g. Arora or the Demo Browser and use the Web Inspector to check it. The JS console is also helpful to try out various thing right when you view the SVG.

Obligatory screenshot follows:

Result of WebKit-based SVG rasterizer

And while you are there, check out also other fresh dojo examples: zooming text and old-school radial blur.

Saturday, August 02, 2008

quattro quattro uno

In case you live under the rock and miss Thiago's latest blog post, Qt 4.4.1 was just released. This is just a few days after KDE 4.1 was announced and close to three months after Qt 4.4.0 was out.

This patch release adds tons of bug fixes to the 4.4.0 release. For the WebKit team inside Trolltech Nokia's Qt Software Unit (by team here it means a group of developers you can count with one of your hand, and still not everyone works full-time on WebKit), beside the usual feature development (like Phonon-based media and Netscape plugin support), we did spend a lot of time fixing important bugs, as evidenced from the 4.4.1 changes.

On to Qt 4.4.2 and KDE 4.2. The latter would be ten percent of the ultimate answer to life, the universe, and everything...

Friday, August 01, 2008

seas would rise when I gave the words

In the context of improving the user experience (read: wasting more CPU cycles), I couldn't resist to add a bunch of random and experimental improvements to the experimental feature of live preview in Arora.

First of all, I gave up the idea of having a top-level widget, like a QToolTip's label, to display the preview and this would already wipe half of the annoyances that might show up. Bonus, this makes it easy to have a non-rectangular, translucent tab preview without the need to rely on composite support. Look at the shot below:

The callout shape, along with its subtle shadow, is very easy to do with QPolygon. Readers with sharp eyes might notice that the preview is not opaque, you can set the opacity as you like. In addition to that, a simple #define will make the tab preview to use OpenGL for scaling. This is obviously faster on graphics cards with proper, non-buggy accelerated drivers.

So far everything is done with only around 250 lines of code. I suggest you to give it a try (check out the live-preview branch). Be careful, as this live preview feature is very addictive! Opera and Firefox-with-Tab-Scope-extension users know for sure what I mean.

Another thing that I'm still undecided is a simple and subtle animation. With QTimeLine, again it would be quite easy. I have another 20-second screencast (watch on YouTube or blip.tv or get the 1.4 MB Ogg Theora video) that demonstrates this:

Maybe this should be disabled by default. Here I would also like to mention that right now there is no plan from my side to push this to upstream. In plain English: you won't see this feature in any official release of Arora in the near future. When, at a certain point in the future, I feel confident enough with this feature, then thing might change. But right now, if you want to try it, just pull my branch and compile it.

And yeah, I watched The Dark Knight the other day and it's simply magnificent!

Wednesday, July 30, 2008

Be my mirror, my sword and shield

The real blog title should be: experimental live tab (thumbnail) preview in Arora.

The nice thing about hacking on WebKit is, whenever you feel you want to experiment with some whacky web browser features, you can just go ahead and implement it. The code base is clean and easy to understand. For example, I always wonder how difficult it is to have a tab thumbnail preview like in Opera, where you hover the cursor on a tab and it displays the preview of the web page in that tab. This makes it easy for you to work with dozens of tabs (I know someone in Trolltech who opens at least 30 tabs in a browser :-), because often you can have a glance of the tab before really switch to that tab.

Today [1] I decided to give it a try, of course with QtWebKit. The victim is Arora, the famous lightweight QtWebKit-based web browser. Giving it a thought, there are surely million ways to do it, from QPainter redirection, grabWidget() abuse, Widgets-on-Canvas with GraphicsView, scaled painting even to a GLWidget, you name it. As a starting point, I picked the simplest one [2]: ask the web view to render to a pixmap and scale the pixmap. After an hour or so, I got to put Arora on par with Opera, in terms of tab thumbnail preview [3].

However, the fun just starts now. Remember video with CSS reflection and HTML 5 video support? If you open a tab and plays a video there, then you switch to another tab, then hover the cursor on the previous tab, you can see that the preview is live! [4] The video even plays in that tiny little window.

Since it is impossible to show this live preview feature in a completely static screenshot, I made a 133-second screencast and put it on YouTube. See the video or watch it here:

As you can see, basically I opened three tabs: Google (0:04), a web page that plays Transformer trailer video (0:09), and another page that plays the same trailer but with added reflection effect (0:24). Then I switched back to the Google page (0:34) and placed the mouse cursor on the trailer tab (0:38). There you can see the minified trailer running nicely. Whacky? You bet :-)

There is a big room for improvement, though. For starter, I just did a hack and repainted the preview at 10 fps even though nothing has been changed in the web page (e.g. the page contains no video or animation). This needs to be optimized, say by finding out a way to update only when it is absolutely necessary. Also, the preview scaling could be better, maybe using a QGLWidget for the preview viewport so the graphics card does the scaling for use. Once real full-page zoom is landed for QtWebKit, it is also interesting to explore it for painting the preview. I'm open for more ideas, especially tricks that can push the performance.

[1] After few days only focusing on bug fixing and other usual stuff. Yes, even QtWebKit in Qt 4.4.2 will receive some love and a bunch of bug fixes.
[2] The method of course can be improved later on.
[3] The code can be found in my cloned Arora repository, under the live-preview branch.
[4] Quite a coincidence, but the radio just plays I used to roll the dice, ..... But I reckon you assume that already.

Wednesday, July 16, 2008

vim: lightning fast navigation in a large software project

Love vim but need to work with a large software project that spans a dozen subdirectories and a bazillion source files? There are plenty of solutions, vim scripts or external tools, for this particular problem. Here is one that I've used for years: using the marvelous project script.

It comprises one .vim file (the script) and .txt file (the documentation), thus dead easy to install. After that, just launch vim using: vim +Project (replace vim with gvim if you favor the GUI version), the side pane will be visible. There is where the project tree will be displayed.

For a quick start, type \C and you will be prompted to answer 4 questions, as the example below (my answers are in bold)

Enter the Name of the Entry: KOffice
Enter the Absolute Directory to Load:/home/ariya/koffice/source
Enter the CD parameter:
Enter the File Filter: *.cpp *.h *.c

which, as you might guess, create an entry with the given name from all C/C++ headers and sources from the specified directory. Wait a few seconds (or minutes, depending on the project size) for the script to scan files in your disk, at last it will show the tree (as in the screenshot above) in the project window.

You can, of course, add as many entries as you want.

Note: for optimal usage, do not forget to put this on your .vimrc file:

:let g:proj_flags="imstvcg"

For details on the meaning, see the script documentation.

Navigating the project tree is easy, if you are familiar with the vim folding. In principle, use zo and zc to open and close the fold right where the cursor is located, or zO and zC to apply it recursively, i.e. for the whole entry.

How to open a file? Just place a cursor in a file name and press Enter. Since the project window is just a normal window, switching back and forth between the project window and main editing window is as easy as Ctrl+W w. Or you can use F12 to quickly show and hide the project pane. In addition, pressing Space toggle the wide and small version of project pane.

Some more tricks. Because the project window is just a normal vim window, use the blazing fast incremental search (along with n or N) to spot the file that you want. It even does allow you to jump between different matches quickly. Again, if the project window is too narrow, hit Space to make it wider and another Space will return the width back to normal. If you press Enter on a filename to open it, a wide project window is toggled to the usual width automagically. Master this technique and you will open any file you need in an instant.

Because I love tabbed editing, I also have this in my .vimrc:

:map <C-T> <Esc>:tabnew<CR>

so that Ctrl+T opens a new empty tab. Wherever I am, I can open KSpread's Cell.cpp (to have a quick look, hence in a new tab) as fast as hitting Ctrl+T, F12, /Cell.cpp, Enter. Try to beat that.

But that is not all. You might ask: what's the use of a big file list if I don't know which file I need to open? Right, because everyone (and his dog) just needs grep. Use \G (which will use vimgrep) and type in your search string. After a while, all the matches are listed in another small window. Choose one that you want and hit Enter, all the magic ensures that the corresponding file will be opened and the cursor is right located in the matched line.

For more features, e.g. rescan the files from disk, adjust the pane width, execute a command on a file, non-global project tree, etc., refer to the script documentation.

Untap the potential of this wonderful vim script and a 3000-files project is not a burden anymore!

Sunday, July 13, 2008

from SDL to Qt: the underwater effect

Doing a real underwater after effect would involve creating a believable water caustics plus some vertex shader incantations, both are far away from my expertise and it would even have taken more than an hour I would like to spend on the rainy Sunday morning preparing an example for this week's Graphics Dojo corner. Instead, I just cheated and ported my previous SDL version of Quake-like underwater effect to use QImage, and that became the example. Since this is an animation effect, the still photo below could not really depict the idea. So, just grab the code, build it, drag-and-drop your favorite photo and stare at the result for few seconds.

Qt for doing underwater effect

Lucky to have been where I have been

Bakso (Indonesian meatballs)

This is Indonesian-style meatballs (but made from lamb instead of beef) served with noodles, soy sauce, chilli sauce and fried onions. It involved mixing mashed lamb with tapioca flour, egg white, garlic, salt, pepper, other herbs to taste and then boiling in hot water.

Saturday, July 05, 2008

dojo this week: HSV pie

Update: Fabian Jakobs has ported the Qt/C++ code to HTML Canvas and JavaScript, runnable inside a web browser.

I was having headache fiddling with some fragment programs when Helder (of SpeedCrunch fame) asked me an innocent question that eventually triggered me to write the Graphics Dojo example for this week: rendering the well-known HSV cylinder in 3-D. At first, I thought using a fragment program is the perfect solution, but considering that we are Trolls, let us write a pure Qt solution that works everywhere. So check out the code!

HSV Pie

Unfortunately, in its current state, the code is not really optimized for (near) real-time rendering. If it would have been fast enough (which I guess not really feasible with a non-OpenGL solution), we could have used it for a fancy color picker. Why use a 2-D color picker/dialog when you can have a 3-D one? I'm sure once the 3-D version is introduced, the 2-D version quickly becomes confusing for any creature on this planet.

The question now: shall I do the HSL sphere?

Wednesday, July 02, 2008

Converting between HSL and HSV

Amazingly, tons of code fragments on how to convert between RGB and HSV as well as between RGB and HSL do exist (in any imagineable programming languages). However, googling for HSL to HSV conversion did not reveal anything useful. Maybe I was blind, but there is really no point wasting minutes for something that (should be trivial). A quick glance at the wikipedia article on HSL and HSV gave me the following code:

 1 void hsv_to_hsl(double h, double s, double v,
 2 double* hh, double* ss, double *ll)
 3 {
 4     *hh = h;
 5     *ll = (2 - s) * v;
 6     *ss = s * v;
 7     *ss /= (*ll <= 1) ? (*ll) : 2 - (*ll);
 8     *ll /= 2;
 9 }
10
11 void hsl_to_hsv(double hh, double ss, double ll,
12 double* h, double* s, double *v)
13 {
14     *h = hh;
15     ll *= 2;
16     ss *= (ll <= 1) ? ll : 2 - ll;
17     *v = (ll + ss) / 2;
18     *s = (2 * ss) / (ll + ss);
19 }

Error checking is left as an exercise to the reader, corrections are welcomed. If the code seems to be cryptic, then there is a reason to take a napkin and jot some stuff there...

Sunday, June 29, 2008

return of the graphics dojo: OpenGL-accelerated widgets and Bloom effect

After almost a year without any sign of life, Samuel and I decide that we should resurrect the Graphics Dojo, i.e. by populating it with some new fresh examples.

Being a graphics ninja, Samuel's first example is on how to (finally) put widgets on OpenGL viewport. This is now made possible thanks to Qt 4.4's new feature of adding widgets to the graphics scene. Check out his example code, it looks awesome and you can play with it for hours!

Qt widgets and OpenGL

Since I'm new to all this magical graphics world, my first example is however fairly simple: Bloom effect (with pure Qt of course). If you are an avid gamer, you know what I am talking about here. And just for the fun of it, I coded it so that you can drag-and-drop an image right from the web browser, e.g. Blooming your favorite Flickr photo easily.

Feedback is warmly welcomed. Enjoy!

Bloom effect with Qt

Sunday, June 22, 2008

on Jim Rohn quotes

Jim Rohn quotes have been always my favorites. Here are my picks:

  • Success is doing ordinary things extraordinarily well
  • Maturity is the ability to reap without apology and not complain when things don't go well
  • Miss a meal if you have to, but don't miss a book
  • Let others lead small lives, but not you. Let others argue over small things, but not you. Let others cry over small hurts, but not you. Let others leave their future in someone else's hands, but not you

midnight in Oslo

Taken today, half an hour past midnight, where the night lasts for only roughly 5 hours 10 minutes. And Oslo is only at 59° 56' North. I wish I would have gone further north.

Sunday, June 15, 2008

JavaScript speed race

Just for fun, I tested JavaScript performance of several web browsers, using the well-known SunSpider benchmark tool. The test machine is a fairly old Fujitsu-Siemens Amilo notebook with AMD Turion64 1.8 GHz processor and 1 GB RAM, running Microsoft Windows XP SP2.

SunSpider benchmark results

The result is not surprising. Internet Explorer is notoriously slow but there is hope with IE8. Mozilla developers have done a great job optimizing Firefox. WebKit with SquirrelFish (and surely the upcoming Safari 4) really shines in speed.

Tuesday, June 03, 2008

creating fancy screenshots with Screenie

Screenshot of SpeedCrunch composed using Screenie

There are tons of open-source projects, on SourceForge, Google Code, etc. If you check a project, most likely you see the screenshots first (don't be ashamed, to look at a screenshot is human). And there lies the problem. There is a fairly small amount of coders that are both very good at writing codes and composing good-looking screenshots.

So we had a terribly hot weekend in Oslo. Too hot to be outside the whole day. So after populating the wonderful weekend with banana brownies (I still favor the one with mango, though), fresh chocolate waffles (let's see if I can still continue the Sunday morning waffle tradition), huge delicious pizza (as usual I underestimated the size), pasta bolognese ala myself (but still can't beat the best one, so I was told), every now and then my own interpretation of alcohol-free SOTB (guess what it is. hint: a cocktail of course), and finally some of the worse sushi rolls I ever made (they got it right when they say practice makes perfect), I still have some free time. Then...

I sat down and checked again this old piece of code, Screenie, that I never had time to finish (note to self: do that more often and clean up the junk). It was a tool to compose a screenshot with some style. By style here I mean of course just copy Apple. Why? If you check e.g. Apple Keynote site, you see the proof that simple transformation and effects can make a big difference. What Screenie can do for you should be predictable: to create a screenshot like that.

Assuming you have Qt 4.4 and git, here are the steps:

git clone git://github.com/ariya/screenie.git
cd screenie && qmake && make

(Likely you need qmake-qt4 for (K)ubuntu and Debian).

Basically you have a window where you can drag-and-drop an image from Konqueror (either local file or from the Internet) and place it there. You have three spots on the screen to fill. Tweak the parameters to achieve the 3-D goodness and translucent reflection that you want. Finally right-click to save the result.

As some Apple web pages show, there are certain cases where you want two images instead of three. So use your imagination and the check boxes are at your disposal. In the following example, I just drag-and-drop the two Plasma screenshots (one, two) I have on my Flickr straight from Konqueror. Don't you agree that visually it does make a difference?

Plasma screenshot composed using Screenie

Benjamin was already playing with that. Helder was using it for SpeedCrunch. Who else wants to join the club?