2010/10/17

Fixing ntfs filesystem on Linux

NOTE: Before apply this you must backup all your data.
-------------------------------------------------------
You can use "ntfsfix" to fix problem on yours ntfs filesystem on Linux:

zarita devcesar # ntfsfix /dev/sdb1
Mounting volume... FAILED
Attempting to correct errors...
Processing $MFT and $MFTMirr...
Reading $MFT... OK
Reading $MFTMirr... OK
Comparing $MFTMirr to $MFT... OK
Processing of $MFT and $MFTMirr completed successfully.
Setting required flags on partition... OK
Going to empty the journal ($LogFile)... OK
NTFS volume version is 3.1.
NTFS partition /dev/sdb1 was processed successfully.





2009/12/22

About Lazarus

Lazarus it's an open source GUI RAD for Freepascal.
"Free Pascal (FPC) is an open-source Pascal compiler with two notable features: a high degree of Delphi compatibility and availability on a variety of platforms, including Windows, Mac OS X, and Linux. "
Links:
http://www.lazarus.freepascal.org/

In this links are daily snapshots:
http://www.hu.freepascal.org/lazarus/

2009/12/20

Lazarus error: "duplicate identifier"

I was converting some code from Delphi to Lazarus and I find it this error: "duplicate identifier".
The solution was to put at the beginning of the unit the next piece of code:
{$code delphi}
{$h+}

2009/09/27

Linux + Eclipse + Flex

First, you must have Linux installed.
Second, links for downloading soft:

* Eclipse
Note: Flex version for Linux will work well with Eclipse 3.3.2 .

* Adobe® Flex Builder™ Linux alpha

Unzip Eclipse on your /home/username. Example: /home/devcesar/eclipse. You may change "devcesar" with the name of your home.
Execute "flexbuilder_linux_install_axxxx.bin".
Select /home/devcesar/eclipse as your Eclipse path. It will show a warning message, dont pay attention.
The install path will be "/home/devcesar/Adobe_Flex_Builder_Linux" and the executable will be "Adobe_Flex_builder.sh".
Just execute and select project->new->flex project.
Important: Features dont present in this Linux version:
* Design view
* States view
* Refactoring
* Data Wizards
* Cold Fusion - Data Services Wizard
* Web Services introspection
* Profiler

DelphiORM

DelphiORM: Object relational mapping for Delphi.
This is a project of a friend of mine. What is the important issue about this? That you can generate the needed class from existent tables.
It has three parts:
* DelphiORM.exe, templates and drivers for extracting database metadata and code generating.
* Clases bases to manage entities and collections.
* "Drivers" for generate SQL (in runtime) for every database.

Source and examples: http://code.google.com/p/delphiorm/
Forum: http://www.grupoalbor.com/foro/index.php#8

2009/04/02

Assql "ABM" example (Ejemplo de un "ABM" para assql)

This is an example that I built for testing Assql.
It has:
- Insert
- Update
- Delete

First, we have to create the table and fillit with data:


CREATE TABLE `tabla` (`tablaID` int(11) NOT NULL auto_increment,
`descripcion` varchar(255) NOT NULL,
`comentario` varchar(255) NOT NULL,
PRIMARY KEY (`tablaID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=31 ;

INSERT INTO `tabla` (`tablaID`, `descripcion`, `comentario`) VALUES
(22, '234234234', 'lalalalal4444'),
(23, 'ssssss', 'ddddddd'),
(25, 'ssssss', 'ddddddd'),
(26, '26', 'ddddddd'),
(27, '234234234', 'editado1'),
(28, 'inserteed 1', 'inserteed 1 com'),
(30, '324234', '234234');


Next, the code:


<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:assql="com.maclema.mysql.mxml.*"
layout="absolute">

<mx:Script>
<![CDATA[
import mx.events.DataGridEvent;
import mx.containers.Grid;
import mx.events.ListEvent;
import mx.controls.Alert;
import com.maclema.mysql.events.MySqlErrorEvent;
import com.maclema.util.ResultsUtil;
import mx.controls.TextInput;
import mx.events.DataGridEvent;
import mx.collections.ArrayCollection;
[Bindable]
public var boolStateNew : Boolean= false;

private function delRow():void
{
service.send("delete from tabla where tablaID='" +
grid.selectedItem.tablaID +"'");
Alert.show("Deleted ...");
service.send("SELECT * FROM tabla");
}

private function addNew():void
{
tiComentario.editable = true;
tiDescripcion.editable = true;
grid.enabled = false;
bCancel.enabled = true;
bOk.enabled = true;
bNew.enabled = false;
boolStateNew = true;
tiComentario.text = "";
tiDescripcion.text = "";
tiComentario.setFocus();
}

private function postEdit():void
{
if (boolStateNew == false){
service.send("UPDATE tabla set comentario ='"+ tiComentario.text
+ "' where tablaID='"+ grid.selectedItem.tablaID +"'");
service.send("UPDATE tabla set descripcion ='"+
tiDescripcion.text + "' where tablaID='"+ grid.selectedItem.tablaID
+"'");
Alert.show("updated");
cancelEdit();
service.send("SELECT * FROM tabla");
}
else
{
service.send("INSERT INTO `test`.`tabla`
(`tablaID`,`descripcion` ,`comentario`) VALUES (NULL , '"
+ tiDescripcion.text + "', '" + tiComentario.text + "')");
Alert.show("Inserted ...");
cancelEdit();
service.send("SELECT * FROM tabla");
}
}

private function cancelEdit():void
{
tiComentario.editable = false;
tiDescripcion.editable = false;
grid.enabled = true;
bCancel.enabled = false;
bOk.enabled = false;
bNew.enabled = true;
}

private function handleDobleClick():void
{
tiComentario.editable = true;
tiDescripcion.editable = true;
grid.enabled = false;
bCancel.enabled = true;
bOk.enabled = true;
bNew.enabled = false;
boolStateNew = false;
tiComentario.setFocus();
}

private function selectedItemChanged():void
{
tiComentario.text = grid.selectedItem.comentario;
tiDescripcion.text = grid.selectedItem.descripcion;
}

private function handleConnected(e:Event):void {
//Alert.show("hello");
service.send("SELECT * FROM tabla");
}

private function handleError(e:MySqlErrorEvent):void {
Alert.show(e.msg);
}

private function handleChange(e:Object):void {
//sComentario = e;
}

private function handleEditEnd(e:DataGridEvent):void {
// Get the cell editor and cast it to TextInput.
var myEditor:TextInput =
TextInput(e.currentTarget.itemEditorInstance);


// Get the new value from the editor.
var newVal:String = myEditor.text;


// Get the old value.

var oldVal:String =
e.currentTarget.editedItemRenderer.data[e.dataField];
var sColName:String =
e.currentTarget.editedItemRenderer.data["tablaID"];
//Alert.show(sColName);
//Alert.show("new" + newVal);
if (oldVal != newVal)
{

service.send("UPDATE tabla set descripcion='"+ newVal
+ "' where tablaID='"+ sColName +"'");
Alert.show("actualizado");
}



//columns="{ResultsUtil.getDataGridColumns(service.lastResultSet)}"
}



]]>
</mx:Script>
<assql:MySqlService id="service"
hostname="localhost"
username="test"
password="test"
database="test"
autoConnect="true"
connect="handleConnected(event)"
sqlError="handleError(event)"
/>

<mx:VBox x="0" y="0" width="100%" height="100%"
verticalAlign="bottom">

<mx:HBox width="100%" height="70%" verticalAlign="top"
horizontalAlign="center">

<mx:VBox height="100%" width="95">
<mx:Button label="Delete Row" id="bDelRow" click="delRow()"/


<mx:Button label="New Row" id="bNew" click="addNew()"/>
<mx:Button label="Edit Row" id="bEdit"
click="handleDobleClick()"/>
</mx:VBox>

<mx:DataGrid id="grid"
dataProvider="{service.lastResult}"
doubleClickEnabled="true"
editable="false"
itemEditEnd="handleEditEnd(event)"
change="{selectedItemChanged()}"
doubleClick="handleDobleClick()"
width="100%" height="100%">

<mx:columns>
<mx:DataGridColumn headerText="ID Number"
dataField="tablaID" />
<mx:DataGridColumn headerText="Descripción"
dataField="descripcion"/>
<mx:DataGridColumn headerText="Comentario"
dataField="comentario"/>
</mx:columns>
</mx:DataGrid>

</mx:HBox>
<mx:HBox width="100%" height="30%" verticalAlign="top"
horizontalAlign="center">
<mx:Panel width="50%" height="200" layout="absolute"
cornerRadius="35" horizontalAlign="center" verticalAlign="middle">

<mx:Form width="100%" height="120" cornerRadius="35"
backgroundColor="#DEC5C5" themeColor="#009DFF" borderColor="#B4C7D4"
id="form1" left="0" top="0">
<mx:FormHeading label="Add/Edit" textAlign="left"
fontSize="19" color="#0F51A3" fontWeight="bold" height="25"/>
<mx:FormItem label="Descripción" width="100%">
<mx:TextInput width="100%" id="tiDescripcion"
editable="false"/>
</mx:FormItem>
<mx:FormItem label="Comentario" width="100%">
<mx:TextInput width="100%" id="tiComentario"
editable="false"/>
</mx:FormItem>


</mx:Form>
<mx:Button label="Ok" enabled="false" horizontalCenter="46"
verticalCenter="59" id="bOk" click="postEdit()"/>
<mx:Button label="Cancel" enabled="false"
verticalCenter="59" horizontalCenter="117" id="bCancel"
click="cancelEdit()"/>

</mx:Panel>
</mx:HBox>
</mx:VBox>

</mx:Application>

2008/10/14

Flex and Data: asSQL

With Flex we can access to Data in many ways. One of them is asSQL.
asSQL allow us to make a connection with a Mysql database server. It's intend to be a AS Mysql Driver.

Links:
Site of asSQL
Updates
Discussion group
Examples
Documentation
Download Source
Download swc
About security information