graham.reeds/

Java and PHP sitting in a tree…

July 27th, 2009 :: graham.reeds
Categories: Galaxy ::Leisure ::Life ::Programming

…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:

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!

1 comment.

VB6 and VBA

June 25th, 2009 :: graham.reeds
Categories: Life ::Misc ::Programming ::Work

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.

0 comments.

Solution to Eclipse

June 25th, 2009 :: graham.reeds
Categories: Eclipse ::Leisure ::Life ::Programming

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!

0 comments.

eclipse add-ons

May 27th, 2009 :: graham.reeds
Categories: Eclipse ::Leisure ::Life ::Programming

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.

0 comments.

Onwards and upwards

April 25th, 2009 :: graham.reeds
Categories: Life ::Misc ::Programming ::Work

Life continues.

Slowly getting used to the way my new employer does things. It’s a little more strict than previous places but this is the largest organisation that I’ve worked for under one roof. Using VB after a break of 5 years is a real pain but apparently it is only going to be for a short time. There are plans to rewrite (why do I cringe when I hear that word?) the apps in VB.NET. Oh joy of joys. Between now and then I can try and wheedle my way into getting C# used. Meanwhile I am learning to swim again by being thrown in at the deep end. As a plus I don’t have to get up/leave so early and I get home an hour earlier too.

While this is going on I am still working on Space. Or rather trying to get Space to work on a local VM. There is little point in pushing forward with changes when the changes are so hard to implement, and the only way to test is on a live system. That’s just folly: If something breaks then we start to lose real money. Better to make a VM and play safely in there.

That means learning Linux. Which I have now installed a dozen times. Even the book on the subject doesn’t work the way it is supposed to. Fortunately I am savvy enough to figure out my way around where the book misses out one of the hyphens in –dport.

With learning comes confidence so I went and reinstalled selecting server as the install option and doing everything manually. However with Virtual PC as my VM I kept getting the ‘i8253 too high – resetting’ all the time which made working in Vim a nightmare. So I decided to give VirtualBox a try.

Oh my God! How fast is it compared to Virtual PC!?. It just rips along. The boot is a blur, the install of the OS is twice as quick and UI is feels more responsive. As a plus I haven’t seen the i8253 bug yet.

0 comments.

Clean again

April 10th, 2009 :: graham.reeds
Categories: Life ::Misc ::Programming ::Work

Just finished my first week back in work and though it wasn’t a full week, does give one some confidence once again.

However, the job isn’t my ideal one – working with mess that is classic VB (could be worse might be PHP) – but it is a job all the same.

0 comments.

Javascript development

April 4th, 2009 :: graham.reeds
Categories: Leisure ::Life ::Programming ::Web

Write code.

Test in Firefox: Works. Test in Chrome: Works. Test in IE: Fails.

Edit code.

Test in IE: Fails.

Edit some more.

Test in IE: Works. Test in FireFox: Fails.

Tweak a few more lines.

Test in IE: Fails. Test in FireFox: Fails. Test in Chrome: Fails.

GIVE ME SOME STANDARDS!!!

0 comments.

So where is the background?

February 28th, 2009 :: graham.reeds
Categories: Leisure ::Life ::Programming ::Web

I’ve just run into one of jQuery’s thornier issues.

While creating a map viewer for the S:GTC I found my code worked in FireFox and Chrome perfectly but refused to budge in IE7. Some of you may know that the map in Space currently only works correctly in IE6 – not good when most of the planet uses something other than. I thought with standards being pretty much standard these days and the bits that are not yet standardised being abstracted away by jQuery (and the ilk) I thought it would be plain sailing.

Until I tried to get the value of background-position. Turns out that IE doesn’t support background-position for getters but supports background-position-x (and -y obviously). So you can suppose that concatenating the strings would get us to the point where we want to be. Yes? No.

In my humble program I need values. Pixel values. I don’t want em, %ages and I certainly don’t want it as a string. What use is that to me? Okay I can create a big switch statement for top, bottom, left, and right but what about center? To cope with that I’d have to check ahead to see what it is and then convert accordingly. So much for ‘Write less, do more’.

There is a whole raft of information on the Net about this very issue and I’ve ran into it after a couple of weeks but amazingly no one has offered a viable solution. There’s a handy test to see it in action. View it in your favourite browser and then check it out in IEx. That’s right Microsoft hasn’t fixed IE8.

Personally I am so frustrated with the whole situation that I feel like browser-sniffing for IE and banning them outright – not just inform them that they have a substandard browser.  If all devs did that then MS would have no option but to fix it. Sod backwards compatibility – if you rely on a bug to work then expect the fix to ‘break’ your mark up. Eventually standards really would be standard, people would learn to write compliant code and dirty hacks be a thing of the past.

1 comment.

The second worst game show on Earth

February 11th, 2009 :: graham.reeds
Categories: Leisure ::Life ::Misc ::Work

Being off for a week I’ve experienced the dubious pleasure of watching Golden Balls, the second worst game show on Earth – the worst being Deal or No Deal.

The premise for Golden Balls is similar to Deal or No Deal in so far as much as you don’t have much say in the proceedings.

There’s a large amount of balls, all of which are golden, in a large rotating drum. These have a monetary value attached to them from £10 to £2,5000. They have a Clamshell/catch affair so you can open them and read the value, but they won’t open at by accident. 12 of these balls are released and roll down into another spinning drum into which a lovely assistant puts 4 ‘killer’ balls.  These random balls are then released down chutes to each player. They then position them how they choose on a 2-tiered rack and then open the front tiered balls for the world to see. Only they can see what they have.

So no player interaction so far. Now the contestants get to ‘play’. The idea for the players to discuss what balls they have and bluff about what they have. After the bluffing they decide which person to drop. This bluffing is pointless. You have no way of telling whether they are lying or telling the truth. The only logically way is to total up the values on show and make your choice based on that. Obviously killers override all other values and must be removed.

So now you have 3 players. The remaining balls are returned to the spinning drum. An additional 2 value balls are added as well as a killer ball. So they now each have 5 balls instead of 4. Again they display the front 2 balls and try to bluff about what they have on the back shelf. You have a little more information than before – you know what balls were there before. However you don’t know who has them. The best you can do is save the player with the most and drop the player with the least.

Now you have the head-to-head. This is where the true intelligence of the players shines through. The remaining balls are closed and placed at random on a field. The contestants pick one ball to bin and one ball to win. The balls are opened to reveal what the contestants would of won – like that makes a difference. If you get a killer, the value is divided by 10. So if you have 10,000 on the board and get a killer your prize fund is now 1,000. Another killer would reduce it to 100.  So killers at the start doesn’t make much difference.

But where does the player intelligence (or lack thereof) come into this? The players were going with their feelings whether a ball felt right or not. Eh? It’s a featureless golden ball – it looks like every other ball on the table. How can it feel of anything?

Okay. Now fast forward to the they end game. You have a prize fund. It can be of any amount. You have to decide whether to split (S) or steal (K). Your opponent has the same choice. There are 4 possible patterns SS, SK, KS, KK. What are the outcomes (with you first):

Recognise this? It’s a bastardized version of the prisoners dilemma. However, this version of game theory it rewards for stealing.

The correct way of doing this is to tell the opponent you are going to steal and offer them a fixed value of less than 50%. Point out that they have no chance of winning any money unless they accept your offer. Tell them what they can buy with the money. If they point out you’d be getting more, point out that my winning is irrelevant. They will be getting zero or the amount you have offered. Always make it about them. And steal.

Nice guys finish last.

0 comments.

jQuery for Dummies

February 9th, 2009 :: graham.reeds
Categories: Programming ::Web

In an attempt to create cross-browser support for S:GTC I thought that learning jQuery would help in making the map work in more than IE6. So instead of getting frustrated at the abysmal PHP code I have to work with I decided to sit down with jQuery and de-stress.

Or so I thought.

I did what anyone does: Skim read the documentation and immeadiately attempt something they have already done in another language. The project I attempt was the map viewer I created in GWT which was based upon the one in Pragmatic Ajax. The Pragmatic Ajax code was simple in it’s design, but refused to work in FF if you enabled any DocType. My GWT version worked with any DocType (admittedly I only tried with XHTML 1.0 Trans, but it should of worked with any of the HTML 4.01 DocTypes.) and also supported scroll wheel zooming to boot.

So with something to aim towards, progress should of been quick. Unfortunately things didn’t go to plan. I scaled back. That didn’t work so I read the docs closely. I then scaled back even further. I now have the same code as the docs. Still it doesn’t work.

Gah.  I feel like giving up and stacking shelves for a living.  Why doesn’t it work!?!

0 comments.

« Previous PageOlder » « NewerNext Page »