Oct 29 2008

Posted by coen under General,Java

learning by cheating

A long time ago, when I still was in high school, I sometimes tried to cheat my way out of some classes (like French, for instance). Of course, after a while, I got reasonably good at it, and that’s basically how I finished the course. I became more and more bold in other courses too, and after a while I got caught ( that was inevitable, of course).

Some time after I finished the part of high school we call ‘brugklas’, I came across a teacher who, to my surprise, encouraged using cheating notes. As I soon would realise, the man ment for us to create cheating notes before the exam, and not use them during one. That way, he said, you learn to summarize the things you need to study for that exam, and you’ll remember it, too.

The man was right. So, now that’s all behind me, I can use this story to do some cheating, while pretending to learn from it as well :) The cheating is about a trivia channel on irc. I’m writing a bot in Java that can parse irssi logfiles, and is also able to learn from the questions the trivia bot asks. The things I’m hoping to learn from this: How to simulate a human being that answers the questions (that means, among other things: do not answer every question correctly, but also that is makes some sense), and what is the nicest, most efficient way to learn questions; how do I determine the correct way to answer, etc.

So: $learning_by_cheating++

2 Comments »

Oct 12 2008

Posted by coen under Programming,c++

Valgrind and it’s neighbours

For some time now, I have been working om my messaging client Skaar. Last week I built a version that only can connect to an IRC-server. There’s still a lot of work to do, but it was time to test and debug my work done so far.

A classmate told me to use valgrind to test Skaar for memory leaks. Valgrind is a suite of tools for debugging and profiling programs, so that should work, and there I went:

valgrind --log-file=./valgrind.log --leak-check=full ./skaar

After shutting down, it turned out that Skaar had left something behind, and not that modest (43Kb) either. It’s actually not that simple to prevent memory leaks, I learned. The obvious cases seem to scream: free(3) or delete me, but the not so obvious cases keep their mouths perfectly shut..

Obvious case:
char* line = (char*)malloc(513);
memset(line, 0, 513);
strcpy(line, "PRIVMSG #mychannel :foo\r\n");
...
free(line);

Not so obvious case:
// in RFC1459.cpp
JoinMessage* joinmessage = new JoinMessage(this, line);
return (AbstractMessage*)joinmessage;


// somewhat later in Skaar.cpp
AbstractMessage* message = protocol->translateIncoming(rawmsg);
...
delete message;

I’m wondering if this is the right way to end the AbstractMessage*‘s life, by the way. Who’s responsibility is it to get rid of the message? I could go with this solution, that says: “Here is your object, have fun”. I could also create a function in the protocol that destroys the message, something like RFC1459::destroyMessage(AbstractMessage* message), that says “Here is your object, but you have to let me take care of it’s end. Actually, I have no clue which one is the best choice, if there is a best choice here..

But, back to business: all I have to do now is just test every possibility to see if there are any leaks. Or I could just watch it when I write code, which also sounds nice.
Another tool that I’ve come to value is gdb, The GNU Project Debugger. This tool allows you to see what happens ‘inside’ the program while it executes. And yes, I stole that line from gnu.org :)
To start using gdb is not very hard, just type gdb yourprogram, and that’s that. To actually start executing you program, type run once gdb has started.

No Comments »

Sep 27 2008

Posted by coen under School,Uncategorized

The switch

A week or so ago, Guy and I decided to switch back from the minor we were doing at Utrecht University. As it turned out, the supposed level of math was so different than my own level, that I couldn’t keep up with it, so we switched back to Hogeschool Utrecht.

At first I was disappointed that we had to switch back, but now that I’m there, I feel home again. So, instead of our previous plans, Mattijs, Guy and I are going to try and do some research, and the results will be implemented in a now-not-so-ready-but-workable my.hunix.nl.

The idea is to find out (for both students and lecturers) what the current problems are while doing project-oriented assignments. For example, students have not one, but multiple places where they have to leave their work logs, and on top of that no decent templates, because every lecturer has his or her own definition of them, so student have to meet different demands, etc.
After we’ve determined a solid set of problems and solutions, we will create a portal for both parties, where they have a nice and easy overview of what they’re actually doing at that point.

Nice thing about this for me is that I’ve time to assist at the preHBO again, because I now don’t have to study until midnight and later to keep up with the courses :)

No Comments »

Aug 20 2008

Posted by coen under General,Life&Cooking

Oops

After we spent out first holiday-week in Portugal, we decided to spend the second week in Eersel, The Netherlands. I must tell you, it’s a relief being here. And not just for the quiet environment (there’s lots of that over here), but also in case you forget to bring something, because you can go back and grab it. Maybe, if you already know me, you know that I tend to forget stuff. So to keep the legend going, I also forgot something this time (I don’t know exactly what it was again, but it had something to do with sleeping at a decent temperature).

You guys have no idea how lucky I was this time, because my girlfriend also brought stuff to sleep nice and warm, so I didn’t have to go back :) The only thing I have to do next time is prepare (as in creating a list of things that I have to bring, and actually take them with me).

That’s all for now folks, see you next time!

2 Comments »

Aug 04 2008

Posted by coen under General,Life&Cooking,School

Finally

Hi y’all,

today I decided that I have been ‘offline’ long enough, and that I must write a final post before I leave for my holidays: so here it is.
Actually, I have *a lot* to tell, but I’ll stick with the 2 weeks to come, for the sake of my peace of mind and stuff.

Tomorrow at 22.00 local time, we will arrive at Lissabon Airport, from where we will be driven to our bungalow. This year, we (as in my girlfriend and I) decided to go on holidays together with another couple. The first week we’ll spend together, and the second week we will split ways and see each other again at the airport to fly back home.

I think my girlfriend takes a camera with her, so there will be lots and lots of pictures taken, including nice civil looking ones with me in it. As I do not want to bear that burdon alone, I will share some of that pictures with you after I get back, so be prepared!

After we get back from our holidays, the fun begins again at school: I am going to do a minor at the University, as I told before. The downside of that is that once again, I had to change the composition of the courses because some idiot over there found it neccessary to switch some of the courses.
So my actual, final list of courses (at this moment) is as follows:

I really look forward to learning all that stuff, because it brings me up to speed for the master I will take after I graduated for my BICT (some kind of BSc).
So folks, that’s it for now, I’m out until August 21th. Good luck and farewell until then!

No Comments »

« Prev - Next »