Archive for category Tricks

Remove DOS carriage return

After writing a shell script on Windows and trying to execute it on Linux, I got the following error message:

/bin/sh^M: bad interpreter: No such file or directory

The problem is obviously because the return line character on Windows and Linux are different. But how to fix it in order to execute it on Linux?
I firstly tried to open it, copy the content of the file and paste it in a new file using only Linux command line, but it didn’t work. 🙁

However, I found the following thread which fixed the problem:

Here is what you need to do:

  1. Open your file using vi
  2. Write the command :set fileformat=unix
  3. Save the file using :wq

The file should now run on Linux. 🙂

, , , , , , ,

1 Comment

Redirect traffic to a specific network

This is a little trick which can be useful in some very specific case.

For example, you could have a machine with two network cards. One of the network is behind a proxy and the other one is connected directly to the internet.
You might want to forward all the traffic for to the network which doesn’t have a proxy.

To do this, I am using the command route:

route add <hostname> <target network>

For example:

route add

Note that this command is available on both Linux and Mac.

, , , , ,

1 Comment

Use ServerXMLHTTP through a proxy

The other day, I was trying to use the ServerXMLHTTP object. For information, this object was created to allow you to establish server-to-server HTTP connections.

The code I firstly wrote looked like the following:

Set oXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP") "POST", sURL, false
oXMLHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXMLHTTP.send sParams
Response.Write oXMLHTTP.responseText

with sURL the URL to call and sParams the parameters to send with the URL.

The problem was that oXMLHTTP.responseText didn’t return anything. Or to be exact, it returned an empty string, which was obviously not the expected response… 🙁

After some investigation, it appeared that the problem was because the server was seating behind a proxy. All this is good and well, but the question now is how to tell the application to use the proxy?

First of all, the ServerXMLHTTP object has a setProxy method:
So I tried to add the following line to the previous code:

oXMLHTTP.setProxy 2, "myProxyServer:80", ""

Unfortunately, this didn’t fix the problem. It looks like this line is simply ignored. If somebody knows why, please tell me! 😉

So the solution I finally adopted was to configure the proxy through the proxycfg tool.
There are two ways of using this tool:

  • Import the proxy settings from the current user’s Microsoft Internet Explorer manual settings using the command proxycfg.exe -u
  • Configure the proxy settings manually using the command proxycfg -p myProxyServer:80

This last solution works for me and I hope it will help a few people. 🙂

PS: I found the following page when writing this article: It would have been so good to find it during my investigation but anyway.

, , ,


limitToList attribute prevents flashing

If you have some elements (or even the whole page) that flash/twinkle using RichFaces, it probably means that these elements are AJAX-rendering. The question is by whom and how to fix it?

A lot of tags in RichFaces can AJAX-render elements such as:

    <a4j:jsFunction name="updateName" reRender="showname">
        <a4j:actionparam name="param1" assignTo="#{}"  />                  

On the above example, the JavaScript function updateName will AJAX-render the element which has the ID showname.

In some cases, you would have some elements that would AJAX-render without asking them to do so!
I still didn’t figure it out why. 🙁 (if anybody has an idea, please don’t hesitate to tell me!)

But, I found a way to prevent this!
You simply can add the following attribute to your tag:


You even can add it to the tags that don’t have a reRender attribute.
For example:

    <a4j:poll id="poll" interval="1000" limitToList="true" />

, , , ,

No Comments


Last week, when using the GROUP_CONCAT() function on a MySQL database, I got an unexpected result. 🙁

Indeed, instead of getting my result as VARCHAR types, I got it as BLOB types! For information, a BLOB is a binary large object that can hold a variable amount of data:
Because BLOB values are treated as binary strings, it is not easy to use. This is why we would prefer to have VARCHAR values.

So the question is how to get around this frustrating problem?

The answer is, for once, very simple! 😀
You simply need to:

  • Open your my.ini or my.cnf file;
  • Change the value of the group_concat_max_len system variable to 512 (no ‘k’ suffix);
  • Restart the mysql service

To verify if the value has been successfully updated, execute the following command in your mysql client:

mysql> show variables like "%concat%";
| Variable_name        | Value |
| group_concat_max_len | 512   |
1 row in set (0.00 sec)

Note that you cannot set the value of group_concat_max_len to less than 1Kb using the MySQL Administrator GUI. Which means that the only way to set this system variable to 512 (which is less than 1Kb) is to edit your MySQL configuration file as described above.

, , , ,