If you find yourself for some aweful reason working with GWT, do yourself a favor.
Add the following line to 'Advanced settings' of 'GWT Compile' dialog:
-draftCompile -localWorkers X
X being the number of cores in your CPU.
You can thank me later :)

(+Boris Daich, you might find it helpful)


Pesky Etching

While working with Qt buttons I've came across a very nasty behaviour - when you disable a button, it's label receives a pretty ugly shadow that makes the font rather unreadable. This effect is called 'etching'. There is a reminant of a CSS property that controls that behaviour called etch-disabled-text, but it's undocumented and actually doesn't work at all.

There is NO documented way of removing that shadow. Pretty crappy, especially for a very configurable toolkit like Qt.

Anyways, here's a workaround. It'll set the proper global palette rules that will apply this fix to all the buttons.
The first line sets the color of the disabled text, the second - removes the etching.



As a continuation to my wildly popular XKCD2PDF post, here's a script I whipped out to get me some sweet PDFs of a great comic called The Oatmeal.


SCons and Qt Resource files

Today I've stumbled upon a bug/problem with SCons' support for Qt resource files (the ones with QRC extension).
Usually, to add a QRC to your project you add a line like this:
qrcobj = programEnv.Qrc("SomeFile.qrc", QT4_QRCFLAGS="-name SomeFile")
and all is well.
But - probably due to a bug somewhere in qt4.py module, the files that are referenced from inside the QRC (the actual images and stylesheets) are not added as a dependency to the build process, so when you change a CSS file, the QRC will not be rebuilt.
The snippet below parses the QRC manually, fetches the list of files inside and adds the to deps list; Python rocks.


warning MSB8015

If you try to build a project in Visual Studio 2010 and you get the following error:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(151,5): warning MSB8015: Forcing a rebuild of all source files due to the contents of ".........\Debug\custombuild.command.1.tlog" being invalid.

Don't despair. I tried googling it and came up with a total of 3 (THREE) results in the whole web, two being in Korean. Yikes.
In any case, the solution was rather simple - check line ending inside the project file. If for some reason (due to being committed to SCM incorrectly, or something of similar nature) it has improper line endings, VS2010 will think that you have bad symbols inside build commands and make the build result invalid.
In my case, I had CR-CR-LF line endings - which, after being changed to CR-LF - solved the issue.



This one doesn't neccessary fall under the topic of this blog, but since it's a hacky thing I've done - I'm posting it here.

Some time ago I wanted to get all the XKCD comics stored on my iPad for offline viewing. Didn't find another solution so I cooked my own:

  1. A script that gets the JSON files of each comics and rips the important info
  2. Download the stuff
  3. Build a HTML page describing the comics with their 'alt' part (the good stuff)
  4. Open the HTML in Word, set margins to zero, save as PDF
  5. ...
  6. Profit!

I am really sorry about the 4th step, I know it's lame, but suprisingly, Word's "Save-as PDF" feature gave the best looking output.

And if you are lazy, you can grab the already generated PDFs here: (split in 3 chunks, the first 900 comics).


P.S. Here's the script:


Checking if MPMediaItem exists by URL

If you are usings AVPlayer with Asset URLs, you might want to check asset's existence on the device.
If the asset is a file in local folder - no problem, you can use NSFileManager to check for existance? But what if it's inside the iPod library? The following trick wasn't easy to find, but here it is:

   NSURL* furl = [f trackUrl];
//        ipod-library://item/item.mp3?id=
        if([[furl scheme] isEqualToString:@"ipod-library"]){
            NSNumber* pid = [NSNumber numberWithLongLong: [[f.name substringFromIndex:32] longLongValue] ];;
            MPMediaPropertyPredicate *predicate = [MPMediaPropertyPredicate predicateWithValue:pid forProperty:MPMediaItemPropertyPersistentID];
            MPMediaQuery *songQuery = [[[MPMediaQuery alloc] init] autorelease];
            [songQuery addFilterPredicate: predicate];
            if (songQuery.items.count == 0) {
                return NO; // NOT FOUND!