martes, 30 de septiembre de 2008

Process monitoring with ps-watcher

Once you have ps-watcher installed the next step is to create a configuration file that contains the rules your want to use for monitoring or acting on what ps-watcher reports, based on the output of the ps command. Along with the supplied configuration file, you can use command-line options to fine-tune the behavior of ps-watcher and assist in debugging.

http://www.linux.com/feature/148189
http://ps-watcher.sourceforge.net/

Tuna news: release 1.2

Lo nuevo:
  1. Nuevo skin web
  2. Reconexiones automáticas de los port-forwardings
http://sourceforge.net/projects/tunadmin/
http://tunadmin.sourceforge.net/

miércoles, 24 de septiembre de 2008

libro para comprar: Clean Code

Quedé muy interesado en este libro, tiene muchas papitas para hacer mejores códigos.
Ej:
The Error Handling chapter is important because of the application of earlier chapters — the Do One Thing rule. Your functions should do one thing — either handle business logic, or exception handling, but not both. It's the difference between this:

try { s = new Socket(4000); s.OpenSocket(); string data = s.ReadFromSocket(); if(data == "32") data = "42"; printer.print(data); } catch(Exception ex) { if(ex == NetworkInterruptException) { //do something } if(ex == PrinterOnFireException) { //do something } logException(ex); }

And this

try { tryToPrintDataFromSocket(); } catch(Exception ex) { logException(ex); }

http://books.slashdot.org/books/08/09/23/2243216.shtml

Timeout en mysql usando jdbc

Ya que ibatis al parecer no soporta timeout para mysql, se puede usar propiedades
  • connectTimeout
  • socketTimeout
  • enableQueryTimeouts para usar Statement.setQueryTimeout()

Ellas son especificables en el string de conexión a mysql:
jdbc:mysql://[host:port],[host:port].../[database] [?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...

http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html

lunes, 22 de septiembre de 2008

Cambio servidor web de proyectos de SourceForge

El acceso ya no es por shell.sourceforge.net, sino por web.sourceforge.net, además hay que usar como login la sgte truculencia:
"The new username spec is USERNAME,PROJECTNAME@web.sourceforge.net"

http://sourceforge.net/community/forum/topic.php?id=3518&page

Cómo obligar al browser respetar un estilo !important

"an "!important" declaration (the keywords "!" and "important" follow the declaration) takes precedence over a normal declaration"

http://www.w3.org/TR/CSS2/cascade.html#important-rules

lsof descubre por qué du dice que hay menos espacio usado que df

Cuando ocurran cosas raras como que du dice que var usa 17G y sin embargo df dice que hay usados en var 41G, como en este ejemplo:

[pablo@test var]$ du . --max-depth=1 -h
8.7G ./www
4.9G ./log
...
17G .

[pablo@test var]$ df -h
Filesystem Size Used Avail Use% Mounted on
...
/dev/mapper/Log02 41G 39G 0 100% /var

se debe a que algún proceso tiene tomados archivos eliminados que aún usan espacio en disco, pero no se ven con ls, quedan como archivos fantasmas. Solución: detener el proceso que tiene tomados esos archivos y ver por qué no hizo "close".

Con el comando lsof se puede ver qué procesos tienen abiertos qué archivos.

miércoles, 17 de septiembre de 2008

solr-tomcat5.5: Solr app does not start: Exception starting filter SolrRequestFilter

Debugging apache-solr-1.2.0.jar, using tomcat 5.5 running on java 5, I found the problem comes from another hidden exception:
Caused by: java.lang.RuntimeException: XPathFactory#newInstance() failed to create an XPathFactory for the default object model...

Two solutions:
  • Remove $TOMCAT_HOME/common/endorsed/xml-apis.jar (I mean mv xml-apis.jar xml-apis.jar.removed). So, the runtime libraries of java 5 will be used, not the tomcat endorsed.
Or:
Then, restart tomcat.

Ref del problema:
http://groups.google.com/group/linux.debian.bugs.dist/browse_thread/thread/f551fc6f05c48d17

Framework PHP: CakePHP




Mientras leía de LimeSurvey, vi que está hecho sobre CakePHP
Ref: http://www.limesurvey.org/

Me recordó a ruby on rails, con el "convention over configuration".
Ref: http://cakephp.org/

La típica lata es que necesita que la BD esté hecha para él (ej: palabras_separadas_por_underscore, las tablas tienen que tener un id autoincrement, etc) no está hecho para BD ya establecidas.

Resumen:
CakePHP is a rapid development framework for PHP that provides an extensible architecture for developing, maintaining, and deploying applications. Using commonly known design patterns like MVC and ORM within the convention over configuration paradigm, CakePHP reduces development costs and helps developers write less code.

Tuna news: nuevo skin con css refresh

Screenshot con su nueva pinta:




http://sourceforge.net/projects/tunadmin/
http://tunadmin.sourceforge.net/

martes, 16 de septiembre de 2008

Platform-as-a-Service: Google App Engine

Interesante sería usar la facilidad de google, para hacer alguna aplicación web y de pasada aprender más python:

One interesting example of a PaaS is Google App Engine. App Engine is a service that allows you to deploy your Web applications on Google's very scalable architecture. App Engine provides you with a sandbox for your Python application that can be referenced over the Internet (and additional languages will be supported in the future). App Engine provides Python APIs for persistently storing and managing data (using the Google Query Language, or GQL) in addition to support for authenticating users, manipulating images, and sending e-mail. The sandbox in which the Web application runs restricts access to the underlying operating system. Although App Engine limits the functionality available to your application, it supports the construction of useful Web services. Check out Resources for more information.


http://code.google.com/appengine/

Rewrite rules para tener REST en PHP

Varias veces olvido los pasos necesarios para que funcione esa truculencia de apache:
  • Make sure that an .htaccess override is allowed. In your httpd.conf, you should have a section that defines your Directory on the server. Make sure the AllowOverride is set to All for the correct DocumentRoot.
  • Make sure you are editing the system httpd.conf rather than a user- or site-specific httpd.conf.
  • Make sure you are loading up mod_rewrite correctly. You should see something like LoadModule rewrite_module libexec/httpd/mod_rewrite.so (Unix/Linux users should also see something like AddModule mod_rewrite.c) in your httpd.conf. Also make sure that those lines have not been commented out (by being prepended with a #). Restart Apache to make sure your conf settings are active.
  • If you are installing into a user directory (http://example.com/~username), you'll need to modify the .htaccess file in the base directory of your installation. Just add the line "RewriteBase /~myusername/".
http://book.cakephp.org/view/37/Apache-and-mod_rewrite

Popularity of Programming languages

Echarle un vistazo cada cierto tiempo...
http://www.hurricanesoftwares.com/popularity-of-programming-languages-september-2008/

Nombres geniales de proyectos

The Eucalyptus project (Elastic Utility Computing Architecture for Linking
Your Programs To Useful Systems) ...
http://eucalyptus.cs.ucsb.edu/

jeje

viernes, 12 de septiembre de 2008

La nueva GUI de VMware es web!

VMware 2 (beta aún) trae una interfaz web para administrar las máquinas virtuales.


Es como una desktop-app, pero es web.
Permite administración remota, con, p.ej. firefox, de las máquinas virtuales que uno tenga en un servidor de un data center.

jueves, 11 de septiembre de 2008

CSS gratis para dejar con estilo las páginas web

http://www.styleshout.com/

Sólo piden poner un link en los créditos a su página, vale la pena...
Vamos a ver cómo queda Tuna y su página web con un buen estilo.

Process Explorer v11.21


Interesante aplicación para ver los procesos, así como con ctrl-alt-supr, pero de manera mucho más detallada:



The unique capabilities of Process Explorer make it useful for tracking down DLL-version problems or handle leaks, and provide insight into the way Windows and applications work. http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx

miércoles, 10 de septiembre de 2008

Monitorear memoria, cpu, etc con comando linux top

El comando ps a veces no da buenos resultados, para esos casos, usar top:

ps -wfea --cols=400 | grep "algun_identificador_del_proceso" | egrep -v "grep|vi" | awk '{printf("%s\n",$2)}'|head -n1|xargs top -n 1 -b -c -p | grep java| awk '{printf("Cpu: %s Memoria: %s Recurso: %s Compartido: %s\n",$9,$5,$6,$7)}'

Comando linux para hacer pipe de la primera linea

head - output the first part of files
-n N
print the first N lines instead of the first 10

lunes, 8 de septiembre de 2008

Acceso a objetos COM desde .net

Siempre olvido las herramientas que se usan para acceder a COM desde .net, para que no pase de nuevo:
"COM Interop Part 1: C# Client Tutorial"
la papa es usar Tlbimp.exe

viernes, 5 de septiembre de 2008

Parche para que prototype permita ajax con methods PUT, DELETE, etc

Acerca del post anterior de este tema, en la discusión se agregó una interesante solución, que es agregar un argumento forceMethod=true/false en la creación del objeto Ajax. Así, para cuando se quiera forzar usar el método (ej: DELETE) se ingresa forceMethod en true y así se deja al programador la decisión de usar o no métodos no compatibles con todos los browsers (aunque sí para IE7 y Firefox3)

http://prototype.lighthouseapp.com/projects/8886/tickets/289-allow-put-delete-and-other-http-methods-on-ajax-requests

miércoles, 3 de septiembre de 2008

Manejo de XML en PHP5

SimpleXMLElement permite parsear XML y manejarlo como objetos php:
$xml = new SimpleXMLElement($xmlstr);
echo $xml->movie[0]->plot;

y escribir estos objetos php como un string xml
echo $xml->asXML();

Referencia:
http://cl2.php.net/manual/en/simplexml.examples.php

El encoding interno es UTF-8. Si se necesita obtener en ISO-8859-1:
// This is what we have today
$sxml = simplexml_load_string($xmlstr);
//$sxml = simplexml_import_dom($dom);
var_dump($sxml->asXML()); // OK
echo utf8_decode($sxml->menu->historico);

$internalEncoding = 'iso-8859-1';
$sxml = simplexml_load_string($xmlstr, $internalEncoding);
//$sxml = simplexml_import_dom($dom);
var_dump($sxml->asXML()); // OK
echo $sxml->menu->historico; // now, no need of utf8_decode

Referencia:
http://bugs.php.net/bug.php?id=32431

Tuna news: reconexiones automáticas

Ahora Tuna tiene un proceso en background que revisa cada conexión y cada port-forwarding y si algo está abajo, lo sube automáticamente. Esta revisión es cada minuto.

http://sourceforge.net/projects/tunadmin/

martes, 2 de septiembre de 2008

Vaciar input de un socket antes de escribir en él y esperar respuesta

Antes de escribir en un socket para luego intentar leer la respuesta, es bueno vaciar todo el buffer de entrada. Esto para que no pase que cualquier byte escrito por el servidor al otro lado (por iniciativa propia) se asuma como parte de la respuesta al comando enviado y conduzca a un error

Solr case sensitive wildcard searches

Al poner un * solr lo toma como que ya hiciste la pega de analizador, toma la palabra tal cual la escribiste y la busca en la BD de palabras que está en lowercase. Por eso, "Kong*" hace que busque en una BD donde está "kong", por lo que no arroja resultados.
Si buscas "Kong", ahí sí que hará la tarea de análisis, entre las cosas que hará está ponerla en minúsculas y encontrará a kong.
Cuando buscas sin *, puedes poner mayúsculas y minúsculas. Si buscas Kong, kong o kong*, no tiene problemas en encontrar resultados.
La idea es que si le pones * solr lo toma como que ya le estás ayudando de manera suficiente al motor de búsqueda, y se salta la tarea de análisis, por lo que él no hará más modificaciones a la query con *, como ponerla en lowercase, quitarle espacios, guiones, etc.
Entonces, se necesita que las búsquedas con * vayan en minúsculas.
Ref:
Wildcard queries are tricky here. What happened when you indexed is the analyzer lowercased the terms. But wildcard "terms" are not analyzed (think about stemming and other types of filters, where passing a wildcard term just doesn't make sense).
http://groups.google.com/group/acts_as_solr/browse_thread/thread/42920dc2dcc5fa88

ant al compilar un jar toma todos los .java

Si eclipse logra compilar un proyecto e incluso hacerle run, pero al intentar compilar el jar con ant falla, puede ser que haya un directorio con archivos .java que ant los esté tomando en su compilación, plop!

lunes, 1 de septiembre de 2008

Parche para que la libreria jsch permita saber estado de conexión de un forwarding

Session.java:
public boolean isPortForwardingLConnected(String boundaddress, int lport){
try {
PortWatcher pw = PortWatcher.getPort(this, boundaddress, lport);
if(pw==null)
return false;
return pw.isConnected();
} catch (Exception e) {
return false;
}
}

PortWatcher.java:
private ChannelDirectTCPIP channel;
En run() setear el channel de la clase
public boolean isConnected(){
if(channel==null)
return false;
return channel.isConnected();
}

Charsets encodings (latin, UTF, ISO) en apache, mysql, php, etc

rfc2376 acerca de los documentos XML:
"the use of the charset parameter is STRONGLY RECOMMENDED...
"UTF-8" [RFC-2279] is the recommended value, representing the UTF-8 charset.
UTF-8 is supported by all conforming XML processors [REC-XML]"

En apache:
AddDefaultCharset On enables a default charset of iso-8859-1
http://httpd.apache.org/docs/2.2/mod/core.html

En Mysql:
By default, MySQL uses the latin1 (cp1252 West European) character set and the latin1_swedish_ci collation that sorts according to Swedish/Finnish rules. These defaults are suitable for the United States and most of Western Europe.
http://mysql2.mirrors-r-us.net/doc/refman/5.0/en/character-sets.html

latin1 is the default character set. MySQL's latin1 is the same as the Windows cp1252 character set. This means it is the same as the official ISO 8859-1
http://dev.mysql.com/doc/refman/5.5/en/charset-we-sets.html

Internet Explorer:
Microsoft Internet Explorer uses the character set specified for a
document to determine how to translate the bytes in the document into
characters on the screen or on paper. By default, Internet Explorer uses
the character set specified in the HTTP content type returned by the
server to determine this translation. If this parameter is not given,
Internet Explorer uses the character set specified by the meta element
in the document. It uses the user's preferences if no meta element is
specified.
http://msdn.microsoft.com/en-us/library/aa752010(VS.85).aspx

Timeout en ibatis

De acuerdo a la documentación de ibatis, el timeout de queries fue incorporado a partir de la versión 2.2.0.

defaultStatementTimeout
(iBATIS versions 2.2.0 and later)
This setting is an integer value that will be applied as the JDBC query timeout for all statements. This value can be overridden with the “statement” attribute of any mapped statement. If not specified, no query timeout will be set unless specified on the “statement” attribute of a mapped statement. The specified value is the number of seconds the driver will wait for a statement to finish. Note that not all drivers support this setting.

Parche para que prototype permita ajax con methods PUT, DELETE, etc

"request" function of Ajax.Request class, simulate other verbs (e.g. DELETE, PUT, HEAD, etc) over post.

Why restrict to only get and post requests?

To enable prototype use servlets of my project (that requires DELETE and PUT methods), as a patch, I replaced in that function this line:


this.transport.open(this.method.toUpperCase(), this.url,
this.options.asynchronous);

by this:


this.transport.open(this.options.method.toUpperCase(), this.url,
this.options.asynchronous);

and works perfectly.

http://prototype.lighthouseapp.com/projects/8886/tickets/289-allow-put-delete-and-other-http-methods-on-ajax-requests