Flex 3.0 meets Symfony meets PureMVC: sfFlexymfonyPlugin

I have just released the new sfFlexymfonyPlugin for Symfony.

The sfFlexymfonyPlugin provides means for a developer to easily integrate flex applications into Symfony. The undelying Felx application uses a specific framework aimed to give developers a Symfony-like feel.
Detailed documentation still to follow. Please for now try to have a look at the DefaultModule example in your application. The underlying architecture is based on PureMVC so please also have a look at their documentations. Soon I will update the documentation and provide a full tutorial on how to use the framework. Also browse through the whole source code (there is not much in there so you will have a nice overview of what’s going on).

Check it out here

New Symfony Plugin: sfFileTrunkPlugin

I have finally finished a new plugin for Symfony: sfFileTrunkPlugin

sfFileTrunk plugin

The sfFileTrunkPlugin provides a central point for file uploads and handling. Not only does it take care of all of your file uploads but also for content delivery easily implemented using partials and components.

Installation

This plugin requires sfThumbnailPlugin. If you want to make use of the components and actions of this plugin don’t forget to enable the sfFileTrunk module in your application settings.yml

Contents

This plugin contains several classes for easy file upload and devlivery.

Creating a file upload using sfFileTrunkPlugin

In order to make use of the plugin’s functionalities all you basically need to do is to create a file input widget in your form and pass the sfValidatedFileTrunk class to the sfValidatorFile.

See for example following form:

class TestForm extends BaseForm
{
    public function configure()
    {
        $this->setWidget('file', new sfWidgetFormInputFile());
        $this->setValidator('file', new sfValidatorFile(array(
            'validated_file_class' => 'sfValidatedFileTrunk', 
            'path' => FileTrunk::getPath()
        )));

        $this->getWidgetSchema()->setNameFormat('test[%s]');
    }
}

It as easy as that. Your action to handle the form could look like the following:

    public function executeIndex(sfWebRequest $request)
    {
        $this->form = new TestForm();

        if ($request->isMethod('post'))
        {
            $this->form->bind($request->getParameter('test'), $request->getFiles('test'));

            if ($this->form->isValid())
            {
                $file = $this->form->getValue('file');
                $file->save();
            }
        }
    }

That’s it. Everything else is already done in the background. The file is saved with a unique name and a reference is inserted in the database.

This was just a very simple example. The real use of the plugin comes through if you combine it with your model. Take the following schema for example:

propel:
  test_table:
    id:
    title:
      type: varchar
      size: 80
      required: true
    file_trunk_id:
      type: integer
      required: true
      foreignTable: file_trunk
      foreignReference: id

A reference to the file_trunk table is needed so that we can store the file_trunk_id in our table (this table could for example the images table for a gallery). Now all you need todo is to change the TestTable’s form a little bit like this:

class TestTableForm extends BaseTestTableForm
{
    public function configure()
    {
        $this->setWidget('file_trunk_file', new sfWidgetFormInputFile());
        $this->setValidator('file_trunk_file', new sfValidatorFile(array(
            'validated_file_class' => 'sfValidatedFileTrunk', 
            'path' => sfConfig::get('sf_upload_dir')
        )));

        unset($this->widgetSchema['file_trunk_id']);
        unset($this->validatorSchema['file_trunk_id']);
    }

    public function save($con = null)
    {

        $file = $this->getValue('file_trunk_file');
        $file->save();
        $this->getObject()->setFileTrunkId($file->getFileTrunk()->getId());
        return parent::save($con);
    }

}

And voila! You have now enabled file upload with reference to the file trunk in your model.

Content delivery with sfFileTrunkPlugin

To put out content is very easy. You can put out content with two components:

<?php include_component('sfFileTrunk', 'filetrunk_file', array('id' => 1)); ?>
<hr/>
<?php include_component('sfFileTrunk', 'filetrunk_image', array('id' => 1, 'width' => 100)); ?>

The filetrunk_image component supports thumbnailing of images. Minimum parameters to be passed so that it works is the width parameter. You can optionally add the height parameter. If you set width to 0 or leave them completely out the original image will be used.

NOTE: When not in the dev environment new thumbnail generation is limited to a 30 minutes interval. That means if you already generated a thumbnail of 30×30 you will have to wait another 30 minutes before you can generate a thumbnail with 40×40.

Symfony Plugin Install Script

This is a very short post.

Currently I am using Symfony 1.4.1 for my development but I have noticed that I could not install most if not all plug-ins through the PEAR packaging system. Since I am using Ubuntu I quickly wrote myself a short script to handle the download and unpacking of plug-ins that I want to install. When calling the script you just give it the URL to the .tgz package of the plug-in. Enjoy

#!/bin/sh
url=$1
#extract the package filename from the URL
package_name=$(echo $1 | sed 's/.*\///')
#extract the raw plug-in name (with version number)
plugin_raw=$(echo $package_name | sed 's/\(.*\?\)\.tgz/\1/')
#extract the actual name of the plug-in (without the version number)
plugin_name=$(echo $package_name | sed 's/\([^-]*\).*/\1/')

#go to the plug-in directory
cd plugins

#check if we already have downloaded the package. You may change the destination to anything you like.
#I store the packages in /usr/share
if [ -f /usr/share/$package_name ]
then
 sudo cp /usr/share/$package_name ./$package_name
else
 wget $1
 sudo cp ./$package_name /usr/share/$package_name
fi

# untar
tar zxpf ./$package_name
mv ./$plugin_raw ./$plugin_name
sudo rm ./$package_name

# remove package.xml file
if [ -f ./package.xml ]
then
 rm package.xml
fi

exit 0

Web apps a la Minority report?

Yes, I know, I have been lazy again with blogging. It was been a turbulent two months and I didn’t have much time. Anyhow, let’s go on. My past blog posts were all about AR, current and future developments with some examples. I didn’t get to play with it yet but something else popped up on my to do list.

While I was looking around for AR examples done with Flash and working with Papervision3D I had this idea… what if I could detect the motion of my hands through the web cam to move objects around in my Papervision3D application?

At first I thought it might be impossible to achieve with Flash but I still googled: flash motion detection. Woop I came across numerous post and most of the pointing me to two crazy guys Ohtsuka Masakazu and Mario Klingemann. Now Ohtsuka was crazy enough to port parts of OpenCV into ActionScript3 (the project is code named Marilena) and Mario improved parts of that port for performance, which enables Flash developers to perform facial recognition on still images and web cam. This technology even found its way into Facebook via an application.

Coming across this blew my mind literally and I started investigating on OpenCV and hand motion recognition which in turn blew my mind (or what was left of it) again, I realized that what I have been thinking is actually possible but yet to be implemented in ActionScript3. The most amazing part is that unlike Minority Report, this approach does not need any special gloves (although it would surely simplify development).

So here are a few videos I have found during my research. I am positive that the user experience on the web will drastically change in the next few years. AR, motion and object dedection, there is a huge amount of possibilities. Imagine a website with computer vision that would respond to your facial expression; try to cheer you up when you’re sad, calm you down when you’re angry and joke with you when you’re happy.

This first video is pretty much the most impressive that I found so far. Big kudos for this kid.

Could body motion recognition the next version of the Wii?

Augmented Reality and… magic?!

As usual I’ve been browsing the web for AR (Augmented Reality) applications, articles and videos when I stumbled upon a video by virtualmagician on YouTube. It is the coolest AR-like video I have seen so far. I am not sure if he is using true real time AR on the trick he performs or if the video was just post-edited. In either way it is damn impressive. Check it out:

AR with FLARToolKit

Augmented Reality in practiceYesterday I gave you an introduction to AR (Augmented Reality) and what is possible with this technology. Today I want to introduce you to FLARtoolKit. FLARToolKit is an ActionScript 3 port of the open source library ARToolKit with which you can build your own AR applications. With FLARToolKit you can build easily great AR applications using Flash/Flex in combination with you favorite 3D Flash Engine which means that thanks to Saqoosha, a Japanese coder, we can experience beautiful AR in our browsers. View Saqoosha’s new year’s greetings in the video or print out a marker and try it yourself.

In the next few weeks I will try myself on the FLARTToolKit and post some examples on how to build AR applications with Flex and Papervision3D.

Enjoy

On Augmented Reality

Augmented Reality - This might be the near futureRecently I have been researching on AR (Augmented Reality) which is in my opinion currently the most interesting trend in the industry. According to Wikipedia AR is

… a term for a live direct or indirect view of a physical real-world environment whose elements are merged with-, or augmented by virtual computer-generated imagery – creating a mixed reality.

So what does THAT now mean? It is not virtual reality as some might think. Virtual reality is composed purely of computer generated elements whereas AR uses pictures (video feeds) of the real world and superimposes computer generated elements on it.

Some of you might have actually already experienced AR in one way or the other. The first time I got in touch with it was a game on my Nokia phone a few years back (can’t remember which one it was) that used the phone’s camera to build the environment of the game. Upon the camera feed were little 3D viruses generated that I had to shoot and by moving the phone I would move within the game’s environment.

AR has many applications and it will change a gamers experience soon. The guys from NVIDIA already started (with others) to develop a unique gaming experience. Let’s take “ARhrrr!”  for example: This game is a project from Georgia Tech and SCAD-Atlanta. The game is developed for the new Tegra by NVIDIA and uses the Tegra’s camera to build a gaming environment on a printed city map. In this city you, the player, have to protect citizens from zombies. The device represents a helicopter in the gaming environment and you can even use real-life Skittles as ammunition. I think it is a bit hard to explain the game itself so here’s a demo video of it:

But the use of AR is not limited to games only. It can be used in many different ways. One company working a lot with AR is Total-Immersion and has lots and lots of examples of use including digital marketing, publishing and education.

One of my favorite marketing applications using AR is “Living Sasquatch“. Many of you may know the advertisements “Messin with Sasquatch” and with Living Sasquatch you can make your own little video with Sasquatch in your own room. All you need is a webcam a printer and you’re good to go. Try it out.

In the future I think that AR will be present everywhere. Scientists are currently researching on digital contact lenses that can show you your vital signs directly in your sight. Though it will take a few years until a first prototype is ready, this idea alone brought up many other applications such as integrations with your phone or pocket PC or the like. Furthermore we can expect at least glasses with AR capabilities much earlier than the contact lenses, as the application of AR on glasses is much easier than on lenses. I myself will probably come up soon with my own little test applications and I already have several ideas how to use this wonderful technology to build interactive websites.

Process Monitor

Just a quick dump of a recommendation I got earlier.

Process Monitor is a very useful tool if you need to see what processes are using which resources on your machine. Here’s a short overview from the website

Overview of Process Monitor Capabilities

Process Monitor includes powerful monitoring and filtering capabilities, including:

  • More data captured for operation input and output parameters
  • Non-destructive filters allow you to set filters without losing data
  • Capture of thread stacks for each operation make it possible in many cases to identify the root cause of an operation
  • Reliable capture of process details, including image path, command line, user and session ID
  • Configurable and moveable columns for any event property
  • Filters can be set for any data field, including fields not configured as columns
  • Advanced logging architecture scales to tens of millions of captured events and gigabytes of log data
  • Process tree tool shows relationship of all processes referenced in a trace
  • Native log format preserves all data for loading in a different Process Monitor instance
  • Process tooltip for easy viewing of process image information
  • Detail tooltip allows convenient access to formatted data that doesn’t fit in the column
  • Cancellable search
  • Boot time logging of all operations

You can find the tool here

Back

Finially… After a long long period of silence I got myself back together and now I’ll start to write again.

A few months ago I started to develop with Adobe Flex. Quite interesting and sort of easy to use but I got really interested when I stumbled upon Away3D and Papervision3D. Those two are 3D engines for Flash… yes… 3D and not like the good old Shockwave Flash. No, fully fledged “high” performance 3D engines even suitable to program little games with them. I was amazed by the capabilities of those two engines and directly dove into developing small test applications and I am currently working on two websites using Papervision3D.

I will post more in the next few weeks about my progress in developing those two applications but in the meantime you can check out some really cool websites developed with PPV3D and Away3D:

Away3D


Eminem’s new album has broken records, and this amazing interactive adventure website lets you discover and immerse yourself in Eminem’s sick musical world.

Some superb 3D User Interface ideas can be seen at AIRFORCE.com’s Supercar site.

Powerflasher’s “PDF Book 3D” tool uses Away3D to breathe fresh air into your run-of-the-mill 2D page flip book viewer

Papervision3D

Nascar and the United States Air Force, the work was performed for GSD&M Idea City out of Austin, Texas.

Site for a band that already broke up in 1986

Business of Mutual Benefit

Don’t you just love those scam emails? To many they are obvious but unfortunately there are still a few fools out there that fall for it. This is what I received today and I fell laughing off of my chair:

BARRISTER FRED JACK

Tel: 27 73 802 2624

Sandton South Africa.

BUSINESS OF MUTUAL BENEFIT.

My name is Fred Jack, personal Attorney to late Mr. Adams Walker,a national of your country who died along with his wife and his Two sons in a a plane crash.

My late client left behind a deposit of Ten Million, Two Hundred Thousand United States Dollars($10,200,000.00usd) in his domiciliary bank account in a bank here in South Africa.

After the death of my client ,his bankers contacted me as his Attorney to provide his next of kin who should inherit his fortune.

The bankers had planned to invoke the abandoned property decree of 1996 to confiscate the funds after the expiration of the period given to me.

I seek your consent to present you as the Next of Kin to the Deceased since you are at an advantage as nationals from the same country, so that the proceeds of this Bank Account valued at $10.2 Million Dollars can be paid to you.

We shall both share the fund, 35% to me and 60% to you, while 5% should be for Expenses or Tax as your Government may require, I shall assemble all the necessary Legal Documents that will be used to back up our claim .

I guarantee that this will be executed under a legitimate arrangement that will protect you from any breach of law.

Please get in touch with me by telephone or email to enable us discuss further.

Best Regards,
Fred Jack Esq.