Howto install QT 4.2 and QtRuby 1.4.6 on Mac OS X Tiger

Monday, October 16th, 2006 at 6:30 pm

I had some (minor?) trouble to get QtRuby 1.4.6 and QT 4.2 running on my Mac (PowerPC, 10.4.8). However, with some help from Richard Dale (thank you!) and the Korundum forum I got it working.

Install QT 4.2

First, download QT 4.2 for your Mac. Unpack it and configure it with at least the “-no-framework” option, the remaining parameters are as far as I know up to you. And DON’T use the -prefix option (some people recommended this to put it in /Developer/qt), otherwise QtRuby 1.4.6 won’t find the QT stuff (Default installation path of QT is currently /usr/local/Trolltech/Qt-4.2.0).

>  ./configure -no-framework -system-zlib -qt-gif -qt-libpng -no-debug \
            -no-stl -no-exceptions -fast
 
>  make
>  sudo make install
>  export QTDIR=/usr/local/Trolltech/Qt-4.2.0
>  export PATH=$QTDIR/bin:$PATH</code>

Install QtRuby

Note: This is only to get version <=1.4.6 to work !!!

  • Fix missing headers – don’t link them, copy them (otherwise the build script will fail!)
    > sudo cp /usr/lib/ruby/1.8/universal-darwin8.0/*.h /usr/lib/ruby/1.8/powerpc-darwin8.0
  • Check out some updates of kalyptus we need to add to QtRuby Release 1.4.6
    svn co -r 588725 svn://anonsvn.kde.org/home/kde/trunk/KDE/kdebindings/kalyptus/
  • Download qt4-qtruby 1.4.6 and unpack
  • Copy from the previous svn checkout the files “kalyptus” and “kalyptusCxxToSmoke.pm” into the kalyptus folder of qtruby
  • According to this article we need to comment out the main() function of qtruby/bin/qtrubyinit.cpp
  • In the root of qt4-qtruby you run:
    > ./configure --with-smoke="qt" --enable-mac --with-qt-dir=/usr/local/Trolltech/Qt-4.2.0 
    > make
    > make install
    > cd /ruby/lib/ruby/site_ruby/1.8/powerpc-darwin8.0 
    > sudo mv qtruby.so qtruby.bundle
  • Test your Qt installation:
    > irb
    irb(main):001:0> 
      require 'Qt'
      a = Qt::Application.new(ARGV)
      hello = Qt::PushButton.new("Hello World!", nil)
      hello.resize(150, 50)
      hello.show()
      a.exec()

Enjoy playing with QtRuby ;)
Thanks to all developers making this possible and thanks for the support!

by markus

R from an OO perspective: modifiers / mutators

Monday, October 2nd, 2006 at 2:36 pm

WARNING: I am completely new to R and I might be wrong here, so please be aware ;)

The reason for this post is, that I haven’t found a throughout short example of a S4 class with methods able to change slots aka. fields (mutator methods).

THE main annoyance with R (IMHO) is that there are no ways to pass values by reference. You need some “tricks” to be able to modify the slots of an object (otherwise you just end up with changing the slots of a copy of the actual object ;).

This short example should give you an idea of how we can modify slots of an object in R which allows mutator methods. Browsing some mailing lists I basically found two ways of doing so: setReplaceMethod which returns the object copy and replaces the original object or the “eval.parent(substitute( … ))” trick. But see yourself:

#define a pythagoras class as an example, holding a, b anc c as numeric values.
setClass("Pythagoras",
   representation = representation(a="numeric", b="numeric", c="numeric"),
   prototype = prototype(a = 1, b = 1, c = sqrt(2))
)
 
 
#define a method to calculate the hypotenuse given a and b 
setGeneric("Pythagoras.hyp", 
function(x) standardGeneric("Pythagoras.hyp"))
 
#implement this method
setMethod("Pythagoras.hyp", signature(x="Pythagoras"), function(x) {
	eval.parent(substitute(
		x@c <- sqrt(x@a^2 + x@b^2)
	))
})
 
 
#define a method to set value a and also update the hypotenuse accordingly
setGeneric("Pythagoras.setA<-", 
function(x, value) standardGeneric("Pythagoras.setA<-"))
 
#implement this method
setReplaceMethod("Pythagoras.setA", "Pythagoras", function(x, value) { 
	x@a <- value
        Pythagoras.hyp(x)
	x
})
 
 
#define a method to set value b and also update the hypotenuse accordingly
setGeneric("Pythagoras.setB<-", 
function(x, value) standardGeneric("Pythagoras.setB<-")) 
 
#implement this method
setReplaceMethod("Pythagoras.setB", "Pythagoras", function(x, value) { 
	x@b <- value
        Pythagoras.hyp(x)
	x
})
 
 
#tests
p = new("Pythagoras")
 
p
 
Pythagoras.setA(p) = 5
 
p
 
Pythagoras.setB(p) = 5
 
p

Beaware: Copy and paste sometimes doesn’t work as the double quotes are no real double quotes!

Give it a try. It will be self explaining by then …
If you have any comments, please let me know!

by markus

Milk steaming – the trick with Rancilio Silvia

Saturday, September 23rd, 2006 at 11:29 pm

I have long tried to get perfect milk for a perfect (is this ever possible?) cappuccino. It always seemed so easy to me, but I never quite manged to get the milk right. Well, as Silvia has a 1-hole steam tip, there is one little trick to get excellent mircofoam.

So, we are all (I mean, we coffee geeks) well aware of many tips for the ultimate microfoam, e.g. follow these instructions at CoffeeResearch.org or this one at CoffeeGeek.

However, to become perfect microfoam with Silvia, you have to change some parameters as compared to a heat exchanger machine:

  • Where to place the steaming tip? This is actually crucial, especially for the expansion phase: Hold the pitcher slightly beveled and put the wand directly towards the edge of the pitcher, but make sure that the milk starts spinning while you do so. Place the wand to the middle of the pitcher – and you won’t get perfect results. Touch one wall and perform your milk expansion and you’ll be surprised by the result! After expansion sink the wand and start turbulating as usual.
  • The milk stretching/expansion phase shouldn’t be too long – as a rule of thumb stop expansion phase at about body temperature (40 ºC or 100 ºF). The final spinning/swirling of the milk needs to be a bit longer (up to about 65 ºC or 150 ºF) with Silvia, as she is not as powerful as heat exchangers. Another reason is if you expand the stretching phase you also end up with too much foam.

Enjoy milk frothing with Miss Silvia!

Posted in Espresso
by markus

J2ME development on OS X: Emulation and JSR-75 – solved!

Saturday, September 23rd, 2006 at 10:08 pm

You want to develop J2ME applications with a Mac OS X operating system ?
This is not as easy going as one might think:

SUN unfortunately provides the “Java Wireless Toolkit” not for OSX (for whatever reason) and their emulator therefore does not work. I think there would be more potential J2ME developers under OSX, but this is actually their (bad) decision. Furthermore, they provide their latest stuff only for Windows :( The only way to get it going on a Linux system is using the old WTK2.2 – nice uh ?

However, there was light at the end of the tunnel:
The mpowerplayer SDK is an emulator (and more…) which is supposed to work on an Apple computers. Well, it does, but there is another catch: No support of the JSR75 fileconnection API so far.

Now and finally one very nice guy implemented the specification and provides a CLDC.jar for mpowerplayer which now allows file input/output !!! This is great news. Thanks for all the effort again! You can see the discussion and also a link for the download of the file here (I think you have to be logged in to view it).

Now and finally my MiniPauker stuff can be developed on my Mac. Nice – very nice indeed.

If you use J2ME-Polish and want to migrate your stuff to OS X, there is one more thing you have to change in your ANT build task:
the preverification of the code is not working with the WTK (the Linux version) – modify your build section and point it to the MPowerplayer subdirectory osx:

 *snip* build preverify="/Applications/mpp-sdk/osx/preverify/preverify" *snip*

Enjoy your Midlet development!

by markus

MiniPauker feature complete

Monday, August 21st, 2006 at 9:04 pm
* WPG2 Plugin Not Validated *

My MiniPauker application is now feature complete for its future stable release.

You ask what MiniPauker is all about? Here it is:
MiniPauker is a flash card based learning application for mobile devices and handhelds. It is based on the leitner cardfile system and is compatible with Pauker (http://pauker.sf.net, the desktop version of this software). MiniPauker uses a combination of ultra-shortterm, shortterm, and longterm memory. You can use it to learn all the things you never want to forget any more, like vocabulary, capitals, and important dates.

Following changes were incorporated:
Cards can now be drawn randomly. Cards which are not learned in “ultrashort-term” go back to be relearned immediately in the next round. UTF-8 was fixed (for Sony Ericsson). The progress bar was fixed. Exception handling in background tasks was fixed. Umlauts were fixed. The code was cleaned up. The UI was polished. Import/Export works now – hopefully – on all devices which support the file connection API JSR-75; exception are those (stupid) mobiles which need a code signing certificate *AAAAAAArgh*. If JSR-75 is not available on a particular phone the im-/export functionality is disabled completely which is not misleading users.

My personal summary of J2ME:
J2ME alone is very very limited in general, but this is on purpose; we shouldn’t forget that it was designed for very limited (mobile) devices. J2ME-Polish helps to improve J2ME significantly and at the end of the day you can do some useful stuff in the way you want it.

Personally the most annoying and frustrating “ISSUE” with J2ME is that it behaves differently amongst various devices. It almost always works in the way you want it in the SUN WTK emulator, it also works great in the IBM J9 implementations for Palm and Pocket PCs … but for the rest of the world it is a lot of trouble. The last weekend I managed to fix some more bugs which only (!) occurred on Sony Ericsson phones, and I am sure there are some more bugs with other brands too. It seems the specifications are not always implemented correctly – and this makes live different – at least if you are used to work with SUNs well behaved standard SDK :)

Anyway … I will continue maintaining the MiniPauker application. I quite like it these days. It does its job nicely and it seems people out there like it as well. If you want to provide feedback, please feel free! Thanks!

Posted in (Mini)Pauker
by Markus

Solo pilot again!

Tuesday, August 15th, 2006 at 9:34 pm

Great news – at least they are great for me: I am a solo pilot again :)

In the last 3 month I had something like 8 hours flight with instructors. I was not pushing things to become solo; sometimes we had a great soaring day so I simply improved my thermalling skills and enjoyed to see the world from a birds perspective (rather than training starts and landings in particular – which is the thing which stops you to solo at some point).

Gliding CGC

Resume of the last month: The Cambridge (University) Gliding Club is an excellent place! ALL instructors I flew with were absolutely amazing! A BIG thank you! I think I flew with 10 different instructors (out of 30 or 40) and they after every day I though: WOW ;) They have a lot of very very good people there. Many are top people on the BGA ladder or even world champions! The general atmosphere at the club is great, helpful and I always enjoy my time there.

Posted in Gliding
by Markus

maildir to mbox

Tuesday, July 25th, 2006 at 4:27 pm

I simply wanted to convert my maildir from KMail to a standard mbox format, e.g. to be able to import it in Apple Mail, Mail.app under OS X. However, I found only complex scripts, none worked for me and I was about to start writing my own script until I found this very easy and neat solution from Christian Zagrodnick – works perfectly:

import sys
import email
from email.Errors import BoundaryError, HeaderParseError
from mailbox import Maildir
 
maildir = sys.argv[1]
 
md = Maildir(maildir, email.message_from_file)
 
while True:
    try:
        mail = md.next()
    except (BoundaryError, HeaderParseError):
        continue
    if mail is None:
        break
    print mail.as_string(True)

Call it via (“python scriptname.py pathToMailDirFolder > file.mbox“) and enjoy!

Thanks to Christian Zagrodnick who made this simple script available at:
http://www.gocept.com/Members/zagy/maildir2mbox/view?searchterm=maildir

by Markus

Birthday BBQ

Sunday, July 9th, 2006 at 1:01 pm
* WPG2 Plugin Not Validated *

We had a wonderful BBQ yesterday … it was my birthday and sort of a house warming as well :)

Thanks all for coming – it was great to have you here!

Recall some nice and funny impressions in my gallery if you like. Please let me know if you feel offended by any of these pictures, so I’ll remove it. Personally I think they are all great :)

CU around, all the best, Markus!

Posted in Everyday life
by markus