sexta-feira, 10 de setembro de 2010

Apache mod_deflate


O módulo mod_deflate provê um filtro de deflate que permite que a saída do Apache seja comprimida antes de ser enviada para os clientes (navegadores), resultando em velocidade e economia de recursos.

Abaixo, um exemplo, onde apenas as imagens são dispensadas das regras de compactação:

LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so

#DEFLATE
<IfModule mod_deflate.c>
#REGRAS
AddType text/css css gz
AddEncoding gzip gz
AddType text/javascript js jgz
AddEncoding gzip jgz
RewriteEngine on
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !.*^Mozilla/4.* [OR]
RewriteCond %{HTTP_USER_AGENT} .*MSI?E.*
RewriteRule ^(.*)concated.min.css $1concated.min.css.gz
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !.*^Mozilla/4.* [OR]
RewriteCond %{HTTP_USER_AGENT} .*MSI?E.*
RewriteRule ^(.*)concated.min.js $1concated.min.js.jgz
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css
#Compatibilidade com o Netscape 4.x
BrowserMatch ^Mozilla/4 no-gzip
#Compatibilidade como o IE
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
#Compatibilidade com o Proxy
Header append Vary User-Agent env=!dont-vary
#LOG
#DeflateFilterNote Input input_info
#DeflateFilterNote Output output_info
#DeflateFilterNote Ratio ratio_info
#LogFormat '"%r" %{output_info}n/%{input_info}n (%{ratio_info}n%%)' deflate
#CustomLog /var/log/mod_deflate.log deflate
</IfModule>

Obs.: Basta colocar as linhas acima no seu httpd.conf.



=========English version=========

The mod_deflate module provides the DEFLATE output filter that allows output from Apache to be compressed before being sent to clients (web browsers), resulting in speed and resources saving.

Below, an example, where the image doesn't where only the images are exempt from the rules of compression:

LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so

#DEFLATE
<IfModule mod_deflate.c>
#RULES
AddType text/css css gz
AddEncoding gzip gz
AddType text/javascript js jgz
AddEncoding gzip jgz
RewriteEngine on
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !.*^Mozilla/4.* [OR]
RewriteCond %{HTTP_USER_AGENT} .*MSI?E.*
RewriteRule ^(.*)concated.min.css $1concated.min.css.gz
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !.*^Mozilla/4.* [OR]
RewriteCond %{HTTP_USER_AGENT} .*MSI?E.*
RewriteRule ^(.*)concated.min.js $1concated.min.js.jgz
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css
#Netscape 4.x Compatibility
BrowserMatch ^Mozilla/4 no-gzip
#IE Compatibility
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
#Proxy Compatibility
Header append Vary User-Agent env=!dont-vary
#LOG
#DeflateFilterNote Input input_info
#DeflateFilterNote Output output_info
#DeflateFilterNote Ratio ratio_info
#LogFormat '"%r" %{output_info}n/%{input_info}n (%{ratio_info}n%%)' deflate
#CustomLog /var/log/mod_deflate.log deflate
</IfModule>

PS.: Just put the lines above in your httpd.conf.

Rodando o IE no Linux / Running IE on Linux


Para rodar o Internet Explorer no Linux:

1. Instale o Wine (para o meu Red Hat 5, baixei o wine-core-1.0.1-1.el5.i386.rpm);
2. Baixe o IES4Linux com "wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-latest.tar.gz";
3. Extraia-o com "tar zxvf ies4linux-latest.tar.gz";
4. Entre no diretório com "cd ies4linux-alguma-coisa-a-mais";
5. Rode o IES4Linux com "./ies4linux";
6. Digite "ie6" para iniciar o ie6;

Obs.: Se quiser instalar o IE7, tente o passo 5 com a opção "--beta-install-ie7".

Problemas:
1. Segmentation fault (core dumped) python "$IES4LINUX"/ui/pygtk/ies4linux-gtk.py: tente o passo 5 com a opção "--no-gui";

Lembrete: o IE7 Beta não é estável.



=======English version=======

How to run Internet Explorer on Linux:


1. Install Wine (for my Red Hat 5, I got wine-core-1.0.1-1.el5.i386.rpm);
2. Get IES4Linux with "wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-latest.tar.gz";
3. Extract it with "tar zxvf ies4linux-latest.tar.gz";
4. Access the new directory with "cd ies4linux-something-else";
5. Run IES4Linux with "./ies4linux";
6. Type "ie6" to start IE6;

PS.: If u wish to install IE7, try step 5 with "--beta-install-ie7" option.

Problems:
1. Segmentation fault (core dumped) python "$IES4LINUX"/ui/pygtk/ies4linux-gtk.py: try step 5 with "--no-gui" option;

Remember: IE7 Beta is unstable.

segunda-feira, 6 de setembro de 2010

Java x Bugzilla Webservice

Well, to create a bug using Java against Bugzilla Webservice:
Bem, para criar um Bug usando Java em face do Bugzilla Webservice:

import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.httpclient.HttpClient;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory;

/**
*
* @author Cleórbete Santos
*/
public class BugCreator {
public static void main(String[] args){
HttpClient httpClient = new HttpClient();
XmlRpcClient rpcClient = new XmlRpcClient();
XmlRpcCommonsTransportFactory factory = new XmlRpcCommonsTransportFactory(rpcClient);
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
factory.setHttpClient(httpClient);
rpcClient.setTransportFactory(factory);
try {
config.setServerURL(new URL("http://server/bugzilla/xmlrpc.cgi"));
} catch (MalformedURLException ex) {
Logger.getLogger(BugCreate.class.getName()).log(Level.SEVERE, null, ex);
}
rpcClient.setConfig(config);

//User.login
Map map = new HashMap();
map.put("login", "arthurdent@galaxy.com");
map.put("password", "**********");
map.put("rememberlogin", "Bugzilla_remember");

Object result = null;
try {
result = rpcClient.execute("User.login", new Object[]{map});
} catch (XmlRpcException ex) {
Logger.getLogger(BugCreate.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println(result);

//Bug.create
Map map2 = new HashMap();
map2.put("product", "X-Files");
map2.put("component", "Component X");
map2.put("summary", "Bug creation test");
map2.put("version", "1.2");
map2.put("description", "Once a upon...");
map2.put("op_sys", "Linux");
map2.put("platform", "PC");
map2.put("priority", "Normal");
map2.put("severity", "major");
map2.put("status", "NEW");

result = null;
try {
result = rpcClient.execute("Bug.create", new Object[]{map2});
} catch (XmlRpcException ex) {
Logger.getLogger(BugCreate.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println(result);
}
}

Now I'm coding a BugList, to use in another app. After I'll post here.
Agora estou codando um listador de bugs, para usar em outra aplicação. Depois postarei aqui.

C ya.
Valeu.