Author Archives: adrian

Redirect a visitor to different pages depending on his browser

If you need to redirect users depending on their web browser, you can use this: RewriteCond  %{HTTP_USER_AGENT}  ^Mozilla.* RewriteRule  ^/$                 /homepage.max.html  [R=301,L] RewriteCond  %{HTTP_USER_AGENT}  ^Lynx.* RewriteRule  ^/$                 /homepage.min.html  [R=301,L] RewriteRule  ^/$                … Read More »

Insert html code into a div using JQuery

When you want to insert a certain HTML code into one DIV you can use the following html code: html> <head> <title>Header&Footer import</title> <script src=”jquery-latest.js” type=”text/javascript”></script> <script type=”text/javascript”> function loadContent(id) { $(“#copy_header”).load(“http://mydomain.com/header.htm”); $(“#copy_footer”).load(“http://mydomain.com/footer.htm”); } </script> </head> <body onLoad=”loadContent();”> <div id=”copy_header” style=”width: 1000px; height: 150px;”> Header is loading.. </div> Lorem Ipsum is simply dummy text of… Read More »

Modify a file from browser

#! /usr/bin/perl use CGI qw/:standard/; print “Content-type: text/htmlnn”; print “Modify the file:$file<br/><br/>”; $action = param(‘action’); if($action eq “”){ $file_content=””; open (MYFILE, “<“, $file); @lines=<MYFILE>; foreach $l(@lines){ $file_content.=$l; } close (MYFILE); print<<frm; <form action=”modify.cgi” method=”POST”> <textarea name=”file” cols=”150″ rows=”30″> $file_content </textarea> <input type=”hidden” id=”action” name=”action” value=”modify”> <br /><br /> <input type=”submit” value=”Modify!”> </form> frm } if($action… Read More »

Perl and treads

Sometimes, you need to create other threads and let the main thread manage other threads. This is an example how to create a thread in Perl: #!/usr/bin/perl use threads; my $thr = threads->create(‘test’); sub test { REPEAT: print “This is a testn”; goto REPEAT; } #!/usr/bin/perl use threads; my $thr = threads->create(‘test’); sub test {… Read More »

Enable/disable hibertaion on XP

For desktop hibernation isn’t the right chooice. It makes sense for notebooks, when you have little battery and your system goes to sleep. The hibernation stores all session data into a file Bellow is how to enable/disable hibernation Control Panel Power Option Hibernation Tab Enable/disable hibernation Cheers,

Compile Apache modules

Sometime, you don’t find the .so file that you need. In this case you must search for it’s source codes and try to comile it. To have this option, you must have httpd-devel / apache-devel installed on your Linux machine. apxs2 -c -I/usr/include/libxml2 -i mod_line_edit.c This will complile mod_line_edit.so Cheers,

Create symbolic link

When you want to create a symbolic link to a certain location all you have to do is ln -s /usr/local/apache/logs ./logs This will create a symbolic link inside current directory: logs which goes to /urs/local/apache/logs Cheers,

Leave a process in background

When you want to close a console, but you want to leave the program which runs active you must run the following commands: Ctrl + Z – this will put the process in background, but in inactive state bg – will activate the process in background If you want to bring it to front fg… Read More »

Show all open ports

When you need to view all open ports from you Linux machine all you have to do is to run the following command in the console: netstat -tulpn Cheers,