Just looking at where Google would have me walk to get to a local dry cleaners. It’s literally across the bridge an turn right and that isn’t taking into account turning off early and heading across the park. Surely some enterprising Googler could add a feature where pavements and cycle paths could be manually added and voted on for reliability?
Employ me and I would do it for you!
May 16th, 2010 :: graham.reeds
Categories:
Life ::
Misc
This post and the one that came previously, were written on my HTC Desire.
The WordPress app will allow me to write posts as and when they occur to me instead of what happens now which is they occur to me but are forgotten as I am not near a keyboard at the time.
A big hurrah for modern technology!
…but they definitely were not K-I-S-S-I-N-G. In fact they weren’t even holding hands.
As a test at work for a new project I was asked to look at using Maven, which is currently being used to great effect by the Java programmers, with C++. A new project has arisen that requires proof that there is 100% code coverage, has various code metrics and need to be presented at the end of it.
As usual the first thing I did was canvas the ‘Net for other peoples experiences. There is no point in reinventing the wheel if you can help it. Unfortunately peoples experiences weren’t good. On the plus side they weren’t recent.
So I set off looking at the Mojo Native Plugin. One of the first things that concerned me was the lack of direct Unit Testing support. I had noticed that several other language plugins had direct support for unit testing. However I can work around that. The other major concern was running the code metric tools that were being evaluated concurrently.
Eventually, after nearly whole frustrating week, I gave up with the Mojo tool. It was simply unworkable. Didn’t help that I am not use to paying the angle bracket tax. I then shifted my focus to the Jade Native Plugins. This is actually a fork of the Maven plugin but has moved along and supports unit testing and static analysers.
This on the face of it seems like a good thing but was again unworkable, but this is probably me more than them – I am not used to editing the pom.xml and getting the relevant info from provided examples is not easy especially when the underlying code seemingly doesn’t work with the examples.
Feeling increasingly like a failure, I turned to Hudson which several posts had pointed to. This was a breeze in comparison. A massive relief as I had a build up and running quickly and a couple of days later after overcoming a few niggardly problems I had a build that had unit tests and code coverage.
I presented my findings and guess what we picked? Option C: Maven2 execing batch files. Did I mention the PM is/was a Java programmer?
April 8th, 2010 :: graham.reeds
Categories:
C++ ::
Life ::
Work
I recently had a problem at work where an application failed if the user tried to use UNC paths in a application that was ran as a service.
This service was written in C# that called into C DLL. Not only that, but the DLL was written in VC6.
So after confirming I could recreate the bug I removed the service and installed the debug version. I tested again and it was still there. I then added System.Diagnostics.Debugger.Break to the code and stepped in and through until I got to the calls to the DLL. The call stepped straight over. Hmm.
- Debug build of the DLL: Check.
- PDB file: Check.
- Step into unmanaged code: Checked.
- Debugging option: Mixed.
So what next. Maybe it wasn’t picking up the debug DLL. So I went around and deleted every other version of the DLL. Didn’t fix it and broke most of the support apps. Maybe it was a weird VS2K5/VC6 interaction. So I rebuilt the library in Visual Studio but it still failed.
I could see the problematic code, but I couldn’t step in to see what the parameters were when it was there. So I created a small console app and transplanted in the problem code and called it. Worked as expected. Which brought up the idea that something was changing the parameters – but why, where and again why?! So the simple console app was extended to call the dll with every single call from the service in it with the same parameters, finally ending where the problem happened.
However it didn’t happen where I expected it to – the breakpoint I placed was never hit. I thought that it wasn’t debugging properly still but it broke successfully if I placed a breakpoint at the start of the code. But if the code wasn’t being reached where it called CreateDirectory how comes there is a directory in the root of C:\ with the name of unc machine?
It turns out that it called a function earlier in the code than expected that uses mkdir – and the code that uses CreateDirectory never gets used due to the parameter tests that are done.
I looked at this code and thought about fixing it but there was over a hundred lines of strcat, strcpy, strtok and moving pointers around. I decided that it was horribly broken and rewrite was in order. So I looked on the net because this is a good case of reinventing the wheel. Most sites, including my beloved StackOverflow, suggest using Boost.FileSystem which in my case is a non-starter. So I had a think about it and this is what I came up with after one false start:
BOOL CreateDirectories(char* path)
{
BOOL status = TRUE;
char* p;
char temp_path[256];
strcpy(temp_path, path);
do {
p = strrchr(temp_path, '\\');
*p = '\0';
} while (!SetCurrentDirectory(temp_path));
do {
p = strchr(temp_path, '\0');
*p = '\\';
status = CreateDirectory(temp_path, 0);// do not check because this will fail on 'too\\many_slashes'
} while (strlen(temp_path) < strlen(path));
return status;
}
Now you can get away with removing the temp_path but I copied the original string to be safe, and I should of used MAX_PATH instead of hard-coding 256 but I think the code is quite elegant (though the WordPress formatting doesn’t really do it justice).
There’s a warning there – not to compare against the status in the while clause as having two slashes instead of one will prematurely cause the function to exit. Ignore the error that the function returns (ERROR_ALREADY_EXISTS) and the following time through it will continue to create the directories.
My 10GB disk on my VirtualPC was nearly full to overflowing so I went looking on how to resize the virtual disk. There’s a free product that does this for you, but to quote an old song “I waved that thing all over the place, my boomrang won’t come back”. In fact I was using the app correctly but not understanding what the app actually did. This guide showed me the way.
It’s been a while since I posted, so what has been keeping me busy?
Work, it’s getting easier – I think I am getting into the VB6 mindset, but I still hate VBA with a passion. When is the nice .NET extension becoming available? Is it already, and could Reporting Services save our souls (not to mention our sanity)?
Space is coming along very slowly. Any time I sit down to work on it I have to spend about an hour refreshing my mind on what I have done – and I only have about 40 mins to do it in.
Had my birthday: One of my presents was an iPod from Mrs Bear – which gave me a lovely opportunity to hate iTunes all over again. This time I accidently deleted my play list, there is no undelete and then it synced it – wiping it. I’ve installed iTunes 9 but I don’t hold out any hope for them fixing all the problems with it. Another present is an ant farm – so along with my Sea Monkeys you could say I have Surf’n'Turf.
Another side effect of my birthday was my the choice of venues for a meal. Since I’ve always wanted to eat there I picked Kaminaki and had some of the nicest fish I have ever eaten, and definately the nicest pitta bread ever. All this and despite the grumblings of some of my friends.
…but not kissing. That would be like kissing a red-headed cousin or something.
As you do with anything programmig related you jump straight in at the deep end. In this case I wanted to take SVG input, and output a JPG, from PHP.
So taking a look around there wasn’t much to choose from:
- GD for PHP can take and output practically anything, but not SVG. And unfortunately its vector object model doesn’t seem to be as expressive as SVG is. There is GD::SVG, which is a perl module. Perl is enabled on the server (we have a horrible perl script for backing up the DB every hour but that is another post) but I’d rather not mess with a language I know nothing about.
- Call ImageMagick and have that do the conversion for us. While actually not that difficult, the cost of starting ImageMagick for each image is prohibitive – while you won’t get 300 people all trying to convert images at the same time, it is possible to get 10 or so clumped together.
- Call Batik to handle the conversion. I’ve used Batik and, if you ignore the first time cost of starting a JVM, it is wonderfully responsive. Unfortunately it is written in Java and Space is written PHP.
I know Java better than Perl, I decided to go with the Batik option. This means enabling the PHP-Java extension, which is simply editing the ini file to uncomment out the line that reads extension=php_java.dll.
In addition to that you need to edit the [Java] section of the ini file. And that is where things get problematic. If you read the scant information on installation you will find that the last known installation was with Java 1.4. I have Java 1.6.14. I found a pretty detailed instructions on the O’Reilly site for Java 1.2. Shouldn’t be too different should it? So I configured it as best I could and ran a simple test program:
<?php
ini_set(“display_errors”, “1″);
error_reporting(E_ALL);
$systemInfo = new Java(“java.lang.System”);
print “Total seconds since January 1, 1970: “.$systemInfo->currentTimeMillis();
print ” Java Version: “.$systemInfo->getProperty(“java.version”);
?>
The output was Fatal error: Unable to load Java Library C:\Program Files\Java\jdk1.6.0_14\jre\bin\client\jvm.dll, error: The specified module could not be found. in C:\Develop\projects\zerosumgames\php\map\htdocs\java.php on line 6 which is never pleasant. So I pushed and poked with the ini file settings – there are only 4 variables so there isn’t much to play with, but nothing would make it work.
So it sat on a back burner for a few days, nagging at the back of my mind: What if I used the JVM that they used themselves? That should work shouldn’t it? So I rooted around on Sun’s site and found what I was looking for: An archive of the all the old JDKs!
So I grabbed the last 1.2, 1.3 and 1.4 JDK’s (after reading very, very carefully Suns EOL agreement) and began by installing Java 1.2 and configuring the ini file:
java.home = "C:\Program Files\Java\jdk1.2.2\bin"
java.library = "C:\Program Files\Java\jdk1.2.2\jre\bin\classic\jvm.dll"
Bingo the output was Total seconds since January 1, 1970: 1248652639311 Java Version: 1.2.2.
Java1.3 went on – and worked too. This is exciting as Batik needs a Java 1.3 runtime (or compatible) to work: Total seconds since January 1, 1970: 1248652802706 Java Version: 1.3.1_20
What about Java 1.4? This gives Batik a speed increase and allows Batik to use additional features (though I don’t really care about mouse-wheels): Total seconds since January 1, 1970: 1248652920024 Java Version: 1.4.2_19
You beauty! So why doesn’t 1.6 work? Surely it is possible? I know the JVM has moved from the classic folder into a client and server folder, but the internals must surely be the same. I pointed at the correct location, but are there any other 1.6 JVMs beside the client and server ones? Well there is the one that exists in jre6 folder put that produces the same error as before.
And finally 1.5? Well I never tried that one – I have a working PHP-Java bridge – and now I need to move on to bigger & better things.
While researching this post I came across Image_Canvas which might do what I want it to and entirelly in PHP – no Java required. However the problem with the documentation is that it isn’t very thorough and your are pretty much on your own. If I get stuck with Java & Batick then I will probably take a closer look but until then…tada!
My employer of nearly 3 months is slowly moving to VB.NET. However a lot of their ‘legacy’ apps still need to be maintained and extended to support new methods, etc.
This involves VB6 and VBA. I was always in the position that VB6 was a mickey-mouse program for throwaway apps but not really suitable for real dev work – I was an elitist C++ programmer basically.
My view has shifted – you can really write large enterprise class apps in VB6. But one thing I can’t seem to shake off is the contempt the people who wrote VB6 IDE had for their users. Having used VC6 for a number of years you get used to certain things: Like if you start editing a file that isn’t checked out it will ask you if you want to start editing and then when checked out your caret is where you want it to be.
Not in VB6. You are informed that the file is locked. So you then have to right click on the file and manually check it out. But now the file closes itself and reopens with you looking at the top of the file.
Should I mention the 255 control limit? Who picked that as a number? (As an aside why is Excel 2003 limited to 1026 rows? Why 1026 and not 1024? Is that a typo?)
“Out of memory error”. I have 4gb in my machine. Why am I out of memory and why does that stop you from saving my last 15 minutes of careful debugging work? Why must you lose my break points?
And the mouse wheel doesn’t work.
This isn’t to say VC6 was all roses – far from it – but it makes you wonder if the VB6 team actually a) used it for anything b) gave a damn.
Found a solution to Eclipse problem – and it doesn’t involve Netbeans!
Get this…wait for it…You simply copy multiple version over the top of each other!
That’s right. Grab the latest J2EE version as that comes with all the bells and whistles that you will probably need. Extract it your program files directory. Then pop over to the PDT and grab the latest of that one too if you want to do PHP development. Now extract that over the top of your previous install and agree to all the messages. Start Eclipse and hey presto! you can now develop Java and PHP apps and have access to the database stuff you will also need!
Installation of eclipse add-ons to current installs is still shit.
Here’s a hint: WRITE A FUCKING INSTALLER THAN CAN INSTALL THE PREREQUISITES FOR ME. Don’t tell me that org.eclipse.ltk.core.refactoring is missing – install it for me. I don’t know where it is and it is certainly not in the DLTK section because I am trying to install the entire damn tree just to get rid of the error messages.
Older »
Next Page »