Archive for March, 2006

Eclipse Won’t Print under Linux

Thursday, March 30th, 2006

Eclipse won’t print under linux. The bug report makes for an interesting read.

However, Kim Lux has posted a rather satisfying workaround for KDE users which allows you to open your currently selected text file in kwrite and print from there.

To set this up: Run/External Tools/External Tools. Create New, name it kwrite-print, location: /usr/bin/kwrite, Working directory: ${container_loc}, Arguments ${resource_name} then, if you wish, switch to the Common tab and select External Tools in the Display in Favourites menu window.

Now you can use Run/External Tools/kwrite-print to open your code in the external editor and print it from there.

Interfaces in C++

Tuesday, March 28th, 2006

Following a discussion on a mailing list tonight about object-oriented v procedural programming, I’ve been doing a little digging.

The discussion was on whether objects should have their own print method or should be passed to an external Printer object that handles that function.

One solution in Java would be for them to implement an Interface Printable that provided a toString() method. That way, the object remains decoupled from the output process but encapsulation is preserved and the Printer object (which takes a Printable object) does not need to know anything about the internals of the objects it is passed.

Which led to the question, can you do this in C++?

It looks as if Interfaces do not yet exist in C++ in spite of some interest. There is a library under development however for submission to Boost.

Google Mars

Sunday, March 19th, 2006

Google’s latest addition to google maps is too beautiful for words: now you can explore the red planet from your desktop.

Why Good C++ is Neither Too Low Level Nor Too High Level

Sunday, March 12th, 2006

In an interview from 2003, Bjarne Stroustrup advised programmers not to treat C++ as C and to take advantage of the STL. He was wary, however, of copying the Java model and making everything too OO.

I particularly dislike classes with a lot of get and set functions. That is often an indication that it shouldn’t have been a class in the first place. It’s just a data structure. And if it really is a data structure, make it a data structure.

The C++ Style Sweet Spot | A Conversation with Bjarne Stroustrup, Part I by Bill Venners (October 13, 2003)

It’s a brief and interesting read.

Stolen Birthday Gift

Saturday, March 11th, 2006

If you sent me a birthday gift the other week, please let me know via email. I may have had a parcel stolen but I don’t know what it was or who sent it.

On Tuesday, a slip was left from the postman saying that he had tried to deliver a packet that was too large to fit through the letterbox. I was a little annoyed because I had been in that morning and he had not rang the bell. I didn’t notice at the time that the date on the slip was from the previous week.

When I went to the post office this morning to collect the package, they told me that someone collected it a week ago and that “They must have said they didn’t have the slip with them and shown a bill or something with your name on.” Top marks for your verification procedures, Royal Mail. Good to know that all a thief has to do to prove he is you is steal a bill while he’s going through the rest of your post.

Obviously there are no managers working at the weekend so I’m waiting until Monday for a call back from someone who might be able to work out what happened. I’m still hoping that the whole thing is an administrative mistake but given our recent troubles with dvds being stolen in the post I am tempted to think the worst.

Write Small But Useful Programs Every Day

Tuesday, March 7th, 2006

I recommend writing small but useful programs every day. Never mind that someone has written the same or better once. They are not you. You must feel the utility of your own programs to gain a sense of balance between that and complexity.

WardCunningham

Sage advice found here while getting distracted from my main purpose.

Longer Battery Life Coming Soon

Monday, March 6th, 2006

At last, portable batteries are beginning to evolve. Lack of adequate power is holding back portable computing. The M1, while designed for heavy-duty equipment, is a much needed sign of progress.

The M1, based on the same lithium-ion technology used in your cell phone and laptop, is the first product from MIT spinoff A123 Systems. Cofounder Yet-Ming Chiang, a materials science professor, succeeded in shrinking to nanoscale the particles that coat the battery’s electrodes and store and discharge energy. The results are electrifying: Power density doubles, peak energy jumps fivefold (the cells pack more punch than a standard 110-volt wall outlet), and recharging time plummets.

Super Battery | Wired

Fixing Eclipse 3.1.2 for Debian 3.1

Saturday, March 4th, 2006

The easiest solution is to download the source for the whole of Eclipse, comment out lines 914-916 of plugins/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java then build the whole thing as per instructions here.

No doubt there is a way of just re-building SWT from scratch but I couldn’t work it out.

Irritating Eclipse Bug in Debian

Friday, March 3rd, 2006

I thought I was going mad the first time the Delete key stopped working in Eclipse. This evening (early morning) the Control and Alt keys stopped working.

A quick browse through the readme revealed that this is a known bug:

Key bindings stop working (GTK+ only)
When using Eclipse, most key bindings will stop working. The only way to make the keys start working again is to restart Eclipse. This problem occurs on Debian, using libgtk+2.0 (2.6.4-2 or later). The problem is that a focus issue exists in GTK+ 2.6.7 and earlier, for which SWT has a workaround. This workaround is incompatible with the fix in GTK+. SWT detects the GTK+ version on start-up and decides whether to enable the workaround. Debian backported the focus fix into their libgtk+2.0 (2.6.4-2) package. To workaround this problem, either get the Debian unstable version of GTK+, compile your own GTK+ or hack Shell.gtk_realize(int) and change the version it checks. Please see either Eclipse’s or GTK+’s bugzilla for more information.

Coming on top of a dying mouse that re-interprets single clicks as double clicks at the most inappropriate moments, I’m beginning to think that my machine hates me…

Still, while looking online to verify that I wasn’t going insane, I stumbled upon the following useful Javaworld article: Become an Eclipse Hotkey Showoff. My favourite is “Hippie Completion” - just for the name. Once I get the control keys working reliably on my keyboard again I’ll have to try it