Archive for June, 2008

Lighttpd install perl, mysql support in chrooted jail

Perl is Practical Extraction and Report Language, which is quite famous and used by many web application.

A Perl5 database interface to the MySQL database is provided by libdbd perl mysql shared library.

You can install perl support via mod_fastcgi or mod_cgi.

Following are essential steps to run perl based application in chrooted lighttpd setup along with MySQL

This article is part of securing and running Lighttpd in chrooted jail.<!–more–>

Step #1: Enable mod_cgi

# lighty-enable-mod cgiOutput:

Available modules: auth cgi cml fastcgi proxy simple-vhost ssi ssl trigger-b4-dl userdir
Already enabled modules:
Enabling cgi: ok
Run /etc/init.d/lighttpd force-reload to enable changes

Now modify the file /etc/lighttpd/conf-enabled/10-cgi.conf file as per our chrooted jail setup:
# cp /etc/lighttpd/conf-enabled/10-cgi.conf /root/
# vi /etc/lighttpd/conf-enabled/10-cgi.conf
Modify the file as follows:
server.modules += ( “mod_cgi” )
alias.url += ( “/cgi-bin/” => “/home/lighttpd/cgi-bin/” )
cgi.assign = (
“.pl” => “/usr/bin/perl”,
)

Save and close the file.

Step #2: Prepare the file system for perl

# mkdir /webroot/usr/share -p
# mkdir /webroot/usr/lib -p
# mkdir /webroot/home/lighttpd/cgi-bin/ -p
# chown www-data:www-data /webroot/home/lighttpd/cgi-bin/

Step #3: Put Perl in the jail

Copy /usr/bin/perl to /webroot/usr/bin directory:# cp /usr/bin/perl /webroot/usr/bin

Install shared object/liberires used by perl:# /bin/l2chroot /usr/bin/perl

Now copy all perl files and modules stored in /usr directory:
# cp -avr /usr/share/perl /webroot/usr/share
# cp -avr /usr/share/perl5 /webroot/usr/share
# cp -avr /usr/lib/perl /webroot/usr/lib
# cp -avr /usr/lib/perl5 /webroot/usr/lib

Step #4: Put Perl MySQL DBD shared libraries in the jail

Copy shared libraries needed to load perl mysql.so (which is stored at /webroot/usr/lib/perl5/auto/DBD/mysql/mysql.so). Type the following command:
# /bin/l2chroot /usr/lib/perl5/auto/DBD/mysql/mysql.so

Please note that you have just enabled perl mysql support. However /usr/lib/perl5/ directory contains other shared object used by perl. You need to enable them to use rest of Perl features.

Step #5: Restart the lighttpd

# /etc/init.d/lighttpd restart

Create window-like element with mootools

We continue our serie related to mootools with a tutorial that shows us how to build a window-like element on our page, that can be resized and moved. Based on previous tutorials, we will will create first the html and apply some js code to it, to obtain what we want. This tutorial is a simple one, so will cover only the basics to help a beginner to understand easier. A future tutorial will show, based on this, ho to create a class for windows.

So, for the beginning we need to set the html.We need next elements:

the ‘window‘ div = the window itslef;

the ‘topbar‘ - the window’s topbar, that will be used to move the window and to hold the title;

the ‘resizer‘ - the element that will resize the window.

All will look something like his:

window like element made with mootools

Ok, we’ll give some ids to elements, “win” for window, “topbar” for topbar, “resizer” for resizer - pretty straight :).

the html code will be something like this:

<div id="win">
    <div id="topbar">window title</div>
    <div id="resizer"></div>
 content
</div>

We won’t cover here the CSS part,please look at the demo for basic style.

Then on event domready, we set “win” to be draggable, with handle set to “topbar”, set to be resizable, with handle “resizer”, and put some limits on resize, using “limit” property. This way we avoid some bad behaviour , like minimize too much the window.

document.addEvent( 'domready' , function() {

	$('win').makeDraggable({'handle':$('topbar')});
	$('win').makeResizable({
		'handle':$('resizer') ,
		'limit':{'x':[220,400], 'y':[120,400]}
		});

} );

Well, that is all. Pretty easy and nice, no?

Here is the demo.

This is done with MooTools V1.11. A later tutorial will explain how to do this with V1.2.

Let me know your thoughts or questions.

Singles Singles

Mootools 1.2 stable is out!

It seems that MooTools team just released the stable 1.2 version of popular framework mootools. Great job, and a big step forward.My only concern is what is going to happen with 1.11, as the website for the moment is working in a reduced form, docs, download being available only, but as they said “At least you can download, right?” :) Again, congratulations!    

A beginner’s mootools - create draggable and resizable elements

The today tutorial will try to explain how to make an element draggable or resizable - or even both in the same time, using the MooTools framework. To accomplish this we’ll make use of two functions existent in mootools: makeDraggable() and makeResizable().

This is very simple.We simply select the element we want to be resizable or draggable and use one of those functions:

$(’id_of_the_element’).makeDraggable();

or

$(’id_of_the_element’).makeResizable();

A good idea would be to set in css of the elements “position:relative” as, those functions assume that elements are positioned absolute, and may break your layout. But this depends on the layout you have.

Doing so, a drag of the element will drag it or resize it.

There are some parameters we can use for this functions.

One of this is ‘handle‘. Handle passed to the function will tell what other element is used to manage the drag or the resize of the main element.so something like :

$(’id_of_the_element’).makeResizable({handle:$(’id_of_handler’)});

will have the effect we obtain in demo page, for the orange div.

What do you have to pay attention on is that handle is an selected element so we need to use $(’id_of_handler’).

In the next tutorial we will try to use all the knowledge we learned until now - select and create elements, add events and make draggable or resizable, to create a window-like element than can be resized or moved around our page.

Textmate tricks- open ftp files in tabs,keybindings changes and codebrowser

After searching through editors for Os X, that can go as close as possible to Quanta, my former editor in linux, before I switched to mac, and not founding anything close - or better said close to my habits - I finished choosing 3 editors - Coda, skEdit, and TextMate.

Coda is nice, but I miss auto-completion, as I was used with , skEdit does a really good job, but I miss a codebrowser panel , and again the auto-completion.

Well, now it comes TextMate.

I wanted for it a codebrowser - i need to see my functions, classes and variables - so i used this plugin TmCodeBrowser . Is not a real panel, but I moved it to the right side of the screen, set normal panel and visible on launch, resized the main window until it touch the edge of codebrowser, and seems ok.

What was very unpleasant for me, was that without a project, files were opening in individual windows. I like my desktop clear, so a file tabs solution would be nice. To fix this, in conjunction with using an external ftp manager - I use ForkLift - I had to create a project, and set to it the folder used by ForkLift to cache it’s files

~/Library/Caches/com.binarynights.ForkLift/

save the project, and take care to have it opened before opening a remote file.

Another thing was the autocomplete feature TextMate it has. I would like to have a classical dropdown, but i think this is the way it reach the speed it has in presenting a suggestion. For a >7000 lines source code, on my G4, other apps become slow, so I get used with this behaviour. What I did not get used with is that key Esc is binded to do operation. Is far, is small and almost always i was pressing the ` key. So I edited the

/Applications/TextMate.app/Contents/Resources/KeyBindings.dict - don’t forget to back-up -

and added this line -

“~ ” = “nextCompletion:”;

that means alt(option) key with spacebar will perform the completion.

I am sure lot of other tricks exist to make TextMate an easier and more pleasant companion for new users of mac, so if you know some, please share.

Thanks.

R’born redesign

Well, after some time from the original launch, we managed to alocate some little time to R’born Development, and we re-skinned our site. This change is intended to come with our new range of services for our clients: eCommerce solutions, CMS solutions on top of php, ajax technologies.

R’born development