Archive for May, 2007
May 31, 2007 at 3:31 pm
· Filed under emacs
In order to reload a file, you can use the macro M-x revert-buffer (if you want you can bind it to a key), or use a more practice trick: use C-x C-v RET. This tell to find an alternate file and by default emacs suggests you the current file.
Permalink
May 31, 2007 at 11:50 am
· Filed under emacs, php, programming
Easy easy easy: how to have php syntax coloring in emacs.
Download the latest version of php-mode. Copy php-mode.el inside your site-lisp directory (on windows could be C:\program files\emacs<version>\site-lisp and the update your .emacs file adding the following lines
;;php-mode.el
(require ‘php-mode)
You will need font-lock enabled. For many information look inside the source file (the comments explain more settings) and for an example .emacs file you can refer to mine.
Permalink
May 31, 2007 at 10:36 am
· Filed under apt, debian, dpkg
This is how I create apt cdrom in order to save disk spaces. I do this when my /var/cache/apt/archives reach 700Mb, so I create a cdrom that I will add to /etc/atp/sources.list with apt-cdrom add.
I don’t know if it’s the right Debian way but it works. If you have something better, use the comments.
I move all deb files into a directory (lets call it /home/davide/cd), then
sudo dpkg-scanpackages /home/davide/cd /dev/null | gzip /home/davide/cd/Packages.gz
Then take all the files within the /home/davide/cd directory and burn a cd.
Permalink
May 29, 2007 at 2:16 pm
· Filed under backup, sitecopy
Every time I have to do a huge update to an application (in this case a web one), I use to make a backup (just “an image”) of that.
I use sitecopy for updating sites and it’s a great and powerful tool. Making a simple image of the remote server on the local machine is very easy but I always forget how to do it, so I’m writing it down.
First of all make a local empty directory in order to hold the downloaded file and then configure sitecopy for using that directory. An example of configuration can be found in a previous post.
For naming the site I use something like the following criteria. Let’s say that we want to manage the www.example.com server, as site in the .sitecopyrc file I use www.example.com for the directory I use for synchronizing (updates, patches): generally the stream is from local to server. I use fech.www.example.com for the backup the stream should be server to local.
Once configured it’s simple
sitecopy -f fetch.www.example.com
sitecopy -s fetch.www.example.com
I’ve noticed that the version of sitecopy under cygwin has a bug (maybe it’s not a bug and maybe it’s not only the cygwin version): when downloading the files, with the -s comman, it will hang up with errors on creating subdirectories. You will need to execute the command more times; one for each inner directory.
Permalink
May 24, 2007 at 11:37 am
· Filed under banshee, debian, linux, mp3, multimedia
I bought some new cds so I would like to listen them from my ipod. I thought to use my new (almost installed) macbook, so I installed banshee. On this laptop I have a Debian etch operating system.
Installing it was very simple, just an aptitude. The problem was that by default Debian didn’t provide support for mp3 and banshee canned only export in wav or ogg. In order to solve the question you have to install the gstreamer0.10-lame (or another version) package. You can find the package on the marillat repositories.
Easy! 
Permalink
May 22, 2007 at 3:30 pm
· Filed under windows, windows update
After a week the problem still persist. In pure Microsoft style, no solution, only workarounds.
Then Microsoft talk about hidden cost of Linux. And what about hidden cost of Microsoft. Who will pay for the two days spent for solving this “windows update feature”
I’ve updated my original post in order to keep all in one place.
Permalink
May 21, 2007 at 4:40 pm
· Filed under javascript, jsp, programming, xmlhttp
Originally posted on December 13th, 2006 in another blog.
Again fighting against an IE6 behavior: the attitude to not report an error. The scenario was the usual: a web page that with xmlhttp ask another page and then populate a div with the content retrieved. Firefox got the right responseText, while Internet Exploder hung up with nothing. Nor an error or the responseText; only an empty responseText.
Why? Muble muble muble.
Naturally it was my mistake, but what the hell, please give me an error.
I forgot the Content-type header on the requested jsp. Solved with
<%@ page contentType="text/html; charset=ISO-8859-1" %>
Permalink
May 18, 2007 at 11:25 am
· Filed under ie, internet explorer, javascript, programming, responseText, web, xmlhttp
Playing a bit on job with xmlhttprequest (more or less on December 2006), I bumped into another IE6 bug (?). I needed to parse an xml stream like the following
<MSG><COD>-1</COD><DESC>blablal</DESC></MSG>
yes, with some empty lines before the XML stream. The problems was that empty lines before the xml stream. While Firefox handled them correctly (ignoring), IE6 hanged up silently (as usual) , so no error displayed. Solved in this way
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState==4){
if(window.ActiveXObject){
result = new ActiveXObject("Microsoft.XMLDOM");
result.async="false";
result.loadXML(xmlhttp.responseText);
}else{
result = xmlhttp.responseXML;
}
cod = result.getElementsByTagName("COD")[0].firstChild.data;
if(cod!="0"){
desc = result.getElementsByTagName("DESC")[0].firstChild.data;
alert("Error while... nn" + desc);
}else{
alert("Operation successful");
}
...
}
};
Ah yes , remember the content-type="text/xml"; charset=...
Permalink
May 17, 2007 at 6:07 pm
· Filed under cakephp, php, programming, web
Originally posted on January 16th, 2007 on another blog.
If you need to delete() an ACL, you need to provide the alias not the id as written on the api. Remember, remember, remember 
Permalink
May 17, 2007 at 3:37 pm
· Filed under emacs, windows
Sometimes ago I posted how to convert a unix file into a dos one and vice versa. This works great on new empty file but cannot work on a already saved file.
What I noticed is that if you are on a windows box and open a unix encoded file you’ll have a lot of ^M character at the end of the line. In my case some rows had only one ^M other more than three. If you use the method described in my previous post
C-x RET f undecided-dos
C-x C-s
C-x C-c
and then reopen the file, you will notice that the file coding is still unix. I think that is because emacs detect the conding type by the first(s) EOL. So first you have to clear the file, then convert the file coding, save, exit and reopen the file.
First let’s define a macro for cleaning the EOL
C-x (
C-a C-s C-q 15 RET RET C-b C-k C-n
C-x )
Let’s now try it on a new line
C-x e
if It works (I’ve typed it by memory not tested) let’s do the whole file
C-u 1000 C-e
If there are more lines repeat the command
Save, exit and reload.
Permalink
« Previous entries