Saturday, June 28, 2008
Problems with AVG 8
Last week I upgraded to version 8 of the AVG Free suite and that’s where the problems started. Things were a little slow for a bit and the whole system seems a little buggy. Then on Saturday the whole thing fell over.
Shortly after booting up my PC would seize up and would require a hard boot to get it back going again. My first suspicion was AVG, and it turned out I was right. I tried turning it off, but every time I clicked on the tray icon to try to access the program using menus, it locked my PC up, and you guessed it, I had to reboot it.
I tried to uninstall it, but that locked it up too. I also tried killing the AVG processes using Task Manager, with the same results. So I was a bit stuck. Short of deleting the folder with the program in I had limited options as I generally had about 1 – 2 minutes of operating time before the PC had to be rebooted. And that was if I didn’t touch AVG.
So I tried to stop it from stating up on a reboot.
In the Start menu I clicked on Run and typed in ‘msconfg’. This brought up the config dialog box. On the Startup tab I unchecked avgTray. Then I saved the changes and rebooted.
This time AVG didn’t start up and I was able to uninstall it, and get my PC back to good running order. Whew!
There is apparently a way to install version 8 without it giving you such a headache, but I haven’t had a go at it yet. When / if I do I’ll let you know how it goes.
Friday, June 13, 2008
Portable applications running from a USB drive
I went to Portable Apps.com and downloaded the application suite and platform. I installed everything into a folder, aptly named – USB and then tried out the various applications to see how they worked.
I was very impressed. Pretty much everything worked fine. The things that needed a bit of work were XAMPP, and Base. (I’ll explain a bit about them later.)
Then I copied the contents of the USB folder onto a 1gig USB drive. It took up about 600mb with all the extra apps I had installed. Then I plugged the drive into my laptop and away I went. All the programs worked fine. This is exactly what I was looking for!!
So what do you get? Quite a lot really.
- Firefox – web browser
- Thunderbird – email client
- Sunbird – calendar
- ClamWin – anti-virus
- Pidgin – instant messenger
- Sumatra – a PDF reader
- KeePass – a password manager
- Sudoku – game
- Mines – game
- CoolPlayer – an audio player
- OpenOfiice – an office application suite
- Writer – word processor
- Calc – spreadsheet
- Impress – presentation application (like PowerPoint)
- Draw – a drawing program
- Base – a database application like Access
I also added:
- FileZilla – FPT client
- GIMP – graphics manipulation application
- Notepad++ - text editor that does syntax highlighting
- VLC Media Player – media player for music and video
- XAMPP – a web-server suite including:
- Apache2
- MySQL5
- PHP5
As I said, for the most part the apps work great. When you plug the USB drive in, if you’ve got the autorun enabled you’ll get the usual window popping up asking you what you want to do. Running the StartPortableApps.exe should appear as the selected option. If not you can navigate to the .exe file and double click it to start the apps menu.
Then you just choose the apps you want to run from the menu. Easy really.
You can surf the web, create documents etc and save them all on the USB drive. When you get home, to work, wherever you can just plug the drive in and access all your files no problem. If you want to copy and paste them to your hard drive, that’s just a normal operation as you would from any removable drive. So there are no nasty hooks that say you can only access the files using the applications on the drive.
Ok so onto the problems I encountered, and their solutions.
Firstly Base, the database utility.
This needs a Java runtime environment which is not part of the download. But no problem. Just go to Sun.com and download the latest JRE. Then put it into the \PortableApps\OpenOfficePortable\App\Java folder and you’re sweet.
Setting up XAMPP took a bit more work.
The main problem is that when you first install it the directory paths are put in as absolute URLs. This works fine until you try to move to a different machine.
So after you install it go to the following files and change the paths as described below. Then it should work fine.
For Apache web server
\PortableApps\xampp\apache\conf\httpd.conf
All the files in the \PortableApps\xampp\apache\conf\extra folder
Find all the places where the URLs are expressed, e.g.
ServerRoot "C:/USB/PortableApps/xampp/apache"
And change it to:
ServerRoot "/PortableApps/xampp/apache"
There are quite a few of them.
This will make it insert the drive letter that corresponds to the location of the apache .exe file, effectively mapping the URLs to use the drive letter assigned to the USB drive.
PHP
Look in the php.ini file in \PortableApps\xampp\apache\bin and remove the drive letter in the URLs for importing packages etc.
MySQL – database sever
This one too uses absolute URLs in the \PortableApps\xampp\mysql\bin\my file.
The only way I could find to edit this file was to open Notepad and then drag the file into it.
As before go through and remove the drive letter.
Once you’ve done that try starting the servers using the batch files in \PortableApps\xampp
apache_start.bat to start the webserver, and apache_stop.bat to stop it.
This will inform you of any errors. If it just says Apache is starting and then seems to hang, that’s a good thing.
Open Task Manager and look under the running processes to see if Apache is listed. It will probably be listed twice. If it is in there, then it is running.
Do the same with mysql_start.bat. If it says it is running and waiting for connections then you’re good to go.
If you’ve missed a URL then it will display an error in the command window. Simply go to the file and change the URL so it does not have a drive letter specified.
Open a web browser (try using the portable Firefox) and type 127.0.0.1 or localhost into the address bar. You should get the XAMPP welcome page. Click on the phpinfo() link to see the settings for PHP. Click on the CD Collection link to check that the database is working. If you get three records displayed, then it is working fine.
If found that clicking on the XAMPP_start menu item in the Portable Apps menu sometimes seemed to take quite a while to start things up, so be a little paitent.
One other problem I encountered is if you already have Apache (or another webserver) running or you’ve got MySQL running, then the portable apps won’t work. So the solution is to make sure the other apps are not running. Check in the processes list in the Task Manager to make sure they are not running before you start your portable webserver.
The possibilities for this are endless!!
My next task is to get my MySQL Interface software (that I wrote) and port it to run in the Portable Apps environment. It should not be too difficult to do given that it is a Java app the does not use absolute URLs.
Well I hope this has been helpful. I’m off now for a well deserved glass of wine.
Sunday, June 8, 2008
XmlHttp ajax style code to call a script without reloading the page
style requests.
I’m using it more and more for all sorts of stuff. I’ve found it to be pretty bomb-proof so far. It’s been tested in Firefox and IE, and I think Safari also, and it always works.
I’d love to credit someone for it, but I have no idea where I got it from. (it was quite a long time ago)
So here’s how it works…
First of all you need the to build the object to run the request.
That’s done with the xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); bits. Depending on the browser, it makes an ActiveXObject or an new XMLHttpRequest();
Then you specify the script you want to execute. I’ve found it works best if the script is in the same folder as the calling page.
The xmlHttp.onreadystatechange = whatHappened; line specifies the function to call when the script has executed.
Note you don’t put the ‘()’ after it yet.
Then you open the connection - xmlHttp.open("POST", url, true); you can specify GET or POST to send your info into the script. I use POST pretty much all the time.
Then set up the parameter list to send to the script. It’s just like setting up the parameters to send through as GET variables – parameterName=value.
You then set up the headers to send, and then send the request.
In the whatHappened() function (which you can call whatever you want) you test for the ‘readyState’. 4 means that the script has finished executing and has returned.
Then you can do whatever you want with the returned data.
To return from a PHP script make sure you use an echo statement, not a return statement.
Because you’re using an echo the returned data is in the form of a string. You can set up the format of the string so that it is delimited, making it easy to split into variable to use in the Javascript function.
Try it yourself. You’ll find this is a handy little script to have in your arsenal.
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != "undefined") {
xmlHttp = new XMLHttpRequest();
}
// Build the URL to connect to
var url = "scriptToExecute.php";
xmlHttp.onreadystatechange = whatHappened;
// Open a connection to the server
xmlHttp.open("POST", url, true);
//get values from the form
var parameters = "parameterName=" + encodeURI( parameterValue);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", parameters.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(parameters);
return false;
}
function whatHappened(){
if(xmlHttp.readyState==4){
// do stuff
}
}
Sunday, June 1, 2008
Learning something new
Unfortunately what I had to integrate was not a standard Joomla template. It had some changed functionality and layouts etc. because the HTML and PHP are mixed up across so many different files in so many different places, it was pretty much impossible to do it the Joomla way. So I didn’t.. sort of.
But that’s not what this blog is about. If you have worked with Joomla code you will already know what a nightmare it is, and you don’t need me to tell you that trying to do anything non-standard is just like trying to get Catherine Zeta Jones to ask me out on a date – extremely difficult, but may be possible if I can just figure out how…
No, this is about learning something new.
Our front end developer, who made the templates, also changed the Javascript that generates the popups. His popups contained different information from the standard ones and presented it in a nicer way. It was also more efficient and less buggy.
Fair enough. So I slogged through shoehorning the templates into Joomla, sort of. But when it came to integrating the Javascript I was stumped. Where were the onmouseover calls?
There was no Javascript at all in the templates. But I had working copies of them so I knew it worked. In the end I had to Skype the developer and ask him how he did it.
What he had done was register events on page load, using a function call onLoad() in the Body tag to register event handlers on the various element on the page that required them. I’d not seen this done before.
But when I looked at what he had done and followed the logic of it, it made a lot of sense. All the Javascript is in the .js file, all the HTML is in the HTML file, all the CSS is in the CSS file and all the PHP is in the PHP file. With due care and consideration it would be trivially easy to change any part of the system without breaking the rest of it.
This really peaked my interest, especially since I was not enjoying working in Joomla and was looking for some way to put a silver lining in the whole miserable experience.
Now I don’t claim to be a Javascript guru, or even adept, but I do know how to write good code, and I’m always happy to learn new and better ways of doing things. That’s one of the things I really like about programming; there is always something new to learn, and there is always a better way to do what you’re doing now.
In my old job I was constantly being told not to re-invent the wheel. But that’s what we do. We look for better ways to do things. Smarter, faster, more robust, more secure… better. And it doesn’t matter where or how that knowledge comes to us, we can accept it, shape it, improve it. That’s why we are not travelling on wooden wheels with iron rims. Some smart-arse sod re-invented the wheel and put a tire on it.
I have always maintained the all learning s good learning. It’s what you do with what you’ve learnt that matters. I’m going to take a deeper look into this new way of triggering and handing events with Javascript and see what I can do with it.
So remember, just when you think you’ve got the best wheel ever invented, take a look at other people’s wheels. You might just find a better one. Or, someone else’s wheel might give you an idea which improves your wheel. And your wheel might help someone else come up with a better wheel. And that’s important. The only thing higher than learning is teaching. So learn from others and also teach others. In the end it will make for a much smoother ride for all of us.