Pixelastic

You can cut our wings but we will always remember what it was like to fly.

Posts tagged with "windows"

Migrating from Windows to Ubuntu : KeePass

I'm slowly trying to move my development machine from a desktop Windows Xp to a laptop running Ubuntu. This is quite a long task because there are so much softwares I depend on on my day to day work. Most of them are crossplatform but I often need o find a Ubuntu equivalent, and sometimes it does not exists and I have to run the Windows app using an emulator.

This is exactly the case with KeePass. KeePass 2.0 is an improved version of KeePass 1.0 (obviously), that allows one to save all password in one place. The 2.0 version also permit to save more than single password, virtually anything, and adding little icons to each entry (when you start having 200+ entries, icons are a must have).

Enter Ubuntu world

The official 2.0 version is not supported under linux. There is a linux port, named KeePassX, but it does not support the .kdbx file format used by the official 2.0 version.

So I tried to run the Windows .exe file with Wine at first (I already had Wine installed to run another app), but it wasn't working with KeePass. I tried instead an other emulator, Mono, and running mono KeePass.exe totally worked.

Little tweaks ahead

First of all, I had to install two additionnal packages to make it open without errors : System.Windows.Forms and System.Runtime. So far, so good.

But, I quickly discovered that one of the most usefull features of KeePass, auto-type (Ctrl+V automatically fills a login/password field) wasn't working correctly. There was one more missing dependency : xdotool.

If you are running Ubuntu like me, do not install it from the official packages, this version is completly outdated and won't work. Instead, you have to manually install the latest version. If you are lucky and running a 64bits system, you can download directly the .deb file from here.

If you are running under a 32bits system like me, you'll have to manually install it. First grab the files from this link. Then, install the libxtst-dev package (it is needed for the install to complete), export the content of the .tar.gz file into a temporary directory and execute sudo make install.

Finally !

Now, you got KeePass 2.0 working under Ubuntu, and installed all dependencies needed to run the auto-type feature.

In a Windows environment, one can change KeePass preferences so that closing it only send it to the tray bar.This option does not seem to be working under Linux, KeePass still shows in the task bar even when minimized. I spent some time trying to fix that too, tetsing AllTray and other tray softs for linux but didn't managed to get what I wanted.

Testing IE6 and IE7 using VirtualBox on Windows

Testing various IE version as always been a chore. Back in the days, I managed to install both IE7 and use a standalone IE6 version.

Then, I discovered IETester that became a lifesaver (my IE6 standalone tends to crash a little too often). It would allow me to test various IE versions side by side.

Unfortunatly, the emulation wasn't perfect, some ajax calls were returning errors and the Flash support wasn't so good.

Additionnaly, there was not way to use the IEDebugBar nor the WebPageTest plugin.

Switching to VM

I finally decided to switch to a Virtual Machine. This would allow me to have an exact snapshot of a given OS/IE version.

VirtualBox is free, so this was my choice. Microsft used to provide free downloads of various flavors of Windows/IE, but it seems to be only working with their proprietary VirtualPC (which only works under Windows 7).

So I took the long road, and manually installed a Windows XP Pro through VirtualBox, using my Windows XP cd.

I used the same serial than my main windows XP. I'm not exactly sure if legally, I'm allowed to do that. How does a VM fits inside the legal statements ? Am I allowed to use one windows activation key inside itself ? Well, I don't really know and don't care that much.

Starting with some housekeeping

I ended up with a nice and clean WinXP install. I had to add an antivirus quick if I wanted to keep it clean. VirtualBox provides a Shared Folder feature to exchange files between the host and the guest.

Start by adding shared folders to your guest (Devices > Shared Folders).

Then install the "Guest Additions", just mount the VBoxGuestAdditions.iso found in your VirtualBox installation directory, using DaemonTools and run the installer.

Don't be as silly as I was. Do not install the Guest Additions on your host, but on your guest. Yeah, seems more logical that way. Just select the options in the Devices menu of your guest window. Reboot after the installation.

You should now be able to access your shared folders by opening the windows Explorer (Windows + E), and going to Network places > All network > VirtualBox Shared Folders

Accessing your websites

I then updated the C:\WINDOWS\system32\drivers\etc\hosts file to bind all requests made to my still-in-development websites to my host.

10.0.2.2        www.pixelastic
10.0.2.2        s1.pixelastic
10.0.2.2        s2.pixelastic
10.0.2.2        s3.pixelastic

You can find your host ip by doing a ipconfig /all in a command prompt.

You then just have to go to http://www.pixelastic/ in IE6 to display the correct website. You can even switch to the Seamless mode to display your IE6 inside your main host.

Using cakePHP OpenId plugin on Windows

After all the praises I've read about OpenId, I decided to implement it in this CMS. My goal was to set an easy way for readers to leave comments without the need for registering to anything.

I thought it would also be great to add as a secondary, and easiest, mechanism for logging in.

So I downloaded and installed the openID component by cakebaker. As I'm running my dev environment under Windows, I had to set some settings.

Fixing the pluginPath

I've save the OpenId component in a plugin, and it has a clever mechanism to import the PHP OpenId library based on the folder it is saved.

Unfortunatly, the regexp used to know the name of the current plugin was throwing errors on Windows, due to the backslashes used in the file path.

I updated the getPluginName() method to this new one and it did the trick :

private function getPluginName() {
$result = array();
$ds = (Folder::isWindowsPath(__FILE__)) ? '\\\\' : DS;
if (preg_match('#'.$ds.'plugins'.$ds.'(.*)'.$ds.'controllers#', __FILE__, $result)) {
return $result[1];
}

return false;
}

Basically it makes sure that the backslashes are correctly escaped under Windows.

Edit : I've sent this patch to the OpenId component author and it is now fixed in the latest versions.

Generating randomness

The second fix was to change the Auth_OpenID_RAND_SOURCE constant to null. This constant enable the library to generate randomness (AFAIK), by using the /dev/urandom.

This does not exists on Windows, so I added the following lines in my bootstrap.php

if (Folder::isWindowsPath(__FILE__)) {
define('Auth_OpenID_RAND_SOURCE', null);
}

Connecting to SSL servers

The PHP bundle on Windows comes with cURL already builtin, but without the bundle of the X.509 certificates of public CA. It means that the OpenId PHP library will refuse to connect to any CA using an SSL connection because it won't be able to check the certificate.

This does not happens on Linux, the list is correctly built in.

Fortunatly, we can pass a CURLOPT_CAINFO option to cURL to manually set a pre-defined bundle, and there already is one shipped with the PHP OpenId library.

All you have to do is add the following line on line 93 of the vendors/Auth/Yadis/ParanoidHTTPFetcher.php file :

curl_setopt($c, CURLOPT_CAINFO, str_replace('\\', '/', dirname(__FILE__)).'/../OpenID/ca-bundle.crt');

 

Running multiple Firefox versions side by side on Windows

Whenever you upgrade your Firefox, the new version will overwrite the previous one. If you want to open multiple Firefox versions side by side, here's my way :

  • First, uninstall all your previous Firefox installation(s). Make sure to backup any important data beforehand (I personnaly use MozBackup to do that).
  • Then install the latest available stable version. This will be the main Firefox version, the one you'll be using on your dayjob and the one you'll always update.
  • Now run the Firefox ProfileManager.
    To do that, create a shortcut to your firefox.exe file, then edit this shortcut. In the "Target" field, add -Profilemanager.
    My field looks like : "C:\Program Files\Internet\Firefox\firefox.exe" -Profilemanager
  • You now have to create one new profile for each FF version you plan on testing. Give them meaningful names. I named mine "FF3.0".
  • Now download the corresponding Firefox version from oldversion.com
  • Do not install it, but extract its content (using a archiving tool like winrar or 7-zip) in a tmp directory. Remove the optional directory as well as removed-files.log and setup.exe.
  • Copy the content of localized/ into nonlocalized/ (overwrite files if asked).
  • You can now rename the nonlocalized/ directory and move it around on your hard drive.
    I renamed mine to Firefox 3.0/ and put it alongside the main Firefox, in C:\Program Files\Internet\Firefox 3.0\
  • Create a shortcut to the firefox.exe file in this directory and edit the target field.
    This time, we have to specify which profile to use. Just add -P "FF3.0" -no-remote in the target field.
    Mine now looks like C:\Program Files\Internet\Firefox 3.0\firefox.exe" -P "FF3.0" -no-remote

That's it.
Now, just run your classic Firefox shortcut to open the most up to date Firefox version, and use the custom shortcuts to open previous versions.

I personnaly also rename the different firefox.exe to firefox30.exe, or firefox35.exe to more easily spot them in the taskmanager.

I also edit each .exe with ResHack to change their taskbar icons. I haven't yet managed to change their title.

Edit : Now I can't open .html files directly from the explorer nor follow links from my IM. I still don't know exactly what of the steps above caused that.