Steps for a successful symfony living part 2

You probably read about which is a quick guide on how to get started with propel on symfony back on the days of symfony 1.2. Now Symfony 1.4 is live and doctrine is the *new* kid on the block. We need to see how to get started with this one.. Lets see..

First download the symfony 1.4.x tarball from I downloaded 1.4.5 for example. Then type in the terminal :

$ tar -zxf symfony-1.4.5.tgz
$ mkdir -p lib/vendor
$ mv symfony-1.4.5 lib/vendor/symfony

This will make the lib/vendor/symfony structure with the contents of the tarball. You can now dispose of the tarball with rm symfony-1.4.5.tgz . Now you can generate a new project like so:

./syfmony generate:project snake

Now create a new placeholder application by typing

./symfony generate:app frontend

We need to type now this command to link to the right graphics too:

ln -s /<>/lib/vendor/symfony/data/web/sf web/sf

Now configure the database connection by editing the file config/databases.yml:

class: sfDoctrineDatabase
dsn:      mysql:host=db_hostname;dbname=db_title
username: database_user
password: password

Edit your database/model schema at config/doctrine/schema.yml like so:

url: { type: string(256), notnull:true }
title: { type: string(256), notnull:true }    title:

and type:

s doctrine:build --all --and-load

to build the database sql, run the sql script, create the model and load the fixtures (if you have any) and thus replace anything that was there already. You are good to go. Enjoy your coffee now. You can code now 🙂

Flixel tutorial part 1

For the uninitiated, Flixel is a game engine made in/for flash. It is said to be much faster than regular flash because it ditches vector graphics for bitmap ones.

This is a tutorial series that will try to introduce you to the flixel sdk one step at a time. So here we go with part 1.

Flixel tutorial part 1: Set up flixel for Flex.

This part is for OS X users of Flex 3.0 IDE.

Step 1: Download the latest flixel version from and save on your favorite location on your disk.

Step 2: Start Flex and select File -> New -> ActionScript Project

Step 3: Type your project name (Tutorial_01) and store at a convenient location

Step 4: Click on «Next» button (not Finish) and at the source path field add the path to the library you downloaded from step 1 (you expanded it right?) and then click Finish

That’s it.. you’re done!.. well almost since you aren’t using the library just yet. The Flex IDE created a file titled «» which we’ll have to replace so replace it with this one:

package {
	import org.flixel.*;
	[SWF(width="640", height="480", backgroundColor="#000000")]
	public class Tutorial_01 extends FlxGame
		public function Tutorial_01()

In the first lines we use a 640×480 canvas with black color and later on we pass control to the class «PlayState». We didn’t define Playstate did we? No!. So Select File -> New -> ActionScript Class and at the window that will appear type Name: PlayState, Superclass: FlxState and hit Finish. Now paste inside this one the following:

	import org.flixel.*;
	public class PlayState extends FlxState
		public var myText:FlxText;
		override public function create():void
			myText=new FlxText(0,30,100,"Hello, World!"); 

What we do here is we create a new FlxText object called myText to print on screen «Hello, World!» and then we pass it to the game engine to attach it to the rendering loop with the add() function. We don’t need to use the update() function yet as we don’t change anything yet.

Flixel uses states to manage the code. This means that when you are for example in the main screen you should create a separate FlxState called Intro and write code there on what should happen and then pass control to another FlxState called for example PlayState which will have the main game code.

Although we didn’t write much you will notice that if you click on the flash area (to activate it) and then hit ~ then you will see the flixel console (we enabled it using FlxG.debug=true). You will be able to see the flixel library version you are using and the fps you are reaching (frames per second). In the time of writing I get 58-62fps (it’s trying to stay to 60 fps) and flixel version 2.21.

This concludes part 1 of this series. Stay tuned for more 🙂

Who steals my interwebs ?

You want to see if someone is hijacking your wireless connection? Here is how to do it.

First of all you have to figure out your ip address. There are several ways to do it. You can go get it from AppleMenu->SystemPreferences->Network->Advanced->TCP/IP or you can type at the

ifconfig -a

now search for the part for en1 (Mac OS X’s wireless connection is on the interface called en1) or simply type

ifconfig -a|grep inet -B1|grep en1 -a1

you should get something like

ifconfig -a|grep inet -B1|grep en1 -a1
inet netmask 0xffffff00 broadcast<br

We will now do some sniffing and we will exclude our own address from the data, so at the type

sudo tcpflow -s -c -i en1 host not

It will ask you for your password etc etc. What it does is this

Strip non-printables. Convert all non-printable characters to the «.» character before printing packets to the console or storing them to a file.
Console print. Print the contents of packets to stdout as they are received, without storing any captured data to files (implies -s ).
Interface name. Capture packets from the network interface named iface. If no interface is specified with -i , a reasonable default will be used by libpcap automatically.

So we are basically asking to present us on screen what happens using our wireless interface (en1) as our source. The next part (host not xxxx) is restricting the process by excluding our own address and thus we can monitor if someone else is using our wireless connection.

If you see anything beyond this point then you are not alone on your network (you can exclude more addresses you know like printers and other computers using «not host and». You get the picture I hope)

What you can do beyond this point is try driftnet. Driftnet is a modern EtherPEG clone. EtherPEG was a small hack to show the images (jpegs) your co-workers were viewing on your network. It was rewritten for OSX but now it’s broken for Leopard (10.5). So you need something more fresh.

Driftnet is here to help your needs. Please read the man page first. The fun part is at just peeking, so by simply invoking at the

sudo driftnet -i en1  host not

you will be able to see what the highjacker sees online (!)by using X11 technology to display the images. If you want to be mean then you can try

sudo driftnet -i en1 -a -s -d . host not

which will store all the images and mpeg media (audio tracks) on the current folder (you should better create an empty one before you do this). The titles of the files stored will be written on the terminal for you to see that something is actually happening.

By this point you should be clearly very frustrated you can’t find these commands on your You should use fink and install them from there (very easy).

Youtube -> mp3

Πολλοί από εσάς ίσως ψάχνετε ακόμη τρόπο να μετατρέψετε τα κλιπάκια του youtube σε mp3 για να τα ακούτε στον υπολογιστή σας, στο mp3 player ή στο cd-player του αυτοκινήτου σας. Ο πιο άμεσος τρόπος λοιπόν είναι ο εξής. Πάτε στην διεύθυνση και πληκτρολογείτε την διεύθυνση του κλιπ από το youtube που επιθυμείτε και ως δια μαγείας έχετε το ηχητικό ντοκουμέντο σε mp3 μορφή!


Steps for a successful symfony living part 1

Suppose you have a mysql db somewhere. Lets make a very quick CRUD. As fast as possible ..


1) a glass of water,
2) a mysql db
3) the symfony sandbox

Here we go:

Step 1: edit config/databases.yml and use these as last lines:

dsn: mysql://<username>:<password>@<host>/<database_name> 

Step 2: edit config/propel.ini to set up propel properly:

propel.database            = mysql
propel.database.createUrl  = mysql://login:passwd@localhost
propel.database.url        = mysql://login:passwd@localhost/database
propel.mysql.tableType = InnoDB

setting up is done now lets get to the fun part

Step 3: we create the model from the mysql db, type at your cli:

symfony propel-build-schema

you should get some echo like:
Generating XML from Creole connection !
and at the end :
[propel-creole-transform] Propel – CreoleToXMLSchema finished
Total time: 1.1212 second
>> schema    putting /var/www/localhost/htdocs/estate/config/schema.yml
>> file-     /var/www/localhost/htdocs/estate/config/schema.xml
which indicates the success of the command. You now just created the schema of the db as a yml.
Step 4: now that we got the mysql model lets create the propel model by typing in your cli:
symfony propel-build-model
which will be used from now on throughout symfony.
You are actually done here. You can start building your applications now based on the work so far. So you should start with a backend and finish off with a frontend. 
Lets start the backend:
Step 1: type at the cli:
symfony init-app backend
to create the backend application
Step 2: type at the cli:
symfony propel-generate-crud backend images Image
to create the CRUD interface for the Image table and it will appear in the backend application as «images»
You are done for now. You can check out the CRUD at your address:
You can now go on and create simple CRUD interfaces for all your tables by this.
Final Step:
Drink the glass of water. You are done now.