knightly

Yearly Archives: 2010

Best wishes

As the year is coming to an end. I realise i haven’t posted anything this last month. And i have load of things on my mind. But no time. I’ll be heading over to a friends house for the remaining part of this year. So i wish everybody a good and happy 2011. Don’t drink to much and be careful with fireworks.

On a side note: did anybody check out the new php.net layout? i think Hannes and Co are doing a great job!

(to see the new layout go to php.net/my and flip the beta switch at the bottom of the page)

Moving from Subversion to GIT

Last weekend was a PFZ meeting. And for this day a few interesting workshops were planned. I mainly was looking forward to the GIT (Git for Subversion Users) talk by Stefan Koopmanschap. And the Dependency Injection presentation by Berry Langerak I didn’t make it too the last one. But learned a lot while doing the GIT workshop with Stefan.

For the last few months i have wanted to take a look at git. But it just never really took the time to sit down and do it. So this opportunity was there at the right time. Although my laptop died halfway through the workshop. I still was able to make it through the whole session together with Joost van Veen. Thanks man. We had a great time. And it was eye opening. Stefan gave a good talk. Helped out where possible. And besides a small Github glitch. It was a successful day.

So successful that i decided to make the switch from Subversion to GIT. Below are some of the steps i took.

The main reasons for me to make the switch

  • Distributed structure make it easy to work from any place. connected or not.
  • Stashing
  • Speed and cleaner folder / file structure
  • Real tags

That’s all for now. but this list will grow. I am sure!

Setting up a GIT server

I decided to go for my own GIT server instead of Github. That’s just the way i like it. Full control.

$ aptitude install git-core

Now all we have to do is create a user for git operations. And set the correct permissions.

$ adduser git
$ mkdir /home/git/.ssh
$ chown -R git:git /home/git/.ssh
$ chmod 700 /home/git

If we want to create a new remote repository. We log in on the git server through SSH and setup a new repository like this.

$ ssh git@git.domain.tld
$ mkdir repository.git
$ cd repository.git
$ git –bare init

That’s all. we now have all we need to connect to git remotely and do some work. But now first we need to import the old Subversion repository. I have found two solid methods for getting the job done.

Import a SVN project into GIT with git-svn

First of install git-svn

$ sudo aptitude install git-svn

Before we start the importing. It’s good practice to create an author mapping file. So the SVN commiter names match the GIT ones. This is done by creating a simple text file like so.

$ touch authors.txt
$ echo “m0s = Thijs Lensselink ” > authors.txt

Importing the existing tags and branches is done by adding the –stdlayout switch

$ git svn clone –stdlayout -A authors.txt svn+ssh://user@svnhost/repository repository.git

The problem with this method is that tags and branches are not created properly. I decided to go for the second method down here.

Import a SVN project into GIT with svn2git

For this to work we first need ruby and some gems packages.

$ apt-get install git-svn ruby rubygems
$ gem install svn2git –source http://gemcutter.org

Create the local repository and import the files from SVN

$ mkdir repository.git
$ cd repository.git
$ /var/lib/gems/1.8/bin/svn2git svn+ssh://user@svnhost/repository –authors ../authors.txt

Show the current selected branch

$ git branch
* master

Show all branches. Notice the trunk branch

$ git branch -a
* master
trunk

List all tags

$ git tag -l
v1.0
v2.0

That seemed to work pretty good for almost all projects. Some projects didn’t have the main trunk in SVN. So to import these just add the –rootistrunk switch.

And while this info is still available in my brain at the moment. I will write down some of the workshop material for future reference.

Setup local Development environment

Create directory somewhere that will serve as the local repository. And run init to create the basic git project structure.

$ mkdir [project name]
$ cd [project name]
$ git init

Now we have a fully functional git repository. We can do anything with (add, commit, tag, branch, push, etc.) The first things to do when starting out is setup the user name and email address of the developer using this repository. This is good when looking though the GIT project logs later on. Also handy to set the core editor to the most convenient editor available.

$ git config –global user.name “Thijs Lensselink”
$ git config –global user.email “email@lenss.nl”
$ git config –global core.editor vi

The repository exists out of a origin and a master branch at this moment. The origin refers to the current repository location. And the master refers to the current repository state. Like HEAD in CVS and SVN. Let’s add a file for testing.

$ touch index.php
$ git add index.php (or add *)
$ git commit -m “Commit something”

Working on a local repository is nice. but we want to save it on a server of course. For this we need to set a repository location. We can do this in two ways. We can overwrite the origin or add a new location. Let’s try the first one.

$ git remote add origin git@git.domain.tld:repository.git

Setting up the remote git repository and push the changes

All changes to this repository are made locally so far. Let’s try and push them to the git server. The only problem here is. I haven’t found a way to create repositories remotely. So we have to log in to the server here and create the repository.

$ ssh git@git.domain.tld
$ mkdir repository.git
$ cd repository.git
$ git –bare init
$ exit

Back on the client side we can now do a push an see what happens.

$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 232 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@192.168.178.24:foo.git
* [new branch] master -> master

if you get this error:

error: src refspec master does not match any.

This means there is no master branch yet. This happens when the repository was created with the –bare switch. You have to commit a change first before you can push anything to the remote repository server.

That’s all. We now have a working GIT server and local repository. All that is left is to do some serious development work. On the other hand, before i forget. i will use this space to rehash Stefan’s workshop for future reference.

Tagging

Let start by looking at the way git creates tags. First of there are two types of tags lightweight and annotated. The lightweight version is nothing more then a pointer to a specific commit. It’s like a branch that doesn’t change. Annotated tags are a bit different then their lightweight version. And for sure different from the tags in Subversion. A tags in git contains the following data

  • checksum
  • tagger name
  • email + date
  • tag message
  • GPG signed

Creating an annotated tag for version 1 looks something like this

$ git tag -a v1.0 -m “Creating a tag”

Dispaly a certain tag

$ git show v1.0

I haven’t had time to look into working with signing of tags. So maybe i will add an entry about that later on.

Branching

A repository can have multiple branches. And switching between branches is a since in git. Branching is much like
it is in Subversion.

Create a new branch from master called foo

$ git branch foo master

Display all branches available. The current branch is highlighted by the * sign

$ git branch
* master
foo

Changing branches in git is a piece of cake.


$
git checkout foo
Switched to branch ‘foo’

There is not much more to branching.

diff, merge and delete branches

When adding a new feature to an existing code base. It’s good practice to create a branch before you start editing. And after everything is done and the change is stable. The branch can be merged back into the master.

First let’s check if there is a difference between the newly created branch and the master.

$ git diff foo master
diff –git a/touch.foo b/touch.foo
deleted file mode 100644
index 257cc56..0000000
— a/touch.foo
+++ /dev/null
@@ -1 +0,0 @@
-foo

Some changes have been found so let’s merge them in the master branch

$ git checkout master
$ git merge foo master (or git pull foo master)
Already up-to-date with 12d2f9cebaf71a580b021a8eeddc38f267b69e53
Trying simple merge with 4d3dff7e0d2a26302a5884e763fd7a48f5ab4437
Merge made by octopus.
touch.foo | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 touch.foo

with git pull it is possible to import branches from other repositories

When done with the changes. And everything is pushed to the remote git server, we can remove the ‘foo’ branch

$ git branch -d foo
Deleted branch foo (was d9a8c76).

That’s all for branching right now.

Stashing

One of my personal favorite the stash command. Imagine working on a project. And somebody asks you to make a small change. In subversion i needed to do a new checkout and work on that. This can be quite slow and cumbersome. In git this is solved elegantly by using the stash command.

$ git stash
Saved working directory and index state “WIP on master: 648f347… foo”
(To restore them type “git stash apply”)
HEAD is now at 648f347 foo

This saves a copy of the working state and let’s you do changes on a fresh base. After your done get back to your work by doing

$ git stash pop (or apply)

With pop you push the stash back to the master. With apply the changes will first be applied to the master before restoring the work state.

Working with other repositories

Clone a repository from a remote GIT server

$ git clone git@git.domain.tld:repository.git ./project2

Clone a local GIT repository

$ git clone ./project ./project2

Now it could be possible a friend or a remote community member without write access made a few changes to his / her remote repository. And wants them on the global remote GIT server. This can be done by pulling the code.

First add the new repository location

$ git remote add friend git://githubaddress

And then fetch the remote changes

$ git fetch friend

This only fetches the changes. but does not apply them to the master. Apply them

$ git pull friend master

updating remote repository

$ git push friend master

That’s all i can remember right now.

NSD unknown key/algorithm

As i was trying to get ready to convert my SVN repository into a GIT repository. I noticed one of my DNS slave servers wasn’t responding. A look at the log files showed something was wrong.

The master server showed:

[1289693117] nsd[6899]: error: query tsig unknown key/algorithm

While the slave displayed the following message

[883615032] nsd[6624]: error: xfrd: zone [ domain ] received error code REFUSED from [ ip address ]

After an hour of searching Google and not hitting any useful result. I rebooted the machine. And was presented by forced hard disk check. The damn thing seemed to be out of sync. And when rebooted. The date was off by a few centuries.

So after resetting the date and restarting NSD. The problem was resolved.

$ date -s ’14 NOV 2010 01:37:00′
$ /usr/sbin/nsdc update > /dev/nul 2>%1
$ /usr/sbin/nsdc patch > /dev/nul 2>%1
$ /usr/sbin/nsdc rebuild > /dev/nul 2>%1
$ /usr/sbin/nsdc reload > /dev/nul 2>%1
$ /usr/sbin/nsdc notify > /dev/nul 2>%1

Google mod_pagespeed continued

Last week i toyed with mod_pagespeed a bit. But just couldn’t get the hang of it. So the last two days permitted me to play some more with this great Apache module. Only this time i choose to build from source and ignore the binaries for a while.

For me the main problem was. As soon as i enabled the module. It was active for all sites running on this server. And that should not be a problem. But some of these sites are WordPress monsters. That are ready to take any server down with a bit of high load.

So after a bit of trail and error. I figured out i could just disable mod_pagespeed globally by altering the main config file. After Apache reloaded mod_pagespeed was not active for the running sites.

in /etc/apache2/mods-available/pagespeed.conf make sure ModPagespeed is set to ‘off’

ModPagespeed off

So now i can simply enable settings i need on a per vhost basis. For this site end some other sites i used the following config section in my vhost.

# MOD-pagespeed

SetOutputFilter MOD_PAGESPEED_OUTPUT_FILTER
ModPagespeed on

ModPagespeedUrlPrefix “http://lenss.nl”

ModPagespeedFileCachePath “/var/mod_pagespeed/cache/”
ModPagespeedGeneratedFilePrefix “/var/mod_pagespeed/files/”

#ModPagespeedRewriteLevel CoreFilters
ModPagespeedRewriteLevel PassThrough

ModPagespeedEnableFilters add_head
ModPagespeedEnableFilters collapse_whitespace
ModPagespeedEnableFilters elide_attributes
ModPagespeedEnableFilters remove_comments
ModPagespeedEnableFilters rewrite_css
ModPagespeedEnableFilters rewrite_javascript
ModPagespeedEnableFilters move_css_to_head

First of we enable mod_pagespeed of course. And then we set the current domain for this instance. After that we set the file paths for the altered and cached files. And we use ‘PassThrough’ instead of ‘CoreFilters’. So we can decide our self’s what filters we will be using.

This had a much better result then my previous attempts. The server was still happily serving pages. And the load was OK. So let’s check the sites if mod_pagespeed is actually running.

$ wget -O /dev/null –server-response http://lenss.nl 2>&1| grep -i ‘X-Mod-Pagespeed’
X-Mod-Pagespeed: 0.9.0.0-172

Well that looks good. So now it’s time to do some testing. And this leaves me with a bit of a pickle. As i don’t have the required wget v 1.12 (i have a small patch for wget v1.11). Besides that i have some other problems running the tests

TEST: 404s are served and properly recorded.
wget -O /dev/null http://lenss.nl/mod_pagespeed/ic.a.bad.css 2>&1| grep -q ’404 Not Found’
wget -q -O – –save-headers http://localhost:80/mod_pagespeed_statistics | grep -q ‘resource_404_count: 1′
FAIL.

This fails because the statistics page requested is not available because this site uses rewrites. And i haven’t found a way to go around this yet besides disabling them in .htaccess with mod_rewrite. So shortly disabling this made it possible to run the biggest part of the test suite without problems.

resource_fetches: 2
total_page_load_ms: 0
page_load_count: 0
cache_extensions: 0
not_cacheable: 0
css_file_count_reduction: 0
css_filter_files_minified: 13
css_filter_minified_bytes_saved: 5082
css_filter_parse_failures: 0
css_elements: 0
image_inline: 0
image_rewrite_saved_bytes: 0
image_rewrites: 0
javascript_blocks_minified: 15
javascript_bytes_saved: 380
javascript_minification_failures: 0
javascript_total_blocks: 15
resource_url_domain_rejections: 0
url_trims: 0
url_trim_saved_bytes: 0
resource_404_count: 2
slurp_404_count: 0
serf_fetch_request_count: 0
serf_fetch_bytes_count: 0
serf_fetch_time_duration_ms: 0
serf_fetch_cancel_count: 0

It fails on the image compression part and that’s fine. Because i will leave that for later. So let’s run the site through the pagespeed browser extension with mod_pagespeed disabled:

load time without : 2.193
firebug/pagespeed score : 68

Now the same thing but with mod_pagespeed enabled:

Load time with : 1.284
firebug/pagespeed score : 90

That looks pretty good. And the other sites i have tested preform way better with the mod_pagespeed module enabled.

I still have some Javascript issues. Some things need further inspection because i have seen error like these coming along:

Permission denied for to call method Location.toString on .

Besides that. This morning my site was down due to Apache spitting segfaults. I disabled the ‘rewrite_javascript’ filter for now. And it seems to run a bit more stable.

[Thu Nov 11 07:38:24 2010] [notice] child pid 23608 exit signal Segmentation fault (11)

So besides it being a beta i am pretty impressed by the current state of this module. And after running it for a couple of weeks the statistics are pretty impressive.

Manuel Lemos also wrote a nice article about mod_pagespeed which is worth reading.

Compiling PHP v1.0.8

Today Rasmus posted on twitter that he just compiled PHP v 1.0.8. And it actually worked. Is that great? :) He was in need of this for his upcoming talk this week in Paris. But i couldn’t resist and try to compile this ancient piece of work ;)

$ wget http://museum.php.net/php1/php-108.tar.gz
$ tar xfvz php-108.tar.gz
$ cd php

If you need to change any config setting do it now. And hit make!

$ vi config.h
$ make

This creates a few .cgi files. So it actually does still build

phpf.cgi
phpl.cgi
phplmon.cgi
phplview.cgi

Let’s copy that to my cgi-bin and run it through Apache.

Changing Mysql for MariaDB

Ok so i quit smoking 4 days ago now. And i am having some serious sleep issues at the moment. i have been up half the night sitting here staring at my screen. But nothing really productive comes out of my hands. So while doing a bit of browsing i hit the MariaDB page. And has been while since i was here. The last time there was no real downloadable package yet. But this has all changed.

So that made me think about last week. I think it was on Friday. but there was some up stirring about MySQL (Oracle) asking a license fee for using the InnoDB storage engine. And quite a big fee if you ask me :) This really sucks. I love the InnoDB engine. What would we do without it…? That’s where MariaDB comes into play. It uses the XtraDB storage engine which is basically InnoDB on steroids. XtraDB is developed and maintained by Percona. Some really smart MySQL guys :) At the moment it’s under the GPL license. And i can only hope it will be freely available for a long time.

So i went ahead and took a look at how hard / easy it is to change MySQL for MariaDB. I tried this on a Debian Lenny machine which made the process quite easy i have to mention.

First get the PGP key from the server and import the repository locations. After that hit update to refresh the local database.

$ wget -O- http://ourdelta.org/deb/ourdelta.gpg | sudo apt-key add -
$ cd /etc/apt/sources.list.d; wget http://mirror.ourdelta.org/deb/sources/lenny-mariadb-ourdelta.list
$ aptitude update

As we can see we have some new packages

Get:8 http://mirror.ourdelta.org lenny/mariadb-ourdelta Sources [864B]
Current status: 3 updates [+3], 232 new [+11].

Searching for ‘mariadb’ gives the following packages

$ aptitude search mariadb

p libmariadbclient-dev – MariaDB database development files
p libmariadbclient16 – MariaDB database client library
v libmariadbclient16-dev – MariaDB embedded database development files
p mariadb-client – MariaDB database client (metapackage depending on the latest version)
p mariadb-client-5.1 – MariaDB database client binaries
p mariadb-client-core-5.1 – MariaDB database core client binaries
v mariadb-common
p mariadb-server – MariaDB database server (metapackage depending on the latest version)
p mariadb-server-5.1 – MariaDB database server binaries
p mariadb-test – MariaDB database regression test suite (metapackage depending on the latest version)
p mariadb-test-5.1 – MariaDB database regression test suite

So let’s go ahead and install the server and see what happens.

$ aptitude install mariadb-server

Some mysql files get removed the mysql-common package gets updated and the new MariaDB packages get installed.

The following NEW packages will be installed:
libmariadbclient16{a}
libmysqlclient16{a}
mariadb-client-5.1{a}
mariadb-client-core-5.1{a}
mariadb-server
mariadb-server-5.1{a}

The following packages will be REMOVED:
mysql-client-5.0{a}
mysql-server{a}
mysql-server-5.0{a}

The following packages will be upgraded:
mysql-common

Now that’s done. Let’s check MySQL’s output

$ mysql –version
mysql Ver 14.16 Distrib 5.1.49-MariaDB, for debian-linux-gnu (i486) using readline 5.1

Just as i expected. Nothing really changed here. The whole MySQL API is till available for calling. Only the base system is now replaced by MariaDB. So let’s see what storage engines are available.

$ mysql -uroot -p

MariaDB [(none)]> show engines;
BLACKHOLE /dev/null storage engine (anything you write to it disappears)
MRG_MYISAM Collection of identical MyISAM tables
FEDERATED FederatedX pluggable storage engine
MARIA Crash-safe tables with MyISAM heritage
CSV CSV storage engine
MEMORY Hash based, stored in memory, useful for temporary tables
ARCHIVE Archive storage engine
MyISAM Default engine as of MySQL 3.23 with great performance
InnoDB Supports transactions, row-level locking, and foreign keys
PBXT High performance, multi-versioning transactional engine

And because the MySQL APi is still in tact. From PHP we can keep using the mysql and mysqli interfaces. This is great stuff!

Google mod_pagespeed

Yesterday Google released a beta version of their upcoming Apache module mod_pagespeed.

And this seems like a very promising project indeed. It mainly is a suite that provides web optimisation features to make your sites run faster. Right now 15 of such features are available.

including optimising caching, minimising client-server round trips and minimising payload size.

So no more manual image compressing and javascript, html and css minifying.

It uses the Apache SetOutputFilter to register the output filter. And from thereon you can use ModPagespeedEnableFilters to enable certain filters.

Filters like:

add_head
Add the head section if missing

move_css_to_head
Moves CSS into the head of the page (needs add_head)

combine_css
Combine multiple CSS tags into one.

rewrite_css,rewrite_javascript
Remove comments and white spaces

rewrite_images
Compress / re encode images

More info about the filters can be found here

So i went ahead and downloaded the Debian version to give it a try. And as always it’s straight forward from here.

dpkg -i mod-pagespeed-beta_current_i386.deb

It hooks nicely into Apache and creates the .load and .conf files in /etc/apache2/mods-available. After a Apache restart everything looked fine. And the pages did seem to load faster. Google also offers a test suite to see the result of this module in action.

Running the tests showed a small speed increase. But at the moment my daytime hours are spend behind a horrible firewall that really screws with web output. So i have to redo those for more accurate results. Never the less. This is a module to keep an eye on.

It’s still a very young project. And i did have some server issues today. So related or not. Be careful :)

Jquery & PHP doing simple image slicing

Today i was in need of a basic image slicer. An there must be a million of these things out there. But i wanted to see how hard / easy it would be to create this myself.

Conclusion. It’s not that hard when using the jquery library. which is becoming my Javascript framework of choice.



I started with a div.

Then i added the placeholder for the to be scaled image. And a div that will represent the slicer borders.

The next thing to do is setup the scaling canvas. So let’s make it draggable and resizeable.

// Create a draggable / scalable slicer
       $(function() {
            $('#image_slicer')
            .draggable({containment:'#image_slicer_canvas'}) // constraint
            .resizable();

            // set the slicer canvas size
            resizeCanvas(
            	$('#image_slicer_image').width(),
            	$('#image_slicer_image').height()
            );
       });

The only thing we need now is a bit of javascript to handle the slice action. I used a sample form to do the posting to the slicer.php script

// handle slicer actions
       $('#image_slicer').resizable({
   	      stop: function(event, ui) {
   	          var pos = $('#image_slicer').position();
   	          // width, height, left, top
   	          $('#scaler_width').val($('#image_slicer').width());
      	      $('#scaler_height').val($('#image_slicer').height());
        	  $('#scaler_left').val(pos.left);
        	  $('#scaler_top').val(pos.top);
   	      }
       });

The result is a nice red dotted line (square) on top of the image. The dotted area is draggable and resizeable.
When the right slice is selected just hit the slice button and PHP/GD will do the rest.

$width  = $_POST['width'];
$height = $_POST['height'];
$left   = $_POST['left'];
$top    = $_POST['top'];

// read source image
$src = imagecreatefromjpeg('images/sample.jpg');
$dest = imagecreatetruecolor($width, $height);

imagecopy($dest, $src, 0, 0, $left, $top, $width, $height);

header('Content-Type: image/jpeg');
imagegif($dest);

imagedestroy($dest);
imagedestroy($src);

That’s all. All files can be downloaded here

Just something funny

I cam across this page today and it made me laugh :) With thanks to the GNU jokes archive.

How the way people code “Hello World” varies depending on their age and job:

High School/Jr. High

10 PRINT "HELLO WORLD"
 20 END

First year in College

program Hello(input, output)
begin
writeln(‘Hello World’)
end.

Senior year in College

(defun hello
(print
(cons ‘Hello (list ‘World))))

New professional

#include <stdio.h>

 void main(void)
 {
  char *message[] = {"Hello ", "World"};
  int i;
  for(i = 0; i < 2; ++i)
  printf("%s", message[i]);
  printf("\n");
 }

Seasoned professional

#include <iostream.h>
 #include <string.h>
 class string
 {
  private:
   int size;
   char *ptr;
  public:
   string() : size(0), ptr(new char('\0')) {}
   string(const string &s) : size(s.size)
   {
     ptr = new char[size + 1];
     strcpy(ptr, s.ptr);
   }
   ~string()
   {
     delete [] ptr;
   }
   friend ostream &operator <<(ostream &, const string &);
   string &operator=(const char *);
 };

 ostream &operator<<(ostream &stream, const string &s)
 {
   return(stream << s.ptr);
 }
 string &string::operator=(const char *chrs)
 {
   if (this != &chrs)
   {
     delete [] ptr;
     size = strlen(chrs);
     ptr = new char[size + 1];
     strcpy(ptr, chrs);
   }
   return(*this);
 }
 int main()
 {
   string str;
   str = "Hello World";
   cout << str << endl;
   return(0);
 }

System Administrator

#include <stdio.h>
 #include <stdlib.h>
 main()
 {
  char *tmp;
  int i=0;
  /* on y va bourin */
  tmp=(char *)malloc(1024*sizeof(char));
  while (tmp[i]="Hello Wolrd"[i++]);
  /* Ooopps y'a une infusion ! */
  i=(int)tmp[8];
  tmp[8]=tmp[9];
  tmp[9]=(char)i;
  printf("%s\n",tmp);
 }

Apprentice Hacker

#!/usr/local/bin/perl
 $msg="Hello, world.\n";
 if ($#ARGV >= 0) {
     while(defined($arg=shift(@ARGV))) {
	 $outfilename = $arg;
	 open(FILE, ">" . $outfilename) || die "Can't write $arg: $!\n";
	 print (FILE $msg);
	 close(FILE) || die "Can't close $arg: $!\n";
     }
 } else {
     print ($msg);
 }
 1;

Experienced Hacker

 #include <stdio.h>
 #include <string.h>
 #define S "Hello, World\n"
 main(){exit(printf(S) == strlen(S) ? 0 : 1);}

Seasoned Hacker

 % cc -o a.out ~/src/misc/hw/hw.c
 % a.out
 Hello, world.

Guru Hacker

% cat
Hello, world.

New Manager (do you remember?)

 10 PRINT "HELLO WORLD"
 20 END

Middle Manager

 mail -s "Hello, world." bob@b12
 Bob, could you please write me a program that prints "Hello, world."?
 I need it by tomorrow.
 ^D

Senior Manager

 % zmail jim
 I need a "Hello, world." program by this afternoon.

Chief Executive

% letter
 letter: Command not found.
 % mail
 To: ^X ^F ^C
 % help mail
 help: Command not found.
 % damn!
 !: Event unrecognized
 % logout

Research Scientist

PROGRAM HELLO
PRINT *, 'Hello World'
END

Older research Scientist

WRITE (6, 100)
100 FORMAT (1H ,11HHELLO WORLD)
CALL EXIT
END

Zend Studio goes virtual

Zend Studio added a new great feature to there already impressive stack of features. The IDE just keeps growing in the right direction.

So the new 8 version which at the time of writing is in Beta added VMWare support. This is a feature i was looking forward to. And couldn’t wait to give this a try. So when i got a email that the new beta is out. I didn’t wait and downloaded the behemoth.

Adding VMWare support to the IDE seems like a logical thing to do. Specially since everything is virtualized now a days. I thought about this a while. But you can use it in different setups. For me it is an extra on my development environment. I’m a big Linux enthusiast. But at the office i work on windows. So now i can develop in my own virtual Linux environment. But it’s also a great solution for running Unit Test on a production VM. Or just to test on a production VM.

My first try was on my OS of choice which is Ubuntu. That however didn’t go to well. As soon as i started the “Run as VMWare application” my IDE would die on me. I quickly gave up on this mainly because i am running Maverick which is not considered stable. And VMWare already had some problems building the kernel modules. If anybody is interested in the crash logs. I still have some.

So back to windows. Windows 7 in particular. I always keep a Windows partition laying around. For games and stuff. So i downloaded the following files.

* Ubuntu-Server
* Zend Studio 8 Beta (trial)
* VMWare 7.1.2 (trial)

Installing VMWare and Zend Studio is a since. Nothing to make note off here. After that was done i installed Ubuntu 10.04 Server edition. And installed Zend Server inside of it. That should be all.. right? So let’s launch the IDE and give it a shot. Well it launched but i got back an error like below.

At first i had no clue what was going on. But i had the feeling there was something wrong with the VMWare client tools. After digging through the Zend Studio manual i found the answer The ‘hgfs’ was not mounted on teh client OS. And this was because the vmware tools did not have enough libraries to build everything. To build the complete VMWare tools on the client OS we need

* gcc
* make
* build-essential
* linux-headers-(current version)

When that’s done it necessary to attach the linux version of the VMWare tools to the virtual CDRom drive. So we can mount it inside the VM.

/usr/lib/vmware/isoimages/linux.iso

mount /dev/cdrom /mnt

Copy the file somewhere and unmount the /mnt or the build will fail. Unpack the VMWare tools and run the perl script inside to install. Once that’s done follow the VMWare instructions. Or reboot the VM.

Now we are all set. Now it’s just a matter of writing code. And running it on the VM. When running an application as a VMWare application the IDE syncs the files with the shared folder on the VM. After that the internal browser is launched to see the result.

The first time you will be asked for the VM to use. Just point it to the VM image created by VMWare.

When no VM is active when launching the application. Zend Studio will trigger VMWare to launch the VM.

Some output in Zend Studio