Georges Jentgen: put life into code

Public Web-Dev chat on Skype

I opened a public chat on Skype called “Web-Development Chat” about a year ago. Since then there were a lot of nice discussions going on. Mostly about web development of course.

Come on and join the chat if you are a web-dev or are in need for some help. There are 120 people waiting for a interesting discussion.

Web-Development Chat

Awesome MAX 2009 Widget

Adobe Platform Evangelist Serge Jespers just published his new Widget for the upcoming Adobe MAX conference 2009. The conference is held in Los Angeles. I am looking forward to watch the keynotes online somehow. But until then:

My Facebook Username

So Facebook today launched their initiative to receive a unique username if you want to. So I grabbed mine before my alter ego takes it :)

You can check my page here: http://www.facebook.com/georges.jentgen




Advertisement

Wordbook – Blog to Facebook Plugin

I was looking for the right way to publish my blog posts onto facebook. I found Wordbook for Wordpress and it seems to be the right plugin for this task!!!

Easily keep changes in a database table in a history table

If you want to keep changes made to a table in your database you can do it by using a history table. Often you have to manually define that table for every distinct table in your database you want to keep history of.

A simple solution is to use a timestamp field with “ON UPDATE CURRENT_TIMESTAMP” in your table, make an exact copy (wihout data, just schema) of it and you are almost done.

Here is my example table:

User
----
User_ID
Username
Email
Timestamp (ON UPDATE CURRENT_TIMESTAMP) (set using phpMyAdmin)

Now you just copy that table to User_History. Next you have to define a simple query that puts an element into this table every time you make changes to that user trough your application:

INSERT DELAYED INTO User_History (SELECT * FROM User WHERE User_ID = $UserID LIMIT 1)

So everytime you make changes to the user in your User-table, you set the timestamp to the current timestamp. The old timestamp is being written along with the user data to the User_History-table. So using the User_History-table you can read what changes have been made.

Nice and simple!

How to use ValueObjects in Flex and AMFPHP

This small tutorial will explain how to use and why you should use value objects troughout your Flex/AMFPHP projects.

First of all, we start with a simple php value object class:


  class VOUser {
    var strUsername = "";
    var strEmail = "";

    var $_explicitType = "com.isageo.VOUser";
  }

Using the $_explicitType we tell AMFPHP to which value object class it should get mapped.

Next we create a simple php class that returns some VOUser objects:


  class User {
    public function getUser() {
      // Get user using fancy database connection

      $objUser = new VOUser();
      $objUser->strUsername = "Georges";
      $objEmail->"email@email.com";

      return $objUser;
    }
  }

So now we have a simple service that gets called by the flex application and receives an VOUser object to work with. Let’s get back to Flex and create a VOUser class using ActionScript:


  package com.isageo {
    [RemoteClass(alias="com.isageo.VOUser")]
    [Bindable]
    class VOUser {
      public var strUsername : String;
      public var strEmail : String;
    }
  }

The RemoteClass meta data tells Flex where to find the VOUser class trough AMF. The next step is to receive some data from AMFPHP. So now when receiving a VOUser object from AMFPHP, Flex know exactly what properties it has and vice versa. Plus: when loading data directly into a Flex component and back out, Flex always retains the right object class (in this case VOUser).

So no more object conversions. You always get what you are expecting!

NetBeans IDE Template Variables

I was tinkering around with the new NetBeans IDE for PHP and as soon as I created a new class NetBeans created some code with a short message:

To edit this template, go to …

Well, as I did not like that template I started opening up the template and made some changes. It hit me that you can use variables in those templates. Something like: ${date} to get the current date on creation. There were 2 other variables in this template: ${name} and ${user}.

I opened up the NetBeans Help but did not found anything about those variables or if there are others I could use. So I did a quick Google search and found a small list of variables:

  • ${date} inserts the current date, in this format: Feb 16, 2008
  • ${encoding} inserts the default encoding, such as: UTF-8
  • ${name} inserts the name of the file.
  • ${nameAndExt} inserts the name of the file, together with its extension.
  • ${package} inserts the name of the package where the file is created.
  • ${time} inserts the current time, in this format: 7:37:58 PM
  • ${user} inserts the user name.
  • ${project.license} based on the value (e.g., ‘CDDL’), the license header is found and is inserted into the template


Prototyping with Flex Builder

The last few days I was working on a graphical prototype for some internal apps. I will try to tell you why it was so much fun doing it with the Flex Builder 3.

Components:
As most devs know, Flex comes with a very mature set of components that work out of the box. This is a very important advantage when prototyping.

States:
States are a very great feature of the Flex Framwork. It gives you the possibility to setup your graphical design in a root state and propagate all changes to all child states. Then, every child state gets tuned to look like a step you make while using the app in real life. And by adding a single ActionScript line to a button, image or almost anything else, you can jump from state to state. Here is a sample code:

currentState = ‘nextStep_12′;

So when this ActionScript gets fired up, the interface changes to the state called “nextStep_12″. You can add this line of code wherever you want to change the state. The end result seems like a real application, even tough there is no real business logic behind all that stuff.

Using states you can get a real feel of how your app will look and feel like in just minutes.

Amazon EC2 Image for Flex/AMFPHP

I played around with Amazon Machine Images (AMIs) and created a simple image for Flex with AMFPHP.

Image ID: ami-a4d334cd
Manifest: flexdev-images/flexdev-lamp-AMFPHP.LinuxDebian-5.0-20090301.manifest.xml

I installed everything I might need for a flex-driven website and AMFPHP:

  • Apache2 + PHP5
  • MySQL 5.1
  • PHPMyAdmin
  • AMFPHP

To get a flex-app running with that AMI you need to do the following after launching your instance:

  1. Create 2 folders called “services” and “projects” in the /var/www folder
  2. copy the main amfphp service into the /var/www/services

The AMFPHP browser can be found in http://public-dns-of-ami/browser
The gateay to AMFPHP can be found in http://public-dns-of-ami/gateway/gateway.php
PHPMyAdmin can be found in http://public-dns-of-ami/mysql

The default MySQL username and password are: root/mysqlpwd

To open the AMFPHP browser you need to enter a username and password: admin/pass. To change it, change the config file located in /var/www_browser/config/login.conf.php. You can also define multiple users, even tough every user sees the same services.

You can login to this AMI using SSH on port 22 and trough the webserver on port 80. For PHPMyAdmin

And that’s it. If you have any questions regarding that AMI and how to use it, just contact me.

How to build a fast and easy backup system using VMWare Consolidated Backup and powershell – Final

Finally I got some time to update my VMWare Backup Script!

I had to change some of the features I had in mind. But it is still enough to get a backup done. So first, let’s see what we have to do on our VMWare Infrastructure Server. The custom fields we defined earlier have to be changed as follows:

0_BackupEnabled (”Yes” to enable)
1_BackupAccess (nbd, san, …)
2_BackupRotation (days to store the backup)
3_BackupCurrentStatus
4_BackupLastStatus
5_BackupSize (in kb)
6_BackupTime

So after updating the custom fields as described we can use the finished script to enable the backups by editing the custom fields for every virtual machine you want to backup. It’s quite easy and you can enable the backup of a virtual machine after creating a new one. No need to edit configuration files on the backup server, or to add new backup schedules.

The finished script can be downloaded here: http://idisk.mac.com/polysign-Public?view=web
(Folder “code”, Filename: vcbackup.txt)

 Just edit the configuration in the script file and you are good to go. Have fun!