P0L0's Blog Opensource Projects and IT experiences

24May/100

Spidermonkey – Execute javascript from console

mozilla

SpiderMonkey is the code-name for the Mozilla's C implementation of JavaScript. This is useful to test part of our JavaScript from the console or in scripts.

In Debian we have a package called spidermonkey-bin.

apt-get install spidermonkey-bin

After installing you will have a program called smjs.

If you start the program without parameters you will get a Javascript shell, in which you can write and test javascript.

$ /usr/bin/smjs
js> function test() {
print('test');
}
js> test
function test() {
    print("test");
}
js> test();
test
js> function test() {
print('test');
test2(123);
}
js> function test2(param) {
print ('test2: ' + param);
}
js> test();
test
test2: 123
js>

To exit the shell, just press "Ctrl+D".

It's important to note that in spidermonkey you doesn't have the "document" Object. If you want to print out text, you cant use document.write, you should use print.

document.write('test'); // In browser
print('test'); //spidermonkey

You can also make smjs to execute the content of a file.

10May/102

Installing TRAC with mod_wsgi using virtualenv

This guide is for installing Trac as a user using virtualenv for a isolated Python environment so that the whole installation runs under a specific user.

First of all we need to install needed packages

apt-get install libapache2-mod-wsgi python-virtualenv python-setuptools

Once we have installed the required packages proceed to create the Python environment

mkdir /usr/local/trac
cd /usr/local/trac
virtualenv python

We now have the isolated Python environment locate under /usr/local/trac/python.

To make possible to use easy_install with repositories we need to upgrade easy_install. I use this to install Trac plugins directly from SVN.

/usr/local/trac/python/bin/easy_install -U trunk

We now can install trac 0.12 using the 0.12b1 SVN Tag (http://svn.edgewall.com/repos/trac/tags/trac-0.12b1 or Trac==0.12b1) or directly from SVN Trunk:

/usr/local/trac/python/bin/easy_install http://svn.edgewall.org/repos/trac/trunk

This will download and install the latest trunk version for Trac.

2Oct/090

Vlogin – Roundcube Plugin

I just released the first version of my Vlogin Plugin for Roundcube. This plugin is based on the Vlogin for Squirrelmail.

For now the only implemented function is that you can login using only "user" and roundcube will authenticate against IMAP using the domain extracted from the webmail URL.

You can get download the plugin from the Vlogin sourceforge project page.

8Aug/090

Postfix+Amavisd-new+Spamassasin+Clamav

Since I had to disable the PTR check in Postfix at Binware because in Spain 90% of mail servers are badly configured and they were all rejected, and now we have lot of spam.

So I decided to install Spamassassin and Clamav to detect and reject some of this spam.

First of all, we need to install needed packages:

apt-get install spamassassin amavisd-new clamav clamav-daemon

We will begin configuring amavisd-new, the configuration files are at /etc/amavis/conf.

In file 20-debian_defaults I changed the header that will be added to each mail processed:

$X_HEADER_LINE = "AntiSpam/Antivirus Scanner at $mydomain";

We need to activate antispam and antivirus check in amavis, this is found in file 15-content_filter_mode. We need to uncomment @bypass_virus_checks_maps and @bypass_spam_checks_maps. The file will look like this:

18Jul/081

AEAT+Firefox = “ha generado una firma no valida”

Como cada trimestre, toca presentar las declaraciones del IVA, por lo que me decido a arrancar VMware para hacerlo desde windows como siempre, pero por alguna razon extraña, IE7 no me deja elegir el certificado, asi que decido probarlo con Firefox3 y cual es mi sorpresa al ver que ya puedo acceder sin problemas a las pantallas de presentacion de declaracion, pero cuando le doy a "FIRMAR Y ENVIAR", me sale un bonito mensaje que dice "ha genereado una firma no valida" y no me deja continuar.

Despues de buscar un poco por google me encuentro con este articulo que explica como hacer funcionar el certificado en Linux con Firefox. Asi que me puse a mirarlo con Firefox3, el cual ya tiene el certificado de FNMT instalado.