Hasta hace poco, el primer paso para instalar la traducción al español (o cualquier otra) del CMS Drupal era descargarla desde la sección Translations en la página del proyecto, pero esto ha cambiado con la introducción de Drupal Localize, un sub-sitio donde se está concentrando todo el trabajo de traducción al resto de idiomas distintos del inglés.

Para comenzar una instalación limpia de Drupal en español, lo primero que hay que hacer dirigirnos a la sección Download de Drupal Localize, donde encontramos el link hacia el servidor FTP donde se guardan las traducciones. Descargamos el archivo PO correspondiente para el core de la versión de Drupal que vayamos a usar (si es la versión 6, podemos usar este vínculo).

Luego, le cambiamos de nombre al archivo para dejarle solo el código del idioma y la extensión (en vez de tenerlo como drupal-6.17.es.po por ejemplo, lo dejamos como es.po).

Después, colocamos este archivo en el directorio profiles/default/translations (es probable que tengamos que crear el directorio translations).

Finalmente, nos dirigimos al instalador de Drupal y ya debería aparecer la opción Español al comienzo del procedimiento.

Drupal instalation

Tags: , ,

El Chifa es como se le llama a la comida china en el Perú, aunque se diferencia de esta comida oriental en la fusión con el paladar e ingredientes peruanos, que a nuestro gusto, la hace exquisita (por supuesto que la cocina china típica es una maravilla por si sola).

En Toronto abundan los restaurantes chinos y asiáticos en general (principalmente coreanos, vietnamitas, japoneses, thailandeses), por lo que uno no se puede quejar de la variedad de comida. Aunque siempre se extraña el Chifa.

Afortunamente, no es imposible encontrar este tipo de comida aquí. El primer paso es ir a New Sky Restaurant, en 353 Spadina Avenue, Toronto:

Una vez en el sitio, debemos pedir la carta de Chifa, hay al menos una mesera que entiende algo de español y sabe de que estamos hablando con lo de Chifa.

Nos traerán una carta en español, con los típicos platos que encontramos en cualquier chifa en el Perú, así que podemos comenzar a pedir con confianza Arroz Chaufa, Wantan Frito (lo que más extrañaba del chifa), Pollo Chi Jau Kay, Sopa Wantan, KamLu Wantan y por supuesto, no podemos olvidar pedir Inka Kola, que con todo combina (lamentablemente no encontramos en la carta Pollo Tipakay).

El último paso es disfrutar como si estuviéramos en el Perú.

Tags: , , , , , , ,

Tags: , , ,

While I was writing some code on VBScript to avoid manual tasks that we currently do with a bunch of files, I needed to automatically upload some information extracted from all these files to a SQL database. One way to do it is using a Web Service that receives the data and store it into the database.

Our Web Service is able to receive the following protocols: SOAP 1.1, SOAP 1.2 and HTTP POST. For simplicity, we are going to use HTTP POST, which receive the parameters in the query string format (param1=value1&param2=value2&…). In the other protocols (SOAP) we would need to send the parameters in a XML way (which is more powerful but a little more extensive to implement).

The expected HTTP request will be:

POST /WebService.asmx/WebMethod HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: length

param=string

And the response (in XML format):

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">string</string>

So, to call the Web Service directly from the VBScript, we can use the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'The object that will make the call to the WS
Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP")
'The object that will receive the answer from the WS
Set oXMLDoc = CreateObject("Microsoft.XMLDOM")
 
strParam = "string to pass"
 
'Tell the name of the subroutine that will handle the response
oXMLHTTP.onreadystatechange = getRef("HandleStateChange")
'Initializes the request (the last parameter, False in this case, tells if the call is asynchronous or not
oXMLHTTP.open "POST", "http://localhost/WebService.asmx/WebMethod", False
'This is the content type that is expected by the WS using the HTTP POST protocol
oXMLHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
 
'Now we send the request to the WS
oXMLHTTP.send "parameter=" & strParam
 
Sub HandleStateChange()
	Dim szResponse
	'When the call has been completed (ready state 4)
	If oXMLHTTP.readyState = 4 Then
		szResponse = oXMLHTTP.responseText
		oXMLDoc.loadXML szResponse
		'If the WS response is not in XML format, there is a problem
		If oXMLDoc.parseError.errorCode <> 0 Then
			WScript.Echo "ERROR:"
			WScript.Echo oXMLHTTP.responseText
			WScript.Echo oXMLDoc.parseError.reason
		Else
			WScript.Echo "Result: " & oXMLDoc.getElementsByTagName("string")(0).childNodes(0).Text
		End If
	End If
End Sub

The ready state tells us about the connection with the Web Service:

  • 0: Uninitialized – open() has not been called yet.
  • 1: Loading – send() has not been called yet.
  • 2: Loaded – send() has been called, headers and status are available.
  • 3: Interactive – Downloading, responseText holds the partial data.
  • 4: Completed – Finished with all operations.

Tags: , , ,

In C#, to convert a String into a Stream object, we need to use the GetBytes method (from the Encoding.ASCII package), this way:

byte[] bytes = Encoding.ASCII.GetBytes(xmlContent);

And then, use that byte array when instantiate a Stream (for example, MemoryStream or FileStream):

MemoryStream stream = new MemoryStream(bytes);

Tags: , , ,

There is a bug on Windows 7 (and Windows Server 2008 R2) that relates to corrupted files error messages and affects several SVN’s operations (like commit and update). The detailed error message you can get is something similar to:

svn: Can't move '[repo]\.svn\tmp\entries' to '[repo]\.svn\entries': The file or directory is corrupted and unreadable.

And you can even get a Windows error message telling you about a corrupted file.

As I found in here and here, there is nothing to be afraid of, it is just another bug/error on Windows that is going to be fixed on SP1 (but there is already a hotfix ready to install). I haven’t finished test it myself (just missing the restart after the hotfix installation).

The hotfix’s download requires you to give your email address to Microsoft before they send you the link where you can download it (some way annoying). I have uploaded on my own server to avoid the process if I need it again, so you can get it from here if you want (remember that you should NOT download executables from non-trusted sources as they can contain viruses and harm your computer).

Tags: , ,

Using Subversion to deploy and maintain updated web applications like WordPress, Joomla or even your development on a web server is very handy. One of the downsides I have found to this solution is that your web root will have hidden .svn directories all over the place (one per each directory on your application). This directories will not be hidden for the web server, so it is important to forbid browsers the access to them.

If you are using Apache, you can use the tips on this page.

If you use Apache 2.2 (I have not test it on other versions, but it should work also on 2.0 version) and have access to the configuration files, you can create the file /etc/apache2/conf.d/svn with the following content:

<Directory ~ "\.svn">
    Order allow,deny
    Deny from all
</Directory>

This will deny access to all the .svn directories on your web server. After you have create this file, do not forget to restart the web server so the changes can take effect.

Tags: ,

This are some problems that you may encounter after installing Munin:

Apache modules are not tracking, so they are not showing statistics, you may want to check Munin logs (specifically /var/log/munin/munin-node.log) to see what is going on.

If you got something like Can’t locate object method “new” via package “LWP::UserAgent”, you need to install the package libwww-perl which contains the LWP::UserAgent required. Thanks to Crowdway.

If you already have installed the libwww-perl package, but Munin is still not showing data, you may need to enable and configure the status module on Apache. Make sure you allow localhost (and the name of the server as well) to access the location server-status on apache2.conf or status.conf. Also, this plugins need the ExtendedStatus flag to be On.

You should have something like:

<IfModule mod_status.c>
#
# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status
# Uncomment and change the ".example.com" to allow
# access from other hosts.
#
ExtendedStatus On
<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from localhost ip6-localhost
    Allow from vps02.graphium.net
    #Allow from .example.com
</Location>
<IfModule>

Sometimes you can get permission errors on your logs, so the best way to get rid of them is to ensure that all involved files in Munin process are own by munin user and group. We can run as root:

 $ chown -R munin.munin /var/lib/munin /var/log/munin /var/www/munin

There are some plugins that require a parameter to work. For example, those that refer to networking (if_, if_err_, ip_) needs the network interface we want to track. In my case (VPS), this is venet0, but on a usual box it can be eth0.

We can list the available interfaces by running the command:

$ ifconfig

Then, to correctly enable this modules, we need to append the name of the interface:

$ ln -s /usr/share/munin/plugins/if_ /etc/munin/plugins/if_venet0

A convenient way to see the result of each module, we can run them independently:

$ munin-run apache_processes
busy80.value 7
idle80.value 1
$ munin-run if_venet0
down.value 7721322
up.value 37550800

By this command, we can ensure that the plugin is working fine and getting results.

Tags: , , , ,

Munin is a small tool for monitoring resources on servers. I think it is very useful, specially on small VPS, that needs to save resources. Reports are written as HTML files, so we will need a Web Server like Apache to see this reports.

First, we install it and add some extra plugins:

$ sudo apt-get install munin munin-plugins-extra

Now, we can make some changes to the default configuration, located at /etc/munin/munin.conf. For example, we can change any of the paths where Munin works:

dbdir /var/lib/munin
htmldir /var/www/munin
logdir /var/log/munin
rundir /var/run/munin

Specially, the htmldir path, where all the reports are written to see through Apache or the one you are using. Remember to move the directory /var/www/munin to where you wanted if you change that configuration line. We can protect this directory with an htaccess file to only give access to some users.

We can configure email notifications if a change occur (like from a OK situation to a WARNING). To do this, we just need to uncomment or add the following line:

contact.someuser.command mail -s "Munin notification" your@email.com

By default, Munin will monitor localhost, but we can add other boxes (clients), these machines will only need to install munin-node package.

Then, we can enable some plugins (more plugins can be found here and here). To do this, we need to create a symbolic link per each plugin we want to activate. I’m going to enable apache and mysql modules, but you are free to enable the modules you need:

$ cd /etc/munin/plugins
$ sudo ln -s /usr/share/munin/plugins/apache_* .
$ sudo ln -s /usr/share/munin/plugins/mysql_* .

Each time a module is enable or disable, we need to restart the service, so we can do the following:

$ sudo /etc/init.d/munin-node restart

Also, it is recommended to reassign all files on the htmldir to munin user and group by doing:

$ sudo chown munin.munin -R /var/www/munin

And then, to avoid waiting 5 minutes until munin cron runs again, we force it by:

$ sudo /usr/bin/munin-cron --force-root

If we are not completely satisfied with the default template, we can modify it, they are HTML files (with some minor special template tags). Anyone with some knowledge of HTML and CSS can do that. We can even download other already created templates (I have found some errors on that template’s JavaScript, I hope I’ll get some time to post the modified template, in the meanwhile, if anyone need it, please drop me a line to send you the files).

Finally, as this post is not as complete as I would like, I leave some links that may help:

Tags: , , , , ,

On my work, I have a box with WinXP, running Virtual Box as a host, and a Ubuntu Server 9.10 box as a guest. My problem is that the firewall on the corporate network does not allow Ubuntu to update the date and time against any NTP server (like pool.ntp.org or ntp.ubuntu.com). So, I need a way to keep the hour updated on the guest. Fortunately, VirtualBox has the ability to synchronize it from the host, the only thing I need to do was to install the Guest Additions package.

To do this, first, we need to click on Devices/Install Guest Additions (from the VirtualBox menu).

Then, on the Ubuntu Server, we install some pre-requisites:

$ aptitude install build-essential linux-headers-$(uname -r) -y

Now, we will mount the virtual CD-ROM (where the Guest Additions are):

$ mount /dev/cdrom /mnt/

And then, run the installer script (there is a 32-bit and 64-bit versions). For 32-bit (which is the most probable, as VirtualBox Open Source only supports 32-bit guests):

$ /mnt/VBoxLinuxAdditions-x86.run

Or for 64-bit guest:

$ /mnt/VBoxLinuxAdditions-amd64.run

It should install the available modules (like timesync), and drop a fail message saying that X server
was not found, which is OK as we are working with a server without GUI.

Finally, we umount the CD-ROM:

$ umount /mnt/

Now, the guest box time should be sync with the host, so we have one less thing to worry about.

Tags: , , ,