Wednesday, August 26, 2009

Playing with Qt Jambi

Over the last couple of days I've been playing around with Qt Jambi, the Qt bindings for Java, which are pretty cool. I haven't used them that much so far, but they seem really nice. I'd been starting to write this little car game thing, which is more a proof of concept at the moment, which I've now ported to be able to use Qt.

Try it as an applet here (note this is using ordinary Java swing, not Qt as I'm not sure if you can embed a Qt widget in an Applet (or in any AWT or swing element). Then there'd be the trouble of having to download Jambi which is fairly big.

Use your arrow keys to drive around, Ctrl+R resets (in hindsight, not a good choice as it coincides with firefox's and epiphany's reload page shortcut (possibly other browsers too)). The physics is terrible, but I find it fun just driving around, making pretty patterns. You might need to click the applet to give it focus.

Or you can download it here. That includes the source. To run it using qt, it will need to find the Jambi jar file, and it looks in the current directory and "/usr/share/java/qtjambi.jar" (the latter is the default location in Ubuntu (and possibly other distros), so you just need to install the jambi package). You can download Qt Jambi here. Then you need to pass the command line option '--qt'. By default I try and use opengl (which is faster), if it doesn't seem to work, try '--qt --no-gl' to use the regular qt rendering engine.

The number in the top right corner is how many milliseconds it's taking to draw each frame (averaged over the last 100 frames I think). I found Qt with no opengl to be about the same speed as Java swing at 640x480, which I found surprising, I thought Qt would be significantly faster, though at full screen swing slows right down, while Qt only takes a little bit longer, and with opengl it's about 25% faster. YMMV.

I had to be a bit sneaky when writing this so that the swing version would run fine even without the Qt libraries. My first (which I thought was nicer) implementation didn't work, as there were references to the Qt classes in the classes that were being run, even though they weren't used. So when I redid it I had to split everything up, a swing version and a Qt version, so that when swing was being used there would be no references to the Qt classes. I wasn't sure that that would work, but it did, which is pretty cool. Enjoy.

Edit: It appears it's pretty hard for this thing to regain focus, I should probably look into that, enjoy it if you can get it to work, otherwise download the jar, that's more likely to work correctly.

Tuesday, August 25, 2009

Windows Network Grrr...

I've come to be incredibly frustrated with how networks work under Windows (XP) over the past year or so. I'll explain my set up a little first, I have a laptop which runs Ubuntu, I connect to the Internet via another computer (running Windows XP) which connects directly to our cable modem. I thought I'd have issues with this seeing as how I wasn't using Windows, but on my side it has been a breeze (much easier than in Vista on the same laptop).

The thing that irritates me is that every time the driver, firewall etc. is updated, or just at random other times, the computer stops me from connecting. I haven't changed anything on my laptop, I just can't connect to the network. So far we've managed to fix the problem by changing some option somewhere on the XP computer, in some nested dialog box, or whathaveyou after trying various things for around an hour. As I said earlier, it's incredibly frustrating. A thing like that should just work, which it does in Ubuntu, but not in XP (though I haven't tried the other way around). Rant over.

Wednesday, August 19, 2009

Proposed road safety law changes

Some new road safety proposals and things came out today (or maybe jest recently), which can be found here. I had a quick squizz at the summary, which overall seems pretty good and I support a lot of the ideas, especially the increased focus on fatigue, which I think is often overlooked. But there's one proposal in there that really irritates me, so prepare for a rant on that.

The offending proposal is: Introduce a zero BAC limit for certain drivers (drivers under 20 years, adults without a full licence, and commercial drivers) (And Guptill just got out, grrr.) These proposals for a zero limit always irk me. People don't seem to understand what zero means, or how common things are that contain a trace amount of alcohol.

Among other things, the following can all contain small amounts of alcohol: cough syrup, fruit juice, and bread. With a zero limit, even the most minute amount of alcohol puts you over the limit. Sure, with current equipment means these trace amounts won't be detectable, but even so, if this law change were to go through it would be illegal to drink juice left in the sun (which had fermented a little) and then drive. How stupid is that? Sure, reduce it to a very small amount such as 0.01% or 0.005%, but not zero. Zero is just stupid.

Just to be open here, I don't fall into this category, I am not under 20, and I have my full licence, so I don't have any obvious ulterior motive. I just hate ridiculous proposals for laws, because there's always the chance that they will no longer be proposals, but get enshrined and adhered to.

I understand the purpose of these laws, to encourage people to not drive if they have been drinking, but a zero limit is not the way to do that. A zero limit may do this, but one huge side effect is that it'll make the actions of people who aren't endangering others illegal. This is when laws go to far, there is a limit to how much they can infringe on the rights of the people. So while I'm in favour of reducing the blood alcohol limit, NZ's is one of the highest in the world as it stands, but I cannot support a zero limit.

I plan on making a submission on the previously linked to site, and possibly even writing a letter to the editor, though I'll need to organise my thoughts a lot better for that. I had more ideas before, so I might add them to this if they come back in an arbitrary manner.

Monday, August 17, 2009

My most productive evening of study - ever

As the title suggests, I think this evening has been the most productive evening of study I've ever had. I got home just before 6pm, and probably studied for all bar 1-2 hours of that until now (11:20pm), and it's not even as if I have something really urgent that I need to finish.

So, when I got home I started my Calc assignment first, spend around an hour working at that, doing a considerable amount. Then we had dinner, and afterwards I went downstairs and did a few things on my computer (not taking much time altogether), then starting reading The C Book as study for a test I have on Wednesday. After a while I stopped, finished my Calc assignment (which was fairly straightforward, though relatively long, 5 pages in all). Then I came back downstairs and continued reading the aforementioned book. I think I read almost 100 pages (as in the pdf version), and now I'm writing this.

I don't think I've ever spent so little time doing other things, even when I had a big assignment, lab report, test or exam the following day. It's crazy. It's as if I've got all motivated or something. But I think it's a good thing, so far at uni I've been cruising a bit too much, doing the minimum necessary for good grades, when it would be better to understand what I'm studying a little better, and with better time management I should be able to keep my sleep more consistent which has to be a plus (I fall asleep way too often in lectures).

I'll see if I can keep this up now...

Thursday, August 6, 2009

The magic that's coming to your browser

I was reading on slashdot an article (actually it's more a blog) about some of the cool things that people can now do with javascript and HTML5 and the like in newer browsers. (Sorry if you're using IE, there may be new versions, but they don't support a lot of this stuff.

Have a look for yourself at some of these:

All of these are pretty cool, and note that they don't need any browser plugins to run (though some of them use external scripts, which is kind of like a plugin). I'll draw your attention to the last one in particular, notice that it doesn't use HTML, but the main page is an svg. People have been talking about how this could be the future of the web (though IE doesn't support svg at all yet AFAIK, so if it will be, it'll be a long time away). You may know of svg as a vector graphics format, wikipedia uses it quite a lot for graphs and things nowadays, where it is inherently better than standard images with pixels and all that, but it is a whole lot more than just a vector graphics format, which is why most browsers haven't fully implemented it yet (it's a whole pile of trickiness).

This could also potentially displace flash, which I'm a bit ambivalent about. At the moment I see some places where flash is used well, but all too many where it is used poorly, and the same could be done with these kind of technologies. Also, flash is a whole lot more mature that this, so it can do a whole lot more at the moment (you may have noticed the above could be quite CPU intensive), but there is good competition in the browser space so these should improve rapidly.

I hope you enjoyed my plagiarism of a slashdot article, and a bit of inane ramble.

Probably

When people ask me if I can do something, if I can come to something, etc. and I think I can and want to, my general response if 'probably.' This must infuriate some people who want to know things for "sure" and be able to plan. But I have good reasons for saying probably over definitely, sure, etc. in that it's impossibly to mean something like definitely, or sure when you're ntalking about the future. Anything could happen. And while my level of commitment is generally above the level usually referred to by probably, I can't think of a succinct way that I could say it more precisely.

In emails and things like that, I will sometimes say "Yes, barring some exceptional circumstance" or the like, but that's a bit of a mouthful in a conversation. "Almost certainly" is pretty good, but then I have to go through this whole thing when they ask me why I'm just "almost."

Oh, the tedium of trying to be precise...