sábado, 29 de março de 2008

So divine

A week full of great stuff. I don't even know where to start... and I really haven't listened/played with everything new I got this week.

But let's give it a try! Starting with music...


I finally gave it a go to Corrosion of Conformity, with the album "In The Arms of God".

It's doubtful category of "Sludge Metal" wasn't taken by any chance; it's actually hard to describe C.O.C. music style. Mixing a bit of the early hardcore punk with the new stoner metal sound, it results in some kind of melodic brutality... which is awesome to hear out loud, shout directly from their lungs. Recommended!







Possibly, Jack White's favorite side project ever. The Raconteurs are back with "Consolers Of the Lonely", after their debut album in 2006. And they do, in fact, console. The similarities between Raconteurs and The White Stripes are obvious, but, there are major differences. Instead of the traditional blues -semi-progressive- rock they got us used to, we find in Consolers of the Lonely pure garage rock, as if Jack White worked with The Kills back in 2003. Much more solid than the previous work, there's plenty to enjoy here, in a wide selection of genres distributed across 14 tracks.





Yeah! Good ol' doom metal in it's best! But wait, that's not all! You'll even get a free sample of sludge metal and stoner metal in the box! Free of charge! I cannot hold responsabilities for damages in your pinky and index finger, after listening to Electric Wizard's "Dopethrone". Truly great stuff.










As for movies... the reviews will come next week, as well as the rest of the albums. One step at a time, dear ones... one step at a time.

domingo, 23 de março de 2008

Flex 3 and PHP

I'm tired of searching for Flex 3 and PHP tutorials on the web, and non of them working. Why? Because most of the tutorials you find are made for Flex 2 instead of Flex 3, and some database-relevant code has changed in this version.

So, I came up with a simple working solution, 100% Flex 3 compatible. This example will fill a Flex Data Grid with the existing data from an existent MySQL database table, allowing you to add information as well. It's still not bug-free, as it's still possible to add blank data to the table.

Here's what it looks like:

The button "Adicionar" it's what actually expands the menu, allowing the user to insert new values. (I wanted to experiment with 'States' as well, so I included them). The 3 dataGrid columns are retrieving data from the 3 existing fields in the database.

1) Let's begin with the database itself: (use Apache/Wampserver to run it locally)

Database name: flex1
Table name: contactos
Username: rychas
User password: 123456

Field1: id
Field2: nome
Field3: email

And add some contacts to these fields.

You're obviously free to change these parameters, as long as you change the correspondent values in the PHP file. Create them like these if you want to use the PHP's directly.

2) The PHP coding.

This is the main file, that will read the database and output its data as XML.
Call this file "rest.php".

<?php

$MySQLConnection = mysql_connect( "localhost", "rychas", "123456" );
//connecting and picking DB

mysql_select_db( "flex1" );

//making the query from table contactos
$Query = "SELECT * from contactos";
$Result = mysql_query( $Query );


/* fetching data and output as xml */
print "<people>\n";
while( $Row = mysql_fetch_object( $Result ) )
{
print "<person><id>".$Row->id."</id><name>".$Row->nome."</name><email>".$Row->email."</email></person>\n";
}
print "</people>";
?>


If you run this file directly and check the html source code, you'll find a XML tree with the data. Flex will interpret these results.
I'm gonna leave the user adding for later. Let's get to Flex.

3) Flex 3 application

This is the entire Flex 3 code, so just create a new Project and paste this code. PLEASE be aware of the php files location; I'm using a local server (localhost) and the files are in a root folder called "flex1". If your source php is in a different location, which is more likely, change this in the third code line.


<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="rest_service.send()" >

<mx:HTTPService id="rest_service" url="http://localhost/flex1/rest.php"/>
<mx:Panel width="365" id="pp" resizeEffect="Resize" height="229" layout="absolute" title="Lista de utilizadores" horizontalCenter="0" verticalCenter="5">
<mx:DataGrid dataProvider="{rest_service.lastResult.people.person}" id="lista" width="316.5" height="125" x="18.5" y="18">
<mx:columns>
<mx:DataGridColumn headerText="ID" dataField="id"/>
<mx:DataGridColumn headerText="Nome" dataField="name"/>
<mx:DataGridColumn headerText="Email" dataField="email"/>
</mx:columns>
</mx:DataGrid>
<mx:Button x="251" y="157" id="adiciona" label="Adicionar" click="update();"/>


<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function update():void{
lista.enabled=true;
lista.focusEnabled;
currentState="registo";

}

]]>
</mx:Script>

</mx:Panel>

<mx:states>
<mx:State name="registo">
<mx:SetProperty target="{pp}" name="height" value="56%"/>
<mx:AddChild relativeTo="{pp}" position="lastChild">
<mx:TextInput x="18.5" y="183" id="utilizador"/>
</mx:AddChild>
<mx:AddChild relativeTo="{pp}" position="lastChild">
<mx:Text x="18.5" y="157" text="Utilizador"/>
</mx:AddChild>
<mx:AddChild relativeTo="{pp}" position="lastChild">
<mx:Text x="18.5" y="213" text="Email"/>
</mx:AddChild>
<mx:AddChild relativeTo="{pp}" position="lastChild">
<mx:TextInput x="18.5" y="237" id="email"/>
</mx:AddChild>
<mx:AddChild relativeTo="{pp}" position="lastChild">
<mx:Button x="250" y="265" label="Submeter" click="reg_user.send();"/>
</mx:AddChild>
</mx:State>

<mx:State name="outro">
<mx:SetProperty target="{pp}" name="title" value=""/>
</mx:State>
</mx:states>

<mx:HTTPService id="reg_user" result="confirma(event)" showBusyCursor="true" method="POST" url="http://localhost/flex1/add.php" useProxy="false">
<mx:request xmlns="">
<utilizador>
{utilizador.text}
</utilizador>
<email>
{email.text}
</email>
</mx:request>
</mx:HTTPService>

<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
private function confirma(evt:ResultEvent):void{
mx.controls.Alert.show("Utilizador adicionado");
}
]]>
</mx:Script>

</mx:Application>


The really important thing is the first few lines, that define the dataGrid parameters. The "people.users" actually refers to the XML category that will be read. The 'dataField' specifies which label will be read by each column. If you change the XML's output in the rest.php file, you'll have to change it here as well.

4) Adding a user

This is the traditional PHP code to add something to a database. It'll just get the values sent by Flex, in the "utilizador" (means user) and "password" fields. If you change them, you'll have to change this file too.

Call it add.php.

<?php
$con = mysql_connect("localhost","rychas","123456");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("flex1", $con);

mysql_query("INSERT INTO contactos (nome, email)
VALUES ('$_POST[utilizador]', '$_POST[email]')");

mysql_close($con);
?>

5) You're done! Now just run the project. If you did everything right, the data should be written in the columns immediately. XML output will give you plenty of possibilities to play with, but I don't think there is a direct way of Flex connecting to a MySQL database.

sábado, 15 de março de 2008

Eternal Circle


The belt is tight nowadays, when it comes to money. There's simply so many wonderful things that you wish for but can't have, fearing the risk of money spent the wrong way.

Fortunately, I was right about Bob Dylan's Bootleg Series; best ~23 dollars~I ever spent. If you're familiar with Dylan's work, you know how simple it is for him to write and compose a beautiful song, easily to be related with one way or another. And among the extense list of recordings the man has gave us since the early 60's, one tends to think that that's all there is to it - nothing else could possibly be squeezed into the hot chocolate cup anymore.

And then you find about 50 rare recordings and b-sides Dylan never included in his LP's, maybe because they didn't fit, maybe because they weren't good enough for him. But the truth is, some of that work is gorgeous work, in fact, almost all of it. These recordings express themselves almost as a form of naked music, uncovering the organs of a fabulous conceptual machine.

This one will certainly be a keeper.


And Down tickets are already kept in the precious stuff-shelf. I never thought I would actually like this kind of Metal, but it's a straight fact that I really do. The concert takes place by the end of next month, and it'll be my first metal concert. And with great company.


I'm also updating my song covers list, already have a lot more and there's a few still on the list right now. What started as curiosity a few months ago may now be one of my obsessions.

sexta-feira, 7 de março de 2008

Just Like Heaven




Tomorrow, by this hour, I shall be seeing one of the greatest bands alive, The Cure! It's finally my chance to watch Mr. Robert Smith in person, which will most likely happen once in this lifetime.

Don't take me wrong, I'm not the biggest and craziest fan about The Cure. I just happen to really like them, what they did and what they do, and truth be told, the band had a major influece in my teenage years. So it would be silly not to take this chance.

I d0n't even know what their current line up is! I shall now do some background checking and song reviewing in order to be... prepared! :D