Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Wednesday, 28 January 2009

Banned Characters in Cookies in Tomcat

I was recently asked to look into why we had a problem with "[]" (square brackets) that were being passed to us as part of an affiliate id, eg: "SF_1234_[345]".


It seems we were saving the value to a cookie. This works fine if you check the cookie values in the browser. However, when we tried to pull the value in Tomcat, it got truncated to "SF_1234_"


After some painfull research... I finally found a page on the Tomcat buglist that clarifies the issue, and breaks down the RFCs to manageable information.


The upshot it quite simple.


The following characters should never be used in an unquoted cookie value.


()<>@,;:\\\"/[]?={} \t


While they will work on some systems, anything that implements the RFC properly will break. As happened to us with Tomcat.

Monday, 8 September 2008

Speed Testing Chrome for List Processing

What are we testing?

As Rich Internet Application development progresses, more and more developers are moving towards the functional programming capabilities of JavaScript.

First Order Functions, Closures, Macros and Lists are becoming a mainstream method of development.

When you can tell the computer how to do it, rather that listing what it needs to do, it becomes much easier to write a program and needs a lot less code.

Think recipe instead of precise instructions.

So how does Chrome compare to the other browsers when doing this?

What did we test?

I used JSTR to create a re-usable test of basic Functional programming.

The test creates a list(array) from a DOM collection, runs a filter on the list to identify the required elements, then performs an action on those elements remaining.

Follow this LINK to run the test for yourself.
Paste the link into another browser to test it on different systems.

The test is pretty basic, but it provide a nice demonstration of the capabilites of Chrome.

So how did they do?

Testing 1000 loops on a windows XP machine with 2Gb ram:
Testing used 10 repetitions for averaging.





Conclusions

It looks like the more modern browsers (FF3, Chrome, Safari) are now concentrating a great deal on Javascript performance. A very good piece of news for anyone developing Rich Internet Applications.

I must admit I was surprised by the performance of Safari on WindowsXP but it is nice to get surprises like this.

I had expected Chrome to out perform everything else and was a little disappointed to see otherwise. However, it is definetely a top notch Javascript system and I look forward to watching it develop.

This test does raise the issue that older versions of any browser will have significant differences in run-time speed for your application.

It looks like we will soon be back to the days of specifying a minumim compatible browser version, and the list will be quite short.

Request for Comments

If you have a different operating system or browser... can you please let me know how it performs in this test?
  1. Use the link above to launch JSTR, pre-loaded with the test..
  2. Clear the Console
  3. Press RUN

If you can leave a comment with the output, I will add it to the data collected.

Saturday, 16 August 2008

Performance Testing in JavaScript

Fast pages and quick load times are key factors to keeping visitors on your site.
If you make them wait, they will leave.

So the speed of your JavaScript applications is crucial.

Fortunately, it turns out that JavaScript applications are ripe for performance optimization.

This requires a strong testing framework... enter JSTR.

String Concatenation Performance

A simple example of the type of benefit available from performance testing can come from testing String concatenation.

Javascript allows the use of "+" to concatenate Strings, but it turns out to be rather inefficient if you are building a very big string, eg: dynamically building HTML from AJAX.

Instead, the use of a Array (wrapped to provide a StringBuffer object) provides a huge boost in performance.

[cc lang="javascript" tab_size="2" lines="40"]
function StringBuffer() {
this.buffer = [];
}

StringBuffer.prototype.append = function append(string) {
this.buffer.push(string);
return this;
};

StringBuffer.prototype.toString = function toString() {
return this.buffer.join("");
};

var buf = new StringBuffer();
buf.append("this is being added");
alert(buf.toString());
[/cc]

To test this against a normal concatenation:
Copy the String below, and then paste it into the IMPORT function in JSTR.

[cc lang="javascript" tab_size="2" lines="40"] jstr_StringBuffer=KHtuYW1lOiJTdHJpbmdCdWZmZXIiLCBkZXNjOiJUaGlzIHRlc3QgY29tcGFyZXMgdGhlIHNwZWVkIG9mIGJ1aWxkaW5nIGEgbGFyZ2Ugc3RyaW5nIGJ5IGNvbmNhdGVuYXRpbmcgc3RyaW5ncyBvciB1c2luZyBhIFN0cmluZ0J1ZmZlcihhIHdyYXBwZWQgYXJyYXkpLlxuQ29tcGFyZXMgYm90aCBsb25nIGFuZCBzaG9ydCBzdHJpbmcgYnVpbGRpbmcuXG4iLCBsb29wczoiMjAwMCIsIGl0ZXJhdGU6IjUiLCB0ZXN0czpbe25hbWU6InNob3J0U1RSIGNvbmNhdCIsIHNldHVwOiJhU3RyaW5nID0gXCJhZGRpbmcgXCI7XG5iU3RyaW5nID0gXCJTdGFydCBcIjsiLCBjb2RlOiJiU3RyaW5nICs9IGFTdHJpbmc7IiwgaW5jOnRydWV9LCB7bmFtZToibG9uZ1N0ciBjb25jYXQiLCBzZXR1cDoiY1N0cmluZyA9IFwiIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkIGFkZGVkICBMT05HXCI7XG5kU3RyaW5nID0gXCJTdGFydCBcIjsiLCBjb2RlOiJkU3RyaW5nICs9IGNTdHJpbmc7IiwgaW5jOnRydWV9LCB7bmFtZToic2hvcnRTdHIgU3RyaW5nQnVmZmVyIiwgc2V0dXA6ImVTdHJpbmcgPSBcIiBNb3JlXCI7XG5mU3RyaW5nID0gXCJTdGFydCBcIjtcblxuU3RyaW5nQnVmZmVyID0gZnVuY3Rpb24gKCkgeyBcbiAgIHRoaXMuYnVmZmVyID0gW107IFxuIH0gXG5cbiBTdHJpbmdCdWZmZXIucHJvdG90eXBlLmFwcGVuZCA9IGZ1bmN0aW9uIGFwcGVuZChzdHJpbmcpIHsgXG4gICB0aGlzLmJ1ZmZlci5wdXNoKHN0cmluZyk7IFxuICAgcmV0dXJuIHRoaXM7IFxuIH07IFxuXG4gU3RyaW5nQnVmZmVyLnByb3RvdHlwZS50b1N0cmluZyA9IGZ1bmN0aW9uIHRvU3RyaW5nKCkgeyBcbiAgIHJldHVybiB0aGlzLmJ1ZmZlci5qb2luKFwiXCIpOyBcbiB9OyBcblxuYnVmID0gbmV3IFN0cmluZ0J1ZmZlcigpO1xuYnVmLmFwcGVuZChmU3RyaW5nKTsiLCBjb2RlOiIgYnVmLmFwcGVuZChlU3RyaW5nKTtcblxuIiwgaW5jOnRydWV9LCB7bmFtZToibG9uZ1N0ciBTdHJpbmdCdWZmZXIiLCBzZXR1cDoiXG5oU3RyaW5nID0gXCJTdGFydCBcIjtcblxuYnVmMiA9IG5ldyBTdHJpbmdCdWZmZXIoKTtcbmJ1ZjIuYXBwZW5kKGhTdHJpbmcpOyIsIGNvZGU6ImJ1Zi5hcHBlbmQoY1N0cmluZyk7XG5cbiIsIGluYzp0cnVlfV0sIHZlcnNpb246MX0p [/cc]

Just to give you an idea...
StringBuffer is just faster for short strings
and about 50 times faster for long strings...!

My thanks to Pavel Simakov for this.

Thursday, 14 August 2008

A 'foolish' new tool for Javascript

I have been dying to shout about this...

instead I have been waiting very patiently...

BUT now it is time to SHOUT!

JSTR(Jester) is out of the box!

JSTR is the first 'Browser based' (ie:Cross-browser ):

  • Testing

  • Benchmarking

  • Optimization


tool for javascript.

With both import & export of Test-Sets, as well as auto-generated URLs, JSTR lets you easily share your code with everyone else, so they can try it for themselves.

Now, when you write about your new discovery, put a link to the test-set in your blog and let everyone else actually try it.

Find out about the new funny man for JavaScript.

Watch the video to learn more

Monday, 11 August 2008

Fixing an error building my first carbide.c++ project


I installed the Carbide.C++ IDE today, followed the tutorial instructions but got an error when I went to build the project.


Error: "bldmake returned with exit value = 2"


A little digging later and I found the solution...


Open a CMD prompt to the group folder of my project and run:


"bldmake bldfiles"


It told me that bldmake.pl was unable to be run...


Even though I have perl installed.


So now I know I have a problem with my perl install.


The simple fix was installing ActivePerl as originally suggested.


Now it works.

Secure your phpinfo from the bad people

I use the phpinfo() function a great deal, for basic information to advanced server administration checking, so I like to have it running on all my hosts.

Unfortunately this is a great hole in my security, as this information is a gold mine for the hackers out there.

I could simply remove the file when I am finished, or obfuscate the filename to make it difficult to find. But both of these would rather destroy the ease and simplicity I am looking for.

So, I decided to sort this out today.

The solution I am using is simple. Basic HTTP Auth.

Just enough to deter any would be hackers, as no-one can see how complicated my security is behind this shield. And, this should work on all PHP servers.

Here is the code.

[cc lang="php" tab_size="2" lines="40"]
function authenticate($uid,$pw) {
if (
!isset($_SERVER['PHP_AUTH_USER']) ||
!isset($_SERVER['PHP_AUTH_PW']) ||
$_SERVER['PHP_AUTH_USER'] != $uid ||
$_SERVER['PHP_AUTH_PW'] != $pw
){
header('WWW-Authenticate: Basic realm="Security Check"');
header('HTTP/1.0 401 Unauthorized');
echo "You must enter a valid login ID and password to access this resource\n";
exit;
}
if($pw == "password"){
echo "You must change the 'password' before you can have access to this...";
exit;
}
}
authenticate("admin","password");
phpinfo();
[/cc]

And a zipped version.

If you have a standard file with phpinfo() in it...
I highly suggest you start using this.

Saturday, 19 July 2008

Timing is everything

Here for your delight.

A simple way to track timing in Javascript.

[cc lang="php" tab_size="2" lines="40"]
// TIMESTAMP Function
function timestamp(){return (new Date()).valueOf();}

// TIMER Function, wraps timing arround function call
function timer(f){
var t1 = timestamp();
for(var i = 0; i < 1000; i++){
f();
}
var t2 = timestamp();
return t2-t1;
}

// The function to test
var testFunc = function(){
var v = (window["DoYouBelieveInSpeedReading"])?true,false;
}
// Now call the timer
alert("time taken="+(timer(testFunc)/1000) + " seconds" );
[/cc]

The core is converting a date object into milliseconds: date.getValueOf(). This will give you a Long of the number of millseconds since 1970.

so var t1 = timestamp(); will store the start time.

Then do the thing you want to test... I would suggest a very large number of times... I needed to make it 100,000 for the Regex below.

and var t2 = timestamp(); becomes the end time.

Now totalTimeTaken = t2 -t1; in millseconds.

Finally time = totalTimeTaken/1000; to get the number of seconds that the function took.

I wrapped it all up in a function timer...

which can be called by
alert("time taken="+timer(myFunc)/1000);


I recently used this to test String matching functions, to find that indexOf is blisteringly fast, followed closely by pattern.test, and then way behind that String.match .

For 100,000 repetitions:
String.match: 1300ms
pattern.test: 360ms
String.indexOf: 180ms

So the moral of todays story is...


  • use indexOf if you can


  • pattern.test if you must have REGEX or more than one match


  • and AVOID String.match if you can


Just remember that premature optimization is a bad thing...

Happy Testing...!

Monday, 5 May 2008

onDOMLoad: Faster javascript for faster pages with a cross browser version of DOMContentLoaded

I have been quite entertained by all the recent talk about page loading speeds, optimization and profiling (eg: YSlow), so I decided to wrap up one of my functions into a usable form for you to dissect.


I call it, onDOMLoad.


Go and have a look at the demo of onDOMLoad.


onDOMLoad is a wrapper to the code suggested by Dean Edwards,Matthias Miller & John Resig. It is cross-browser capable and I hope pretty easy to understand.


Download


The Javascript is available to download here and here in minified form.


I have fully documented the uncompressed version


I like easily readable code, as I will often come back to it 6 months or a year later, and I hate spending hours working out how my own code runs.


Why use my version


onDOMLoad does vary from the few other solutions out there. It is very small, 1K minified. It works nicely in co-operation with the window.onload function. But most importantly, onDOMLoad allows multiple functions to be specified.


Future stuff


I have seen some great possible improvements, like Hedger Wangs implementation of Diego Perinis IE readyState check. I will post more updates here when I think they are ready.

Friday, 25 April 2008

Better Task control on Windows (NT/XP/Vista)

I have been using ProcessExplorer since long before Microsoft bought out SysInternals, since long long before that too, and I have found it incredibly useful.

e.g.: checking to see if my new application has a memory leak etc..

Now I have just discovered it has an even better toy-set built into it.

If you have never tried it, download and install ProcessExplorer.
The run it.

You will get a view like task manager, but with much better granularity in the processes.


Next comes the standard view:

select View > System Information



Now, for the "Piece de Resistance"...

Goto Options > Replace Task Manager.


Now try CTRL-ALT-DELETE...

Windows Task Manager has been replaced by the more powerful ProcessExplorer.

Friday, 14 March 2008

Scaleable unit testing and continuous integration in an agile team using GIT

I like agile development, it works, but it does need some pretty clear guide lines and rules. It also needs very good testing systems to ensure no developer breaks anyones elses code.


Up until now, I have been using the same tools as everyone else.


SVN, perforce, CVS, etc... we all know this type of source control management system.


We all know how these systems work.


I take a task, I write my unit test, I make sure it fails, then I write my code until the test passes and all other tests pass as well. Then I can commit my code.


When I commit my code, the continuous integration system kicks in, re-builds the application, runs all the units tests, and then the functional tests.


It is really cool. Especially if you have been developing for some time and remember 'the older days'.


The 'Old Days' when we worked alone were much easier, but we need teams now, and we must have ways to manage and control working together.


However, about half the time, when I check in my code, I break something, and the continuous integration system bleeps loudly and displays an embarrassing photo of me.


So now I have to fix the problem. And that's ok.


However, with any decent sized team, you now have a single point of failure.


The build server itself.


Everything merges at this point, and many regression mistakes are only discovered when the code is checked in. This means that the primary development codebase is now broken.


And this tends to happen often, every day.
A right pain if you are running a tight release cycle.
There is no way you can pass broken code to QA.


It gets even worse, when tasks are larger, the changed code coverage is large, and it has been quite a few days since it was checked out.


Now, it is possible, and good practice, to do a checkout before checking in. But how many times have I seen this forgotten in the rush to get a release ready.


So that's the problem.


 


The solution that I have recently converted to, is GIT.


This distributed SCM, at first seems rather primitive, but on further examination, this primitive nature hides a great deal of raw power.


Distributed SCM means every developer can commit to their own repository, so they can roll-back their own code if they go in the wrong direction.


Distributed SCM also requires much better branching and merging.


It is simple to create a distributed branch for a micro-project team, each developer can now clone this branch, work locally, commit locally and then check their code back into the branch.


The micro-project team leader can now do code review, unit testing and functional testing, before committing the completed project back into the primary codebase.


So now, at any point in time, you can take a copy of the main codebase and pass it to QA for testing and release. Knowing for certain that only working code ever makes it into the this codebase.


This allows you to move to a fast release cycle. A new feature has been added. Now you can test and release knowing everything will work.


In effect, you have moved the larger scale unit/functional/regression testing further back into the development process.


What you also managed to achieve, is secure asynchronous micro-project development, so each micro-project team can now work independently while still being agile.


And all the effort ends up in a single unified codebase that works!


This is the secret to scalability in agile development.


 


The title of this little note does promise to let you in on how to integrate the unit and functional testing of continuous integration into GIT.


I love this, it is so simple.


Because GIT is so primitive, it runs scripts, that actually sit in the repository itself.


All you need to do, is edit the scripts to add your testing.


Even better, you can set it up to run pre or post any command.


e.g.: run unit tests post-commit.
e.g.: run functional testing post-merge


etc...


With a little thought, you can have an entire workflow mapped out that will only allow unit tested, function tested, regression tested and codebase merged micro-projects to be committed to the primary codebase.


As far as I can see... this is as close to the holy grail as we have ever been.


Have fun.

Wednesday, 12 March 2008

Autocomplete using tab in windows command line prompt

One of my bug-bears for years has been the lack of auto-completing in the windows CMD promt.


I have always used *nix tools like cygwin to provide this.


Now I find out that this has been built in for years....


It was simply disabled.


The fix is very easy. A Registry edit:


HKEY_CURRENT_USER/Software/Microsoft/Command Processor/CompletionChar= 9


Thats it.


This is a microsoft fix. But why did they fail to make it standard...?


FYI: here is the registry export of what it looks like when done.


=============================================


Windows Registry Editor Version 5.00


[HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
"CompletionChar"=dword:00000009
"DefaultColor"=dword:00000000
"EnableExtensions"=dword:00000001

Saturday, 1 March 2008

SSH Tunneling for mySQL GUI tools from Windows to a production Linux server

I thought I might add another simple tip.

When I am messing around with a wesite... I spend a lot of my time creating, editing and manipulating the databases.

Any commercial Hosting Service, worth their salt, will block port 3306 to mysql.
It is a simple and basic security measure, that must be left in place.

So I often have to use the command line tools to do all my work. This is fine for most things. But when I am editing data, it can be a real pig and slows me down.

I want to be using a GUI tool.

So how... do I use the availble GUI tools, when their communications are blocked?

Simple, I use PuTTY to create a local tunnel through the firewall to the server.

I am going to assume you already have PuTTY and are used to using it.
Otherwise my first suggestion is learn PuTTY.



How To do it...



1: Create a connection in PuTTY to your server as normal.

  • HostName, A on fig.
  • Port(22/SSH), B on fig.
  • Give it a name, C on fig.
  • Click save, D on fig.

2. Goto the Connection->SSH->Tunnels option at the bottom of options of the left. E on fig.



3. Make sure the local and Auto radio buttons are selected. F on Fig.

4. Enter the Source port. G on fig. This is the listener port you will connect to on your local machine. If you have mySQL running locally on 3306, then I suggest 3307. Continue incrementing the port number for each server you add.

5. Enter a destination HOSTNAME:PORT. H on Fig.This is the destination FROM the remote server, so if you are SSHing directly into the mySQL server, the hostname needs to be localhost:3306 or 127.0.0.1:3306.

6. Click Add. I on Fig.



7. Check that your tunnel is now shown in the list box. J on fig. The info displayed should show "L3307" which is localhost port 3307, and localhost:3306, which is the destination host & port.

7. Remember to save your setting before you open your connection. D on Fig.

8. Start you PuTTY connection, (Open, K on Fig) and log in as normal...

9. Now Start the mySQL GUI, I am using the MySQLQueryBrowser.





10. Enter the Server Host. L on fig. This should be localhost , as we are connecting to putty.

11. Enter the Port. M on fig. This is our local putty listening port, in this case 3307 .

12. Enter your MySQL Username and Password. N & O on fig.

13. Click OK. P on fig.

That's it...

You should now be connected to MySQL.

Finally

Set up a batch file to create the PuTTY connection.

Put this in a batch file. Obviously change the location to point to your install of Putty.

c:\some\dir\with\putty\in\it\putty.exe -load mysqltunnel

You can then of course, create a keyboard shortcut to the batch file.



Errors

If you get a user not allowed error, then you need to check how you log in to mysql using the command line on the server. This will affect your tunneling setting.



If you get a Can't Connect error, you have forgotten to start the putty session first...

Friday, 29 February 2008

Getting KCacheGrind for xDebug on Windows with KDE

As I am playing around with xDebug, I need a profile file GUI. I tried WinCacheGrind, but as it is two years out of date, I wished to try KCacheGrind as well.


So, how do you install a Linux KDE application on windowsXP?


As it turns out, quite easily.


Here's how...


1. download the installer to C:\KDE4 from here:
http://download.cegit.de/kde-windows/installer/


2. Run the installer
2.1 Choose you packages, I choose all of them.
(NOTE: KCacheGrind needs Kdesdk package)


3. Add "C:\KDE4\lib" to the %PATH%
3.1. Start > Control Panel > System > Advanced > Environment Variables, Select PATH, click [edit]..


4. Create env variable KDEDIRS with value "C:\KDE4"
4.1 Start > Control Panel > System > Advanced > Environment Variables, click [New]


5. Do this... at a command prompt
(temporarily needed, check KDE link below to verify)
cd C:\KDE4
C:\KDE4> bin\update-mime-database C:\KDE4\share\mime
C:\KDE4> bin\kbuildsycoca4 --noincremental


THAT'S IT.... ALL DONE. How quick was that...


6. Testing...
run c:\KDE4\bin\assistant.exe to test a QT program.


Now run KCACHEGRIND..
run c:\KDE4\bin\kcachegrind.exe



These instruction are a summary of the KDE on Windows project

Simple tricks for Windows Programming automation using batch files

I thought I might mention a few of the simple tricks I use when I am developing...


Keyboard assigned Shortcuts


I often need to restart apache very regularly, ie: every other minute.


This is a real bore when I have to find either a GUI or and command prompt. So I set up shortcuts in windows..


I create batch files to do what ever I want, create a shortcut to the batch file and then assign key strokes to them.


ie:


CTRL+SHIFT+F9 => start apache service


CTRL+SHIFT+F10 => stop apache service


Then all I need to do is keep an eye on the Apache Monitor.


NOTE: You must put the shortcuts in a folder in your Start menu... otherwise they will never run when you hit the assigned keys.


While it seems simple, I have noticed how few people truly automate the tasks they perform again and again and again....


Do it.
This alone saves me hours every week when I have my head in code.


 


Automating a task with Batch file and viewing the results


Use set /p varName="ask for data" then use the variable to call the correct thing.


You can also use this to stop the box from closing, so you can see the results, put this at the end: set /P Done="Press return to close."


Here is an example for an ant build:


@echo off
set /P TARGET="Please enter Target(clean,compile,build,run,javadoc):"
CMD /C ant %TARGET%
echo -------------------------------------------
set /P Done="Press return to close."
:End

Wednesday, 27 February 2008

How Microsoft caused apache & php_mysql.dll to fail...using VISTA (dwmApi.dll)

The Background

Last week I discovered I had quite a few viruses etc.. on my laptop. So I needed to reformat the hard-drive and re-install WindowsXP before I started my new job.

Now before I did all this, I made sure I had a complete back-up of everything off the machine. NB: this is my main development machine... it is a very nice HP laptop.

Before I did this, I had a very nice fully working development environment, i.e.: Cygwin, IDEs, Java VM (1.4/1.5/1.6), mySQL, all my tools, compilers, disassemblers, apache 2, php 5, remote access etc...

So WHY.... did PHP5 refuse to work when I re-installed it today....?!!!

Well, sit back and I will tell you a story of detective work and a serious mistake that seems to have got through to cause me and others, a huge problem.

The Story

I needed to re-install a php environment today, so I could test the environment I am recommending to my current client.

So I copied everything back on my machine, ran a quick command line PHP test (which worked) and tried to start apache.... and it FAILED... with:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\_dev\\php5\\ext\\php_mysql.dll'



Considering it had worked on the command line, I thought this was a little strange. But config issues are normal, so... it needed a little work. I am quite used to this, having done it far too many time over too many years.

Over the next FOUR hours... I re-installed apache twice, PHP twice, rebooted a few times and re-ran the configuration at least four times.
NONE OF IT WORKED...

I still had php alone working fine, but php through apache failing... with a message that simply made no sense.

So now I started to get frustrated and went hunting on google..

The Chase

After a while, I found a few forum threads that talked about using Dependency Walker to see what php_mysql.dll actually needed, and why it should be failing.. So I downloaded the software and checked it out.

Dependency Walker immediately reported a failure in the dependencies. DwmAPI.dll.

Ok, that seems a little odd...

So, off I went back to google to see what I could find out.

It turns out that DwmAPI.dll is a Desktop Windows Manager API... and after a load more research I found out... for Windows VISTA...!!!!

Now I was pissed.

The Fury

Some idiot had compiled a dependency to the wrong operating system into one of my tools.

At least I now had a culprit... all I had to do was track down the criminal.

AND GUESS WHAT.... it was Internet Explorer 7.



Look at the tree... DwmAPI.dll is a dependency of IEFRAME.dll, which I recently gained, when I decided to bite the bullet and install IE7.

What a £$%&ing mistake that was...

So now I was even more pissed off.

I had spent hours debugging to find an error that should never have existed from the people who created the operating system I depended on.

At least I should be able to fix it.

The Fix

Well, on that point I can at least put one happy note forward.

IE7 uninstalled in 5 minutes... I rebooted... I started apache... I checked the error log files and..... IT WORKED...!



And just to prove a point...
Here is the Dependency Walker result after I had un-installed IE7.





And the moral of this story.....

IE7, PHP, Apache and the word NOT features quite heavily.

... you work it out. :->



But... this has been enough of a serious headache to make me think about ditching windows for a *nix machine. Either OSx or Linux.

Considering I have been a windows(less than fanatical) user for quite a while, mainly due to client pressure... it is ironic that the systems I use to develop and now being pushed off machines that keep me using their software...

To Microsoft:
VERY POOR SHOW...
You have created a bug that makes the primary web development environment crash. And you have done it with your browser.. something the same web developers really need to install for testing.
I AM VERY DISAPPOINTED.
Were I a more paranoid type... I would be suggesting this was deliberate.
FIX IT. NOW.

Wednesday, 20 February 2008

Why Git

I suppose the first thing you should do is watch the videos.


Here is Linus Torvalds explains GIT philosophy to googleTech:
[video]http://www.youtube.com/v/4XpnKHJAok8&rel=1[/video]


And Randal Schwartz with more details about using GIT
[video]http://www.youtube.com/watch?v=8dhZ9BXQgc4[/video]


You should now know enough to realise why GIT....


If you are still in egypt... de nile... then here are some thinking points.


these are coming as soon as I organise my thinking....

Thursday, 19 July 2007

Finding a working PHP eBay API...

If you are trying to understand the eBay communication APIs, then you have commited yourself to a BIG leaning curve.


As I have walked the walk already(I worked for eBay), I hope my experiences can help those who follow me up this monumental path..


All eBay programming APIs are designed to talk to the exposed eBay services. These services are constantly evolving. As they evolve, older versions become obsolete.


These older version are usually supported for about 14 months after a new version is created, however, they will eventually fall off the supported list and start to cause API call failure.


So to make sure you can design applications that talk correctly to the eBay services, you need an uptodate API.


FYI: you will need to keep your API up-to-date as well duing the lifetime of your application. As the APIs are really a communication layer, you should be ok calling them directly, rather than implementing your own abstraction layer on top.


So far we have managed to find one fully functional PHP API.
You can get this from IN TRADE SYS at this url:
http://www.intradesys.com/index.php?id=ebay_at_for_php&L=1.


These guys seem to be totally up to date with the current version of the eBay services platform. They also provide a few samples and some basic documentation...


Definetely Recomended if you are looking to develope eBay applications with PHP.