Jan 21, 2010

"cannot enable executable stack as shared object requires: Permission denied" on Fedora Core Linux

I've got this problem while trying to run Linux. It is actually the problem of the security program in Fedora Core.

Here is how you solve it.

Open the terminal and switch to root user, by typing "su -".

Now type "setenforce 0".

And that's it. Your problem's solved !

JsHttpRequest problem

One of AJAX Library, JsHttpRequest, supports a lot of stuffs (e.g. file upload through iframe). It worked fine, until I used it for my facebook application.

The problem is that the outer frame is on facebook.com. The inner frame is on my server.

JsHttpRequest makes use of the outer frame, which is on a different domain. Therefore, the "permission denied" exception is thrown.

It is thrown on this commmand: top.JsHttpRequestGlobal = JsHttpRequest;

The source code is also obfuscated.

Therefore, I have decided to implemented my own AJAX upload library !

Jan 20, 2010

Flickering free .NET form

To achieve a flickering free form, Only enabling DoubleBuffered property is not gonna work.

You need to add this in the main form:


protected override CreateParams CreateParams {
get {
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000;
return cp;
}
}


This does not speed up the painting process. It just makes your form invisible while the painting process is being done.

Here is the reference: link

Jan 11, 2010

InvalidAuthenticityToken

A controller always throw InvalidAuthencityToken, if it receives HTTP Post from a form which is not created from the controller itself.

It is the Rails protection mechanism.

Therefore, to solve it, we have to turn it off.

In the controller, just add this line:

protect_from_forgery :only => [:create, :update, :destroy]


It specifies that the protection mechanism only applies to those three actions (create, update, and destroy).

For other actions, they can receives a third-party HTTP Post without throwing InvalidAuthencityToken.

Debugging Rails

I've just had a painful experience: Rails does not accept an HTTP request from facebook canvas, and all it returns is HTTP 422 status, which practically means nothing.

After googling for a while, I have found a way to debug a rails server. Simply, runs

ruby script/server


and that is it. You will see debugging message from Rails on the terminal.

And another good thing about it is that you do not need to restart the server everytime you make a change.