martes, 29 de marzo de 2011

Detectar el tipo de una variable en Javascript

Código JavaScript:

var _getType = function( inp ) {
var type = typeof inp, match;
var key;
if (type == 'object' && !inp) {
return 'null';
}
if (type == "object") {
if (!inp.constructor) {
return 'object';
}
var cons = inp.constructor.toString();
if (match = cons.match(/(\w+)\(/)) {
cons = match[1].toLowerCase();
}
var types = ["boolean", "number", "string", "array"];
for (key in types) {
if (cons == types[key]) {
type = types[key];
break;
}
}
}
return type;
};

Ver Articulo completo

jueves, 24 de marzo de 2011

JQuery Bloquear pagina mientras se carga Load...

Usando BlockUI

The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser[1]. When activated, it will prevent user activity with the page (or part of the page) until it is deactivated. BlockUI adds elements to the DOM to give it both the appearance and behavior of blocking user interaction.

Ver Pagina Oficial

Implementando nuestro propio Loading

lunes, 21 de marzo de 2011

Cliente para Protocolo WebDav

Codigo de ejemplo para utilizar WebDav
Ejemplo 1
Ejemplo 2
Tutotial de Apache Http Integrando WebDav Server

hosting a webdav folder using tomcat 6

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.jackrabbit.webdav.client.methods.PutMethod;

...

// WebDAV URL:
final String baseUrl = ...;
// Source file to upload:
File f = ...;
try{
HttpClient client = new HttpClient();
Credentials creds = new UsernamePasswordCredentials("username", "password");
client.getState().setCredentials(AuthScope.ANY, creds);

PutMethod method = new PutMethod(baseUrl + "/" + f.getName());
RequestEntity requestEntity = new InputStreamRequestEntity(
new FileInputStream(f));
method.setRequestEntity(requestEntity);
client.executeMethod(method);
System.out.println(method.getStatusCode() + " " + method.getStatusText());
}
catch(HttpException ex){
// Handle Exception
}
catch(IOException ex){
// Handle Exception

viernes, 18 de marzo de 2011

Paginacion con Hibernate

Codigo de ejemplo para implementar la paginación en Hibernate con Spring.
ver codigo

miércoles, 16 de marzo de 2011

Usar Filtros para Session en Hibernate con Tomcat

Este foro se explican las ventajas y desventajas de utilizar el Patron Open Session in View con Hibernate y Tomcat.
ver foro


Using Hibernate with Tomcat

domingo, 13 de marzo de 2011

JQuery con otras librerias(Prototype)

Este articulo muestra como podemos usar en combinacion JQuery y Prototype.

http://docs.jquery.com/Using_jQuery_with_Other_Libraries

jueves, 10 de marzo de 2011

Apache Jakarta Commons IO

En este tutorial vamos a hacer una presentación de la librería Jakarta Commons IO de Apache.
Leer link completo

miércoles, 9 de marzo de 2011

martes, 1 de marzo de 2011

Crear Servicios en Windows XP

Link Fuente

Ahora los pasos necesarios, para hacer que una aplicación, archivo ejecutable se ejecute al incio del ordenador de forma automática, como un servicio. Esto está testeado en windows XP home y XP Profesional.

PASOS A SEGUIR:
0- Copiar los archivos instsrv.exe y srvany.exe a la carpeta windows\system32

1-ejecutar en consola:
C:\Documents and Settings\Admin>c:\WINDOWS\system32\instsrv.exe NOMBRE_NUEVO_SERVICIO c:\WINDOWS\system32\srvany.exe

Respuesta consola:

” The service was successfuly added!

Make sure that you go into the Control Panel and use
the Services applet to change the Account Name and
Password that this newly installed service will use
for its Security Context. “

2 - ejecutar: regedit -> HKLM\system\CurrentControlSet\Services -> aparece el servicio creado

3 - crear carpeta llamada “Parameters” (boton derecho nueva clave)

4 - crear dentro de parameters nuevo “valor alfanumercio” llamado “Application”: con el valor : RUTA/nombre_del_ejecutable_del_servicio.exe

5 - [opcional] ir a administrar servicios para activar el servicio o reiniciar para que se encienda. Por defecto se crea el servicio con Encendido automatico.
Descargar archivos necesarios crear-servicio en windows


Ejemplo de usar el comando para convertir una ejecutable en servicio de windows:

C:\>instsrv.exe
Installs and removes system services from NT

INSTSRV ( | REMOVE)
[-a ] [-p ]

Install service example:

INSTSRV MyService C:\MyDir\DiskService.Exe
-OR-
INSTSRV MyService C:\mailsrv\mailsrv.exe -a MYDOMAIN\joebob -p foo

Remove service example:

INSTSRV MyService REMOVE

C:\>c:\WINDOWS\system32\instsrv.exe Servidor-EasyPHP c:\WINDOWS\system32\srvany.
exe

The service was successfuly added!

Make sure that you go into the Control Panel and use
the Services applet to change the Account Name and
Password that this newly installed service will use
for its Security Context.

C:\>