CAT | programación
25
Multilenguaje en Wordpress
0 Comments | Posted by andres in Desarrollo web, GNU/Linux, Herramientas, Internet, Software libre, Wordpress, programación
qTranslate hace lo que tiene que hacer y es muy sencillo de usar, recomendable.
20
Using Selenium with SmartClient (SmartGwt)
0 Comments | Posted by andres in Configuración, Desarrollo web, General, Gwt, Java, SmartClient, SmartGwt, programación
Selenium is a powerful and popular tool which can be used to test your SmartClient applications.
Selenium executes tests against your running application in a browser emulating user interaction and asserting various conditions.
Selenium provides a record/playback tool for authoring tests without learning a test scripting language. You must be familiar with
Selenium and use of Selenium IDE before proceeding. Refer to the documentation on the Selenium
site.
Use of Selenium with SmartClient applications is no different than using Selenium to write and run test cases with any other application with
the exception on on caveat. Selenium supports the concept of Locators
in order to specify the element you’d like a given Selenium command to operate on. For example Selenium supports XPath based locators, and DOM ID based locators.
XPath based locators are extremely fragile due to complexity of certain highly nested DOM elements you need access to combined with the fact that
XPath support varies across browsers and so your tests might not work across different browsers.
SmartClient occasionally renders a different DOM structure depending on the browser for performance for rendering the UI such that it appears identical across various browsers.
As a result using DOM ID or DOM XPath based locators with SmartClient applications is not advisable. Instead SmartClient supports a new Selenium
locator which is an xpath-like string used by Selenium to robustly identify DOM elements within a SmartClient application. SmartClient locators for Selenium
are prefixed by “scLocator=” and have a readable XPath like value even for cells in ListGrid’s or TreeGrids. Typically these locators will not be hand-written and
are generated by Selenium IDE, Selenium’s test recording tool.
One primary locator is based on the ID of the SmartClient widget and has the syntax ID=<Canvas ID>. This
simplifies the task of writing tests if you know the ID of the Canvas. For reference, the scLocator syntax for
ListGrid cells and DynamicForm FormItem"s can be found at the end of this document.
Setup Instructions
- SmartClient ships with a Selenium user extension Javascript file : user-extensions.js. When running the Selenium tests make sure you place this file at the appropriate location.
Refer to the Selenium Documentation for mode details. - In order to create tests, we suggest you use Selenium IDE. By default, Selenium looks for a file called “user-extensions.js”, and loads the javascript code found in that file.
In the standard Selenium distribution, this file does not exist. You should place this file in this common location.
Refer to the Selenium documentation if you need additional information. Once you have
Selenium IDE installed, you will need to use the SmartClient user-extensions.js file with Selenium IDE. This is installed by
putting the pathname to its location on your computer in the Selenium Core extensions field of Selenium-IDEÕs Options=>Options=>General tab.
Additional Details on how this can be setup can be found here. -
You will also need to configure Selenium IDE with a SmartClient provided Selenium IDE extensions javascript file : user-extensions-ide.js This is installed by
putting the pathname to its location on your computer in the Selenium IDE extensions field of Selenium-IDEÕs Options=>Options=>General tab.
That’s it, we’re done configuring the environment.
Recording Selenium tests with Selenium IDE
Once you have your application running in Firefox, open Selenium IDE from the Tools ==> Selenium IDE menu option. If the Selenium IDE is in record mode,
then clicking or carrying out other operations like typing in a text field with automatically record the appropriate Selenium commands with the SmartClient locator.
There’s no need for you to manually enter the locator, the recorder does this for you! Sometimes users many want finder grain control of what Selenium command
is created instead of having the Selenium IDE recorder do this automatically. For example if you want to verify the value of a particular cell in a ListGrid.
Instead on typing in the command “verifyTable” and manually enter the SmartClient Locator (scLocator), you can simply right click on the table cell or any other
SmartClient widget and the most suitable Selenium commands will appear in the context menu along with the scLocator path for the clicked element. See image below.

Common scLocator syntax
List Grid cells
//ListGrid[ID="itemList"]/body/row[itemID=1996||itemName=Sugar White 1KG||SKU=85201400||1]/col[fieldName=SKU||1]
- This assumes the ListGrid has an explicit ID
- the ‘body’ part might be ‘frozenBody’ if the field in question was frozen
- row[......] identifies the row (record)
- itemID=
– that’s the primary key field from the dataSource the grid is bound to - itemName=
– that’s the title field value for the record - SKU=… – that’s the cell the user clicked’s value
- 1 – that’s the index of the row (rowNum)
- col[.....] – identifies the column in the grid
- fieldName=… – field name for the field the user clicked
- 1 – that’s the index of the column
- itemName=
Form Items
//DynamicForm[ID="autoTestForm"]/item[name=textField||title=textField||value=test||index=0||Class=TextItem]/element
This example is the data element (text entry box) for a text field
- this form has an explicit ID
- item[...] identifies the item
- name (field name, if set)
- title (title, if set)
- value (current value if set)
- index (index in the form items array)
- Class (SC class of the item – in this case TextItem) after the “/” we identify the part of the item in question options here include:
- “element” – the data element
- “canvas” – for CanvasItems – points to the canvas embedded in the item
- in this case the xpath might continue to contain, for example children of the canvas or elements within it (cells in a listGrid, etc)
- “textbox” – the “text box” – this is the area where content is written out for items without a ‘data element’ – like header items
- “[icon=<...>]” – the icon element — “<...>” would contain the “name”
of the icon
Known Limitations
- Support for multi-select for SelectItems with selection mode “grid” (non-default)
- Support for Drag & Drop due to limitations in Selenium
2
Qué es un looping? (explicado por un mortal)
0 Comments | Posted by andres in Humor, programación
Para quien no conoce el concepto de looping, es un término que crearon los informáticos para definir un enredo de los tantos que han creado y para lo cual no tienen una explicación sencilla que resuelva el problema. Haciendo poco esfuerzo, trataré de explicarles en pocas palabras este famoso término.

Se dice que un programa de computación “entró en un looping” cuando ocurre una situación como la siguiente:
El DIRECTOR llama a su secretaria y le dice:
Señorita Vanessa: Tengo un seminario en Argentina por una semana y quiero que me acompañe para que conozca a mis socios. Haga los preparativos del viaje…
La secretaria llama al marido:
Oye Juan – Voy a viajar al exterior con el director por una semana. Cuidate, querido.
El marido llama a la amante:
Leonor, mi tesoro – La bruja va a viajar al exterior por una semana, vamos a pasarnos esta semana juntos, mi reina…
La amante llama al niño a quien le da clases particulares:
Manuelito – Tengo mucho trabajo la próxima semana.. No tienes que venir a clases…
El niño llama a su abuelo:
Tata – La próxima semana no tengo clases, mi profesora estará ocupada. Así que, por fin… ¡Vamos a poder pasar la semana juntos!!
El abuelo (que es el DIRECTOR en esta historia) llama a la secretaria:
Señorita Vanessa venga rápido – Suspenda el viaje, voy a pasar la próxima semana con mi nieto que hace un año que no veo, así que no vamos a participar en el Seminario. Cancele el viaje y el hotel.
La secretaria llama al marido:
Juan- El imbécil del director cambió de idea y acaba de cancelar el viaje, se me jodió el viaje.
El marido llama a la amante:
Amorcito disculpa – No podremos pasar la próxima semana juntos, el viaje de la tetona de mi mujer fue cancelado.
La amante llama al niño de las clases particulares:
Manuelito – Cambié de planes: esta semana le voy a dar clases como siempre.
El niño llama al abuelo:
Abuelo, la vieja de mi profesora me dijo que esta semana tengo clases normales, discúlpame, no voy a poder hacerte compañía.
El abuelo llama a la secretaria:
Señorita Vanessa – Mi nieto me acaba de decir que no va a poder estar conmigo esta semana porque tiene clases. Así que continúe con los preparativos del viaje al seminario…
¿Quedó claro lo que es un looping…???
Fuente: null
5
Antipatrones de diseño
0 Comments | Posted by andres in Curiosidades, Diseño, General, programación
Investigando en Wikipedia llegué a una categoría que no conocía: Antipatrón de diseño lo que en pocas palabras significa, una mala solución a un problema.
Está muy interesante recorrér algunos de los que allí se presentan y notar que no necesariamente se aplican a la informática.
Algunos de los que me parecieron mas interesantes:
http://es.wikipedia.org/wiki/Base_de_datos_como_comunicador_de_procesos
http://es.wikipedia.org/wiki/Par%C3%A1lisis_del_an%C3%A1lisis
http://es.wikipedia.org/wiki/Fear_of_success
http://es.wikipedia.org/wiki/C%C3%B3digo_ofuscado
http://es.wikipedia.org/wiki/Magic_pushbutton
http://es.wikipedia.org/wiki/Martillo_de_oro

25
Instalar Netbeans para PHP en GNU/Linux
0 Comments | Posted by andres in Desarrollo web, GNU/Linux, Herramientas, programación
En mi caso utilizo ubuntu pero debería ser muy similar en cualquier otra distribución, especialmente de la familia de
Debian
Previo a la instalación debemos tener instalado el JDK:
sudo apt-get install sun-java6-jdk
Vamos a la web de descargas de Netbeans:
http://netbeans.org/downloads/index.html
Descargamos la opción de PHP.
Supongamos que descargamos el archivo en el escritorio, abrimos una consola, escribimos:
cd Escritorio
Le damos permisos de ejecución al archivo descargado:
sudo chmod 644 netbeans-6.8-ml-php-linux.sh
Ejecutamos el archivo:
sudo sh netbeans-6.8-ml-php-linux.sh
Se nos abrirá el instalador y seguimos los pasos que nos indica.

Siempre me gustó mas javascript que flash, chromeexperiments.com es una gran prueba de que se pueden hacer las mismas cosas que con flash

Uno de los ejemplos que mas me gustó:
http://www.chromeexperiments.com/detail/browser-ball/
Otra vez Matías tirando buena info.
Processing es una librería javascript con una filisofía similar a los applets de Java.
Para aprender un poco acerca de la sintaxis es que hice un ejemplo muy básico, simplemente se pinta un círculo en donde hagas click.

Dentro del método setup() hay otro método llamado noLoop(), este es usado para que el método draw() no se refresque solo. Para lograr que el canvas se refresque hay que poner el método redraw() luego de nuestra acción, en este caso lo puse dentro del método mouseClicked(). Para probar, puedes comentar ambos métodos a la vez para ver que funciona de todos modos, también puedes probar comentar uno y otro para ver el comportamiento.
Gracias Matias Menafra por el aporte.
Existe una gran variedad de este tipo de herramientas, dejo una lista de las que encontré y cómo instalarlas.
*Dia, además de UML puedes diseñar otro tipo de diagramas como por ejemplo circuitos eléctricos
*BoUML, luego de realizar tu diseño puedes generar el código correspondiente en varios lenguajes como Java, PHP, etc.
*Gaphor, no le he probado mucho.
*Umbrello, una herramienta hecha para KDE pero funciona lo mas bien con GNOME, muy completa.
*ArgoUML, una herramienta hecha en Java que pinta muy bien
Quitando ArgoUML, si tienes alguna distrubución basada en Debian como por ejemplo Ubuntu, puedes instalar las herramientas facilmente buscando en tu gestor de paquetes o tecleando en la consola:
$ sudo apt-get install nombre_de_la_herramienta
ArgoUML lo puedes descargar de aquí
Una vez descargado, descomprimimos el tar.gz y buscamos el .jar que dice argouml, click derecho, abrir con java y ya está corriendo.
¿Conoces alguna otra que no haya nombrado?
25
Instalar visual editor en Eclipse Ganymede (3.4.2)
11 Comments | Posted by andres in programación
Simple y sencillo, estando en Eclipse vamos Help -> Software update y abrimos la pestaña Available software. Clic en Add site…
y pegamos la siguiente URL http://update.soyatec.org/Ganymede/ve/1.4
Posteriormente damos un tic al checkbox como se ve en la imágen.
Apretamos el botón install… y le damos siguiente a los sucesivos pasos.
Una vez instalado el visual editor nos pide que reiniciemos Eclipse (si no nos pide, reiniciamos igual).
Listo, ya tenemos visual editor instalado
Les dejo un script hecho en Perl para el envío masivo de mails.
Es sencillo y bastante intuitivo.
Lo que debes hacer es copiar el código y guardarlo en un archivo por ejemplo mailing.pl
Luego para ejecutarlo, abre una consola y tipea:
$ perl mailing.pl
Logicamente, previo a hacer una ejecución de prueba debes modificar el script con los datos que sean necesarios, esto es, conexión a base de datos, tablas a seleccionar, etc.
#!/usr/bin/perl
# Programa para el envio de mails
print "\n Comienzo.. \n";
use DBI();
use strict;
my $opcion = $ARGV[0]; #en caso de pasarle parametros al script, los atrapo aqui (en este caso no se usa)
my $db = openConnection(); #conecto con la BD
my $asunto = "Mi asunto"; #asunto del mail que va a ser enviado
my $remitente = "micorreo\@correo.com";
my $mensaje = "mensaje.html"; #cuerpo del mail en html
my @mails = getEmails($db);
my $i;
for ($i=0; $i<=$#mails; $i++) #para cada correo obtenido de la BD...
{
my($id, $email) = split(":", $mails[$i]);
enviarCorreo($email, $asunto, $remitente);
}
print "\n Se han enviado ".$i." correos \n";
print "\n Fin. \n";
closeConnection($db); #cierro la conexion a BD
sub openConnection
{
my $db = DBI->connect("DBI:mysql:database=nombre_BD;host=mi_host","mi_usuario","mi_password",{'RaiseError' => 1});
return $db;
}
sub closeConnection {
my $db = $_[0];
$db->disconnect();
}
sub getEmails()
{
my ($db) = @_;
my $query = " SELECT emails";
$query .= " FROM mi_tabla";
$query .= " WHERE alguna_condicion";
my $sth = $db->prepare($query);
$sth->execute();
my @data_array;
my $i = 0;
while(my $ref = $sth->fetchrow_hashref()) {
$data_array[$i] = $ref->{"id"}. ":" . $ref->{"email"};
$i++;
}
$sth->finish();
return @data_array;
}
sub enviarCorreo
{
my($email, $asunto, $remitente, $algo_a_sustituir) = @_; #atrapo los parametros pasados a la sub rutina
open(MAILING, "$mensaje") || die "No se encontro el archivo '$mensaje'\n";
my $buffer = "";
my $line;
while (defined($line =
$buffer .= $line;
}
close(MAILING) || die "Error cerrando '$mensaje'\n";
$buffer =~ s/{{algo_a_sustituir}}/$algo_a_sustituir/;
open (MAIL,"|/usr/sbin/sendmail -t") or die "No se puede abrir sendmail\n";
print MAIL "To: $email\n";
print MAIL "From: Mi nombre <$remitente>\n";
print MAIL "Subject: $asunto\n";
print MAIL "Content-Type: text/html\n";
print MAIL "$buffer\n";
print MAIL "\n";
close(MAIL);
}

