By default on Windows Eclipse autocomplete shortcut is: Ctrl+Space. In my Mac laptop I use this combination for the operating system’s spotlight quick search. As a result, I wanted to change the default autocomplete shortcut. What you need to do is:

1. Go to Window->Preferences (Eclipse -> Preferences on Mac).

2. In the new window that pops up, go to “General -> Keys”

3. Find the “Content Assist” command and change it to whatever you like (in my case I chose Cmd+Space).

4. Don’t forget to click on “Save” on this pop up window!

Recently I’ve been playing around with a webbrowser control to automate my interaction with a website for testing purposes. I am using C# and DOT NET.

I found it a bit difficult to change the value of an HTML combobox (i.e. dropdown), but as it turns out it’s rather easy.I used the following code to change the value of a combobox named: “test” to the value 12.

foreach (HtmlElement el in webBrowser1.Document.GetElementsByTagName("select"))
 {
 if (el.Name == "test")
 {
 foreach (HtmlElement comboItem in el.Children)
 {
 Console.WriteLine(comboItem.InnerText + " " + comboItem.GetAttribute("Selected"));
if (comboItem.InnerText == "12")
 {
 comboItem.SetAttribute("Selected", "True");
 }
 }
 }
}

This code was used for the following HTML:

<select name="test">
  <option value="10" SELECTED>10&</option>
  <option value="11">11</option>
  <option value="12">12</option>
  <option value="13">13</option>
  <option value="14">14</option>
</select>

Finally the following code was required to press the “Submit” button:

foreach (HtmlElement el in webBrowser1.Document.GetElementsByTagName("input"))
{
if (el.Name.ToLower() == "submit")
{
el.InvokeMember("click");
}
}

I have developed a component in Java that requires an HTML parser. The component goes through around 2000 webpages and gets some data.

It was quite easy to implement it using the org.htmlParser (http://htmlparser.sourceforge.net/). Even though some of the webpages are quite big (some of a size of up to a few hunders of MBs) the memory of the component seemed to grow inexplicably leading to a Java heap out of memory error. I spent a good deal of time trying to figure out the source of the leak thinking it was my code. After a few attempts to identify the problem, I used the IMB Support Assistant workbench and took a heap dump using the command:

jmap -dump:format=b,file=heap.bin processID

I was able to identify a lot of Finalizer objects referencing the org.htmlParser.lexer. This looks like a memory leak, where the garbage collector can’t collect the objects properly?

Well.. the fact of the matter is I haven’t spent an enormous amount of time reading the documentation and/or source code of the project.  It seems there is a close() method that can be called on the Page reference of the lexer and I haven’t used it. So, at the end of my method that does the parsing I added:

parser.getLexer().getPage().close();
parser.setInputHTML("");

The first statement closes the Page object. I added the second statement just to be on the safe side, even though it’s probably redundant.

And the “Memory Leak” seems to have vanished…

I have received an Email with the top 50 programming quotes. Here are my favourites:

  • “Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning.” – Rick Cook
  • “Walking on water and developing software from a specification are easy if both are frozen.” – Edward V. Berard
  • “They don’t make bugs like Bunny anymore.” – Olav Mjelde
  • “A C program is like a fast dance on a newly waxed dance floor by people carrying razors.” – Waldi Ravens
  • I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone.” – Bjarne Stroustrup
  • “In the one and only true way, the object-oriented version of ‘Spaghetti code’ is, of course, ‘Lasagna code’ (too many layers).” – Roberto Waltman
  • “For a long time it puzzled me how something so expensive, so leading edge, could be so useless. And then it occurred to me that a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are, in short, a perfect match.” – Bill Bryson
  • “Good design adds value faster than it adds cost.” – Thomas C. Gale
  • “Perfection [in design] is achieved, not when there is nothing more to add, but when there is nothing left to take away.” – Antoine de Saint-Exupry
  • “The best programmers are not marginally better than merely good ones. They are an order-of-magnitude better, measured by whatever standard: conceptual creativity, speed, ingenuity of design, or problem-solving ability.” – Randall E. Stross
  • “To iterate is human, to recurse divine.” – L. Peter Deutsch
  • “The trouble with programmers is that you can never tell what a programmer is doing until it’s too late.” – Seymour Cray
  • “Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program.” -Linus Torvalds

And my favourites:

  • “You can’t have great software without a great team, and most software teams behave like dysfunctional families.” – Jim McCarthy
  • “Beware of bugs in the above code; I have only proved it correct, not tried it.” – Donald E. Knuth
  • “Sometimes it pays to stay in bed on Monday, rather than spending the rest of the week debugging Monday’s code.” – Christopher Thompson
  • “First learn computer science and all the theory. Next develop a programming style. Then forget all that and just hack.” – George Carrette
  • “Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves.” – Alan Kay
  • “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” – Martin Golding
  • “There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies.” – C.A.R. Hoare
"Programming today is a race between software engineers striving to
> build bigger and better idiot-proof programs, and the universe trying to
> build bigger and better idiots.
> So far, the universe is winning." - Rick Cook