Zenbe Lists has been down for the past few days and I am losing track of my things todo. Had a huge list of things to do on my days off, but… Anybody got any suggestions for a TODO lists program that works with iOS 3.0.1 and will sync with a PC? Guess I could always try a pen and a piece of paper, but I am afraid it will take me some time to remember how to use this archaic user interface.
Selecting the value of an HTML combobox programmatically using a WebBrowser Control
Posted on: October 30, 2011. No Comments »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>
foreach (HtmlElement el in webBrowser1.Document.GetElementsByTagName("input"))
{
if (el.Name.ToLower() == "submit")
{
el.InvokeMember("click");
}
}
A small adventure comes to a happy end..
Posted on: July 26, 2011. No Comments »I have a Windows XP installation on a VMWare hard disk. Today I tried to boot it, but… OOPS (no.. I don’t mean Object Oriented Programming and Systems… I mean..crap!). It seems I forgot the password of the installation. So a little adventure started…
1. After a bit of research I found out that there is ophcrack. I downloaded the live CD as an ISO image and set VMWare to load that CD.
2. When VMWare starts and before windows starts booting I clicked on the VMWare screen and pressed ESC. This gives me the menu to select the device I want to use to boot.
3. I chose to boot from the CD.
4. The ophcrack live CD starts loading, but when it finishes I get a: “No partition containing hashes found” error.
5. The problem seems to be that the Windows installation is on a SCSI virtual disk that is not recognised by this distribution of linux. Tried “fdisk -l” on a terminal from within the ophcrack live CD and it didn’t return any results. To be able to crack the password I need to have access to the “WIndows/System32/config/ folder of my virtual hard disk. So…
6. I created a second virtual hard disk in the same VMWare virtual machine. I downloaded an ISO image of Ubuntu
7. Installed Ubuntu on the newly created hard disk.
8. Boot using Ubuntu. Ubuntu was able to access the virtual hard disk of the windows installation. I copied the folder “WIndows/System32/config/” on my local Windows 7 installation.
9. Downloaded ophcrack for Windows and installed it on my Windows 7. Also downloaded the XP Free Small Table.
10. Launched ophcrack and clicked on “Tables”->Install and selected the folder where I had downloaded the XP Free Small Table file (if it is a zip file you need to unzip it).
11. Select Load->Encypted SAM and select the “config” folder I had copied from the VMWare installation (through Ubuntu).
12. Got my password in 45 seconds!!
An Excellent Podcast…
Posted on: July 23, 2011. No Comments »…on the history and the classes of the titans: http://www.code-magazine.com/codecast/index.aspx?categories=Microsoft&messageid=ac2e5e67-1a66-4d1e-af26-b1f58f7272ce
org.htmlparser “Memory Leak”?
Posted on: June 27, 2011. 2 Comments »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…
Importing WordPress Blog Posts to Facebook/LinkedIn
Posted on: June 13, 2011. No Comments »I keep this blog (which I don’t update very often, but that’s another story) and I post both personal and professional (in the sense that it will appreciated by Computer Scientists) content. I would like to import all blog posts automatically from this blog into my facebook and linkedin profiles.
The thing is that I don’t want to post Computer Science related content into facebook and I don’t want to post into my (professional) linkedin profile all kinds of rubbish. I found out that it is easy to selectively syndicate content depending on the tags that I will add to my post.
So I added two tags, an import_facebook for posts that I want to be imported into my facebook profile and an import_linkedin tag for posts that I want to be imported into my linedin profile.
Then I installed the “WordPress” application for linkedin and I set as a feed url of my blog the following: http://kyriakos.anastasakis.net/tag/import_linkedin
I also installed RSS Graffiti for facebook and I set as a url of my feed the following: http://kyriakos.anastasakis.net/tag/import_facebook/feed
From now on any WordPress post I tag as “import_facebook” will be imported into my facebook profile, while every WordPress post I tag as “import_linkedin” will be imported into my linkedin profile. Before installing the WordPress and the RSS Grafiti apps on your linkedin and facebook profiled respectively, you need to have at least one post tagged “import_facebook” and a post tagged as “import_linkedin” for the applications to pick up the links properly.
Ipconfig equivalent in Ubuntu
Posted on: . 1 Comment »I use a virtualbox virtual machine to run Ubuntu from within Windows (yes, I know I am a masochist). Anyway, every time I resume the virtual machine Ubuntu loses connection with the internet and I have to reset the interface. In windows from the command prompt you have to do an ipconfig /release and an ipconfig /renew. Similarly in Ubuntu all I had to do was the following:
1. sudo ifconfig to get a list of all the network interfaces. There you can see the name of the networking interface that you need to reset. In my case I wanted to reset interface “eth3″. So I did:
2.sudo dhclient -r eth3 to ipconfig /release
3.sudo dhclient eht3 to ipconfig /renew
That’s it! Got a new IP and I can access the internet!
When everything else fails…
Posted on: April 15, 2011. No Comments »This morning I came out of the shower and found my iPhone on the floor. I had forgotten the alarm on and since it’s on vibration, the alarm was ringing for quite some time until the phone fell on the floor. I picked it up and the home button wasn’t functioning, the speakers were dead and it wouldn’t charge. The phone has been like that for the whole day.
I just came back from work and I decided to use a novel approach based on strict scientific/engineering reasoning. I let it fall down again. I picked it up and it didn’t recognise the Sim card. Ooops… I switched it off, removed and re-inserted the Sim card and turned it on. It’s back to normal! The home button works, the speakers are loud and clear and it charging at this very moment!
Top Programming Quotes
Posted on: January 16, 2011. No Comments »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
Installing Visual Editor on Eclipse Helios
Posted on: November 13, 2010. No Comments »I recently wanted to install Visual Editor on Eclipse Helios. Apparently there is an nice way, which works like a charm for me. For more details you can have a look here: http://sourceforge.jp/projects/tmdmaker/wiki/VisualEditor1.4.0ForHelios









Recent Comments