Friday, July 10, 2009

Best slogan ever

http://www.fckeditor.net/: "FCKEditor - The text editor for Internet"

"Look, ma, I'm editing the Internet!"

Sunday, June 28, 2009

GDB 7 will bring major improvements

According to GDB and Debian Developer Daniel Jacobowitz, GDB 7 will bring major improvements:

Improvements mentioned are:
  • Support for understanding inlined functions -- that is, you will actually be able to step in, through and out of them, and get backtraces that include inlined functions!
  • Support for pretty-printing STL containers etc!
  • Python scripting.
So it appears that this release will be a great one. It's slated for this fall.

Oh, and on another sidenote -- I must promote cgdb again, it simplifies debugging with gdb a lot. It will also benefit from these improvements. It could be that it could need a feature or two to make these new features easier to use (python scripting, perhaps?). Sadly, upstream of cgdb appears to be quite dead; no release since 2007.

Function returning function pointer: funny syntax

Take a look at this:

void (*f())(void*);

At a first glance, it may look like some kind of special function that returns void and takes a void*. That's totally wrong. It's actually a function that takes zero arguments, and returns function pointer, a void (*)(void*) -- that is, a pointer to a function pointer that returns void and takes a void*. The syntax actually makes a little sense if you consider the syntax for defining a variable containing such a function:

void (*f)(void*);

Typedefs of function pointers are weird too:

typedef void (*ptrFunc)(void*);

But I can't help to think that the following syntax would be much clearer:

void (*)(void*) f(); // invented syntax
void (*)(void*) f;
typedef void (*)(void*) ptrFunc;

These would make a lot more sense than the current function pointer syntax in C/C++, and would 'logically match' other declarations -- [return] type followed by an identifier (followed by argument list if it is a function), instead of mixing [return] type, identifier and argument list into one big mess.
It may be that the invented syntax is harder to parse -- I have thought a while on this, but haven't come to a reliable conclusion. The syntax may just be a historical artifact.

In any case, this odd syntax must be the reason why you usually define typedefs for function pointers, as done above. Then we can use the following syntax:

ptrFunc f();
ptrFunc f;

Much cleaner and understandable -- the obvious drawback is: what's a ptrFunc? You'll have to find the typedef to know. But I think that's worth it.

Surprise with std::map.operator [] and thread safety

A year ago or so, I got a surprise using std::map.operator [] in a multithreaded program -- the program kept crashing while in subscripting the map, even though I was just reading and nor writing -- I thought!

I looked it up today while peeking at my old code, and discovered that std::map.operator [] inserts a data_type() for the specific key if it does not exist -- which surely explains the crashes I got. The reason I was able to use it like this, was that I was storing a std::map to record valid pointers -- operator [] would thus return false for pointers that weren't keys in the map.

Lesson learnt? Use std::map.find() instead!

Hello again!

So I, umh, decided to start blogging again. It's been a while.

Saturday, August 19, 2006

Vim

Vim is probably the best code editor I've ever tried. It just gets better and better the more you use it. You can define custom commands. It's scriptable. And I love the separation of command vs input mode :)

Wednesday, August 02, 2006

Happy 286 day!

Today it's the only 2/8/6 of the century. I guess only computer geeks will get this, though :)
In fact, this is almost a week of funny dates. 1/8/6, 2/8/6, 3/8/6, 4/8/6, 5/8/6 (pentium day!!!) and last but noe least, 6/8/6 (ppro day!!!)

Thursday, March 23, 2006

Power of valgrind and cgdb combined

I just found out how to make valgrind ask if it should invoke cgdb when it finds an error:

valgrind --db-attach=yes --db-command="cgdb -nw %f %p"

This is incredibly useful. For those of you who don't know, cgdb is a curses interface to gdb, which displays a split view between the code and the gdb console. A bonus is that it uses vim-ish keys and commands. Valgrind is a very powerful memory debugger, which can find memory leaks and find illegal writes and reads to/from memory done by an application.

Sunday, March 19, 2006

Addicted to vim and screen

I've become addicted to vim and screen. With it, I can get a very powerful development environment over one ssh connection. I switch between windows in screens with ctrl-a [0-9]. I switch between splits in vim with some custom bound key combos, ctrl-j and ctrl-k. I can issue regular expressions and I can use all the powerful and flexible editing commands vim offers. Just try pressing d and then any 'movement'. For example dt;. That one will cut all text before the next ;. Then there's the visual modes, v and V. Try selecting some code with it and pressing =. That will reindent that code. And this is just poking on the surface of what's possible with vim.

Friday, March 17, 2006

Artificial Stupidity

seqseq & int: error (7)
seqseq & float: error (7)
byteseq & seq: error (7)
byteseq & byte: error (7)
byteseq & int: error (7)
byteseq & float: error (7)
intseq & seq: error (7)
intseq & byte: error (7)
intseq & int: error (7)
intseq & float: error (7)
floatseq & seq: error (7)
floatseq & byte: error (7)
floatseq & int: error (7)
floatseq & float: error (7)
seqseq & seq: error (7)
seqseq & byte: error (7)
seqseq & int: error (7)
seqseq & float: error (7)
byteseq & seq: error (7)
byteseq & byte: error (7)
byteseq & int: error (7)
byteseq & float: error (7)
intseq & seq: error (7)
intseq & byte: error (7)
intseq & int: error (7)
intseq & float: error (7)
floatseq & seq: error (7)
floatseq & byte: error (7)
floatseq & int: error (7)
floatseq & float: error (7)
seqseq & seq: error (7)
seqseq & byte: error (7)
seqseq & int: error (7)
seqseq & float: error (7)
byteseq & seq: error (7)
byteseq & byte: error (7)
byteseq & int: error (7)
byteseq & float: error (7)
intseq & seq: error (7)
intseq & byte: error (7)
intseq & int: error (7)
intseq & float: error (7)
floatseq & seq: error (7)
floatseq & byte: error (7)
floatseq & int: error (7)
floatseq & float: error (7)
seqseq & seq: error (7)
seqseq & byte: error (7)
seqseq & int: error (7)
seqseq & float: error (7)
Passed Test!


...

Friday, November 25, 2005

How to get rid of ssh brute force attackers

Simply bind ssh to another port. The bots are programmed for port 22 and won't use any other port.

Thursday, November 17, 2005

Note to oneself

What to not do in Nethack: Eat a zombie. It's very likely rotten.

Tuesday, November 15, 2005

Windows box fixed

Turns it it was ZoneAlarm that was blocking images it thought was ads. Disabling it also fixed the non-functional site.

Monday, November 14, 2005

Browsing in windows fscked

My mom noticed that some sites weren't rendered correctly on the winxp box we've got (that I rarely use, but that's another story) and some were even not viewable at all.

One of the sites that aren't viewed correctly is www.resedagboken.se. The photos in the middle of the page is simply... not there. This happened in both firefox and IE (!!). I examined the page source and compared it to the page source on my linux laptop. The result is: the <img> tags for these images are missing on that computer -- they are replaced with whitespace.

I'm having a hard time thinking of anything else than spyware that could cause this... so I'm currently scanning it with ad-aware. Who knows what that poor box might have gotten on it.

Firefox 1.5 rc2 is cool

SVG support, canvas and css3 columns -- what else do you want?
It's also a tad bit faster than 1.0.x. However it still has quite a bit of bugs.