Archive for Mai. 2011

Install and configure Aptana Studio 3

Hi at all 😉
Here are the complete and unabridged posts to install and configure Aptana Studio 3, step by step:

Have fun with it.. 😉
Feed back and so on always welcome!

Install Flex SDK under Ubuntu Linux

Today i want to install the Flex SDK, because i need it for compiling OpenLaszlo sourcecode to an AIR application.

The first thing we need is the Flex SDK. Download it here:
and extract it within your home-folder.

cd ~/
unzip -d tempflex

While the processing of this, you can begin the next step.

The Flex SDK requires Sun Java for compiling the SWF binaries, so if you haven’t already, install Java. If you aren’t sure if java is already installed, you can also try the following command that install java on your system:

sudo apt-get install java-package sun-java6-jdk

Wait a several minutes while the packages download and install, then agree the Sun’s license.

Now you must decide where do you want to place the installation of Flex SDK. Often optional software installations are placed within the ‚opt‘ directory at the root of your system. Because i’m the only user on my system, and also i’ve mount my home directory on a seperatly partition, i prefer to place my optional sotfware within my home directory. Also i create the needed directory within my software directory and move the flex files to the new directory:

mkdir ~/Software/flex -p
mv ~/tempflex/* ~/Software/flex/

Finally for making all the required commands available, from each path of your system, you must edit your ‘.bashrc’ in your home folder. It is also necessary, if you haven’t already done it, to add the LPS home directory and the LZX compiler path. Just type the following command to do this direct from the shell:

gedit ~/.bashrc

Now you must add these rows into the .bashrc:

# Make the FLEX compiler available
export PATH=/home/thomas/Software/flex_sdk_4.5/bin:$PATH

# Export the LPS home directory
export LPS_HOME=/home/thomas/Software/OpenLaszlo/lps-root

# Make the LZX compiler available
export PATH=/home/thomas/Software/OpenLaszlo/lps/bin:$PATH

Save the file and close the text editor. After that you must exit all open terminal windows, then opening a new one. Now should be all commands available that you need.. 😉

You can check if your Flex SDK installation was successful, by run the following command:

mxmlc -version

Is the result something like:

Version 4.5.0 build 20967 do all right! 😉

Install Adobe AIR under 64Bit Ubuntu

For trying to develop some Adobe AIR applications, i’ve need to install AIR. After a little research it turns out, that the current version is only available for 32 Bit Ubuntu, so i need a workaround.

First download the 32 Bit adobeair.deb from the Adobe website:


After that you must extract the deb-file and the control-files, change the architecture parameter from ‚i386‘ to ‚all‘ and repackage all into a new deb-file:

mkdir temp
dpkg-deb -x adobeair.deb temp
dpkg-deb --control adobeair.deb temp/DEBIAN
sed -i "s/i386/all/" temp/DEBIAN/control
dpkg -b temp adobeair_x64.deb

Finally you can install Adobe AIR on a 64-bit system with the following command:

sudo dpkg -i adobeair_x64.deb

Now you are able to install AIR applications and use that.

Update Aptana Studio from Version 3.0.0 to 3.0.2

Today i want to upgrade my Aptana Studio 3 to the current Version. Therefore i need to change the update settings.
I’m always want to try the newest versions of software, like Ubuntu, OpenLaszlo and all the others, also when there are possible bugs in there, i need to try out the new features or be glad about fixed issues. 😉
So at first we must select the update site for the nightly updates. Go to ‚Window‘->’Preferences‘ and select within the tree ‚Install/Update‘->’Available Software Sites‘. Now we must additional select the ‚Aptana Studio 3 Nightly Updates‘ entry.

After waiting for pending, select the Aptana Studio 3 Entry and accept the Terms of the license agreements. After the update progress a finally Aptana restart is required and that’s it.. Now you’re Aptana Studio 3 is up to date again 😉

Insert Google Analytics JavaScript direct within TypoScript

TIPP: Um Google-Analytics noch leichter in jeden TYPO3 Fluid-Template nutzen zu können empfehle ich die Verwendung des Fluid-Template-Manager (kurz FTM).

Um CSS oder JavaScript in TYPOScript zu integrieren, Zum Beispiel das JavaScript für einen Google Analytics Tracking-Code, kann man den folgenden Code verwenden:

page {
  headerData {
    1 = TEXT
    1.value (
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-Y']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
}) ();


PHP Regular Expression to validate strings

Hi at all 😉

Since a long time i’m searching for a regex in PHP, that filter some letters as sample names. But the solutions that i’ve found could not filter all letters i need.
The most ones didn’t gets letters like à, ä, æ, and so on, without including the letters explicit in the regex.

These week Lars, my college from iscope 😉 , founds the following solution to take all Unicode characters:

class Validate {
	 * Checks a String
	 * @author     Thomas Deuling <>
	 * @param      string $value String to check
	 * @return     boolean Is valid?!
	public static function lettersOnly($value="") {
		if (!preg_match("/^[\pL]*$/", $value)) return false;
		return true;

Here some test cases:


$testvalue = "gfgsergds";
$function = "lettersOnly";
echo "Validate::".$function."(".$testvalue."): ".(string)Validate::$function($testvalue)."<br>";
// Validate::lettersOnly(gfgsergds): 1

$testvalue = "gfs3467rgds";
$function = "lettersOnly";
echo "Validate::".$function."(".$testvalue."): ".(string)Validate::$function($testvalue)."<br>";
// Validate::lettersOnly(gfs3467rgds):

$testvalue = "g%/)=gsgds";
$function = "lettersOnly";
echo "Validate::".$function."(".$testvalue."): ".(string)Validate::$function($testvalue)."<br>";
// Validate::lettersOnly(g%/)=gsgds):

$testvalue = utf8_decode("aäüöføæhgfd");
$function = "lettersOnly";
echo "Validate::".$function."(".$testvalue."): ".(string)Validate::$function($testvalue)."<br>";
// Validate::lettersOnly(aäüöføæhgfd): 1


Update Subversion PlugIn to 1.6.x within Aptana Studio 3

Before starting the update of subversion, check your Aptana Updates and install them.
Do this in the main menu ‘Help’ -> ‘Check for Updates’. After finishing the update, restart aptana.

Now you are ready to start the update. First of all, add the new Subversion Update site. For that open ‚Help‘ -> ‚Preferences‘ and select within the Tree ‚Install/Update‘->’Available Software Sites‘, now add the following update site:

After that, you have to do a second Aptana Update under ‚Help‘ -> ‚Check for Updates‘. Now you will find some new updates about subversion, select them all.
Agree the terms and do complete the update. After finishing these second update, restart aptana again and that’s it.

Take webcam snapshot with OpenLaszlo

Today i have played a bit with my webcam, and tried to make some pictures and save that as jpeg files.

Click here for a demo 😉

At first we must integrate the webcam within a base structure of openlaszlo code. It’s needed to include some ActionScript libraries to realize our little project.
It’s advisable to implement in the base strukture a switch tag for handle the runtime, and also a passthrough tag for including the ActionScript 3 libraries.
This base structure could be look like:

<?xml version="1.0" encoding="UTF-8" ?>
<canvas width="100%" height="100%">
		<unless property="$as3">
			<handler name="oninit">
				Debug.error("ActionScript 3 required");
				import com.adobe.images.JPGEncoder;
				import flash.utils.ByteArray;
				import flash.display.Bitmap;
				import flash.display.BitmapData;
				import flash.geom.Matrix;


After that we create some views and include a videoview and a camera-tag inside.

<simplelayout axis="y" spacing="0" />
<view name="videoView" width="$once{canvas.imageWidth*2}" height="$once{canvas.imageHeight}">
	<simplelayout axis="x" spacing="0" />
	<view name="videoView" width="$once{canvas.imageWidth}" height="$once{canvas.imageHeight}">
		<videoview name="video" oninit="" width="$once{canvas.imageWidth}" height="$once{canvas.imageHeight}">
			<camera name="webcam" show="true" width="$once{canvas.imageWidth}" height="$once{canvas.imageHeight}" bandwidth="0" picturequality="1.0" />
	<view name="snapshot" width="$once{canvas.imageWidth}" height="$once{canvas.imageHeight}" />
<view layout="axis: x; spacing:0">
	<button text="Take a snapshot" onclick="canvas.takeSnapshot();" width="$once{canvas.imageWidth}" />
	<button text="Save snapshot" onclick="canvas.saveImage();" width="$once{canvas.imageWidth}" />		

I don’t know what i do wrong, but i have the feeling that the bandwidth and quality changes does not work (using lps 4.9.0). So, i additional change these values within the oninit handler. If you have a tip, or know what’s the problem of that, please contact me 😉
Here now my oninit handler:

<handler name="oninit">
	// Get the webcam 
	var cam:Camera = Camera.getCamera();
	// Specifies the maximum amount of bandwidth that the current outgoing video feed can use, in bytes per second. To specify that Flash Player video can use as much bandwidth as needed to maintain the value of quality , pass 0 for bandwidth . The default value is 16384.
	var bandwidth:int = 0; 
	// This value is 0-100 with 1 being the lowest quality. 
	// Pass 0 if you want the quality to vary to keep better framerates
	var quality:int = 100; 
	// Set bandwidth and quality
	cam.setQuality(bandwidth, quality);
	// Set measurements and framerate
	cam.setMode(canvas.imageWidth, canvas.imageHeight, 30, false); 

For taking a snapshot from the webcam, we write a small function:

<method name="takeSnapshot">
	// create a new bitmap object
	var tempSnapshot:BitmapData =new BitmapData(canvas.imageWidth, canvas.imageHeight, true, 0x00FFFFFF);
	tempSnapshot.draw(, new Matrix());
	// place the snapshop i a view
	var targetView = canvas.videoView.snapshot.getDisplayObject();
	targetView.addChild(new Bitmap(tempSnapshot));
	canvas.setAttribute("shotAvailable", true);	

Further we want save the snapshot at a local machine. Therefore we must convert the snapshot into a image and send it to the client.

In order to convert the snapshot into a image, we need the JPGEncoder ActionScript library from Mike Chambers.
Some days ago i write about, how to integrate this in OpenLaszlo. You will find the article here.
Here now the function for converting the snapshot into a image:

<method name="saveImage">
	if(canvas.shotAvailable) {
		// Take the snapshot movieclip
		var sketch_mc = canvas.videoView.snapshot.getDisplayObject();
		// Get the image data from that
		var jpgSource:BitmapData = new BitmapData(sketch_mc.width, sketch_mc.height);
		// Create a Jpeg from the image data
		var jpgEncoder:JPGEncoder = new JPGEncoder(85);
		var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);
		// Create an URLRequest with the image
		var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
		var jpgURLRequest:URLRequest = new URLRequest("./snapShotHandle.php?name=sketch.jpg");
		jpgURLRequest.method = URLRequestMethod.POST; = jpgStream;
		// Send the image for download
		navigateToURL(jpgURLRequest, "_blank");

For saving the image, we use use a small PHP script like:


// create filename
$filename = date("Y-m-d_H:i:s", time())."_".uniqid(mt_rand(), true).".jpg";

	// add headers for download dialog-box
	header('Content-Type: image/jpeg');
	header("Content-Disposition: attachment; filename=".$filename);



That’s all you need…
Click here for a demo 😉

Sourcecode: OpenLaszlo - (1053)

If you found some bugs or have some Tips, please contact me.

Flush DNS-Cache and change DNS-Server in Ubuntu

During i do today move a internet site from one server to another one, i’ve the problem that the DNS of this site isn’t up to date.
So i wanted to flush my local DNS cache, but how?

After a bit searching with google, i collect the needed informations for doing this in Ubuntu.
At first it’s needed to install nscd by using the following command:

sudo aptitude install nscd

After this, we are able to flush the DNS Cache with the following command:

sudo /etc/init.d/nscd restart

This should be enough, to become a current DNS dissolving. But in my case it shows after a few test, that our intranet router also caches the DNS. So, i must change my local DNS entry to another one, that is more up to date.

For this, we must editing the resolv.conf:

sudo nano /etc/resolv.conf 

Therein we must change the IP of the nameserver:


After just a few seconds the system should be automatically changed, and your network requests goes to the new DNS server.

Use ActionScript 3 libraries within OpenLaszlo

Today i tried to integrate an ActionScript 3 within OpenLaszlo.
In detail i needed a JPEGEncoder that is integrated in the ActionScript 3 Library from Mike Chambers.

You can download the library here:

The integration is very easy. First of all navigate into your lps root folder, and create a folder named ‚flexlib‘. Then download the ActionScript 3 Library and place the as3corelib.swc in it.

That’s all.
Now you are able to integrate as sample the JPGEncoder Library:

<?xml version="1.0" encoding="UTF-8" ?>
<canvas width="100%" height="100%">
		<unless property="$as3">
			<handler name="oninit">
				Debug.error("ActionScript 3 required");
				import com.adobe.images.JPGEncoder;