SVN Quick Installation Guide in Ubuntu

For all of the installation and configuration process, you need to login as root.

Installation

apt-get install subversion (this will install the subversion package) Install any other dependencies if any as required for your system.

Server Configuration

The following steps assume that, the necessary packages are installed. Now we will create the folders and the repository. The SVN repository can be placed in several places in the server. Most common places are /var/svn/ , /svr/svn/,? /home/svn/ etc.

First of all create a new user group named ?subversion?
addgrp subversion
Then add youself and the www-data ( the apache user) to this groups. You can do this by doing the following steps

1 Choose System > Administration > Users and Groups from your Ubuntu menu.
2 Select the Group tab
3 Click the ‘Add Group’ button
4 Name the group ‘subversion’
5 Add yourself and www-data (the Apache user) to this group .

Note: As default, the user configuration does not show system users. To see the Apache user in this list, do the following
a) Start gconf settings editor: Alt+F2 gconf-editor Enter.
b) In the tree, locate /apps/gnome-system-tools/users.
c) Select the “showall” check-box.

Now logout and login again in order to the above changes to be applied.
Now we will create the folder where you can place the SVN repository.

mkdir /home/svn
cd /home/svn
mkdir projectname
chown -R www-data:subversion
projectname
chmod -R g+rws
projectname<-This command will set the gid for proper permissions on all new files added to your SVN repository.

Now issue the following command to create the SVN repository
svnadmin create /home/svn/projectname
chmod -R g+rws projectname Issue this command again, because svnadmin will create folders and files without the write access to the group.

Importing the Project into SVN

Now go the folder where your project folder is present. Then issue to following command to import your project into SVN repository.
svn import projectnamefile:///home/svn/projectname ?m ?Initial checkin of projectname into SVN?

Creating Users

Now we have created the repository and imported the project into it successfully. Now we have to control the access to the repository by creating users.

If the SVN is just now installed the passwd file will not exist and it should be created first,?? under the /etc/subversion folder. This is the file that will contain the authentication details for the users.

to create the the password file, use the command
htpasswd ?c /etc/subversion/passwd username (Enter the username here)

this will prompt us to enter the password for the user. Enter the password. Now the user is added. To add more users use the same command above without using the ?c switch. For example to add another user, use the following.

htpasswd /etc/subversion/passwd username2 (Enter the second username here)

Checking out from Repository

We have created the repository, imported out project into SVN and created the users also. Now to check with the installation and repository, we have to checkout our project from the repository. Go to any of your working folder(not to the svn repository folder) first. To checkout use the following command

svn co file:///home/svn/projectname (this will checkout the projectname from SVN repository)

That?s it we are done with the our basic things to use SVN.? To access SVN over various protocols like http://, https://. svn:// and svn:+ssh// we can refer ubuntu or SVN documentation. For an example I?ll explain how to access our SVN repository over http:// (WebDAV).

Access the SVN via WebDAV (http://)

To access the SVN repository via WebDAV, we must configure the Apache server.
First we have to install the libapache2-svn package
apt-get install libapache2-svn

Then add the following snippet to the /etc/apache2/mods-available/dav_svn.conf file.

<Location /svn/projectname>
DAV svn
SVNPath /home/svn/
projectname
AuthType Basic
AuthName “
projectname subversion repository”
AuthUserFile /etc/subversion/passwd
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>

Hope this will help somebody who would like to get all the basic, necessary steps to start using the SVN. Let me know your feeback.

For further reference see the following links

Installing Apache,PHP5,MySQL on Ubuntu

Apache
sudo apt-get install apache2

PHP
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5

sudo /etc/init.d/apache2 restart

MySQL
To install the MySQL Server and Client packages.
sudo apt-get install mysql-server mysql-client
This will install the mysql server and client packages.
By default, recent Ubuntu/Debian systems install a MySQL Server from the 5-branch.

Set MySQL Root Password
By default, the root account of the MySQL Server is empty. To set the mysql root password do the following.
sudo mysqladmin -u root -h localhost password ‘mypassword’ #replace the ‘mypassword’ with your password.

Connect to MySQL from PHP / Ruby
Now you have Apache+PHP already installed, and want to connect to MySQL from PHP scritps.
For that you have to install one library, which is used to connect to mysql from PHP. Use this command to install the library.

sudo apt-get install php5-mysql

In case you are using Ruby, use the command
sudo apt-get install libmysql-ruby to connect to MySQL from Ruby.

Note : while restarting the apache if you get the following error
apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName

then open the /etc/apache2/apache2.conf file and add the following line
as the last line

ServerName “YourSitename or Servername”

save the file and restart the apache by giving the /etc/init.d/apache2 restart command, you will not get the error anymore.

To Install MySQL Query Browser, an GUI for MySQL

sudo apt-get install mysql-query-browser

After installation, to start MySQL Query Browser go to Applications > Programming > MySQL Query Browser.

Install PHP-GD Library

The GD Graphics Library is useful for dynamically creating, manipulating images. You will need to compile PHP with the GD library of image functions for this to work. However Ubuntu (and Debian) comes with package called php5-gd

To install GD for PHP use the following command.

sudo apt-get install php5-gd

I’ve collected the information from net which are required while installing and configuring Apache, PHP, MySQL and given here. Hope this will help for somebody who can get all information at one place.

Check if a firefox addon is installed or not

While trying to check if one of my firefox add-on is installed or not, I found that, Chrome resources can no longer be referenced from within <img>, <script>, or other elements contained in, or added to, content that was loaded from an untrusted source. This restriction applies to both elements defined by the untrusted source and to elements added by trusted extensions.

Before firefox 3 we were able to check if a firefox add-on is installed or not as following.
using an image tag to load an image in the firefox add-on.
Once loaded trigger the onload event to verify the add-on is loaded.
For example,
< img src=”chrome://youraddonname/content/skin/images/anyimagefilename” width=”0″ height=”0″ onload=”function call here()” style=”visibility:hidden” >;

But this stopped working after firefox 3 and later versions due to security restrictions.
And the extensions won’t interact with the web page in any way.

Continue reading “Check if a firefox addon is installed or not”

Cannot load mysql extension. Please check your PHP configuration

Everytime I install PHP, MySQL in windows boxes I used to get the error message “Cannot load mysql extension. Please check your PHP configuration“. This is because i’d forget to do the necessary steps.

While wandering thru sites most of the people were looking for the same issues.So decided to write a simple post with the necessary steps to solve this while installing PHP, MySQL in a linux box.

PHP.INI settings

1. Modify extension_dir = “./” to extension_dir = “c:/PHP/ext”
2. make sure php_mysql.dll file is inside the folder c:/PHP/ext
3. uncomment the line ;extension=php_msql.dll i.e., remove the comma in the line. so that line will look like
extension=php_msql.dll

Others
4. Copy the libmysql.dll file to C:\WINDOWS folder
5. restart Apache Service

Disable Text Selection in a web page

Here is a sample code snippet, which can be used to disable the text selection in a web page.

But selecting text inside input fields, such as Textarea, textbox and Select (combo) box is not restricted.

//get the browser name,version details
function agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); }

//variables to hold the browser names, and versions
var is_ie = false;
var is_ff15 = false;
var is_ff20 = false;
var is_ff30 = false;
if(agent('msie'))
    is_ie = true;
else if(agent('firefox/3.0.0'))
    is_ff30 = true;
else if(agent('firefox/2.0.0'))
    is_ff20 = true;
else if(agent('firefox/1.5'))
    is_ff20 = true;

/* This is the function which Disables Text Selection in the Document*/
function selstart(e){
    //if not ie and !not ie then return
    if (!agent('msie') && !(!agent('msie')))
        return;

    var selobj=(!agent('msie'))? e.target : event.srcElement
    var topelement=(!agent('msie'))? "HTML" : "BODY"

    if(agent('msie')){
        if ( selobj.tagName!=topelement &&
                (selobj.tagName=='SELECT' ||
                selobj.tagName=='TEXTAREA' ||
                selobj.tagName=='INPUT')
              ){
                  selobj.select();
                  return true;
              }
        else
            return false;
    }else{
        document.body.style.MozUserSelect='none';
        document.body.style.userSelect='none';
    }

}
document.onselectstart=selstart;

This function uses another function named agent to get the browser agent name, whether the user’s browser is Firefox or IE or others. And some global variables for storing browser names and versions.

Whenever a select text event (onselectstart) is fired, the function selstart is executed and the text selection inside the web page is restricted. The function will return true to disable text selection.

Javascript function to Validate IP Address (IPv4)

In one of my current project ( Front end for an ISM Device ), I’ve to validate IP Addresses using JavaScript.

And wrote this function fnValidateIPAddress

The function takes an IP Address as input string and returns either true if the input string is a valid IP Address or false if not. This function checks for the Class C IP Addresses only. This function can be changed further to validate different IP Classes.

Continue reading “Javascript function to Validate IP Address (IPv4)”

Article Contributors Wanted

Hi friends,
Anybody interested in writing articles in my blog. If? interested please let me know.
You can write about anything , however Technical articles is most welcome and preferable.

Even you can contribute any code samples also.? You’d have faced a problem with your daily coding routines, and have found a solution/code fragment. Which you can send it to me and I’ll post it here (of course? with, textual changes if needed).

Ok. What is the Deal?

As of now, I cannot offer anything in $$. But what i can do is, post your details like your name, site url, etc in the article. I can Post your blog links in blogroll, a separate section for your site in the? side bar etc.

Am having an idea of creating a section to post a forum, separate area for posting Code snippets.

Would it be a good idea?

Shoot me with your comments.

piqqus.com Invites Available

Anybody want Piqqus.com invite? Let me know will send you an invitation.

For Newbies, Piqqus.com allow you to vote for people’s site in return you?ll get some points in order for you to promote your article in future. A tool to promote your blog and your sites.

piqqus.com is a stumble/diggs/propells exchange website, meaning that you stumble the available opportunity (other people’s topics), earn stumble point. Once you collect enough stumble point, you may create a campaign for your own topic, other people will stumble for you. This feature is for digg.com, propeller.com sites also.

Even piqqus.com is open for registrations, you cannot take part of the campaigns, i.e., you cannot get points,create campaigns for your site,blog, if you have registered without an invitation.

So invitation will give an option to get points earned, and also you can use the points later for promoting your sites,blogs.

Here is an invite http://piqqus.com/….php?r=97..&c=….mohy49c…4674

Log Javascript Errors Part 2

So far we have seen how to trap the javascript errors in Part 1. Now we have
the data. We will see now, how to send data to the server using AJAX.

Send Data to Server

ajaxCtrl(
    function(){
        return true;
    },"ajxerrorLogger.php",theData
);

The remote file is “ajxerrorLogger.php”.

I?ve used PHP for this.
Instead you can use ASP, JSP also.

This is used to receive the
data sent from the JavaScript error handling function. That’s it.
Our JavaScript errors are now sent to the server silently.

What Next? In the server side, we have to code the “ajxerrorLogger.php”

Receive Data and Write into a File

if($_POST && $_POST['file']!=''){
    $filename = "./errlogs.txt";
    $fh = fopen($filename,"a+");

    //the content is in the form
    //Date    File    LineNo    Error Message
    //(tab delimited)
    $fcontent = date("d/m/Y h:i:s", mktime())."\t".
    $_POST['file']."\t".$_POST['line']."\t".$_POST['err']."\r\n";
    if (is_writable($filename)) {
        if (fwrite($fh, $fcontent) === FALSE) {
        }
        fclose($fh);
    }

}

$fh = fopen($filename,"a+");

 Continue reading "Log Javascript Errors Part 2"

Log JavaScript Errors – Part 1

Introduction

Recently in one of my projects, I’m informed by my QA team
that, in some pages they?re experiencing crashes, or some pages not functioning
properly after sometime.

Our team looked for options where there can be a code
generating errors. And the feedback I got, from the QA team was not helpful to
reproduce the error. But there is no doubt to look for areas only in JavaScript
coding, and not other than JavaScript coding.

Normally while releasing a project, what I would do is, just
escape/bypass the JavaScript errors. That means, whenever there is a JavaScript
error, it will not be reported to the user and they are suppressed.

Background

Following is the function, we can normally use to suppress the JavaScript errors.

var isDebugging = true;
function ErrorSetting(msg, file_loc, line_no) {
    var e_msg=msg;
    var e_file=file_loc;
    var e_line=line_no;
    var error_d = "Error in file: " + file_loc +
                          "\nline number:" + line_no +
                           "\nMessage:" + msg;
    if(isDebugging)
        alert("Error Found !!!\n--------------\n"+error_d);

     return true;
}
window.onerror = ErrorSetting;

window.onerror = ErrorSetting; this line will call the ‘ErrorSetting’
function, whenever there is a JavaScript error. And the function will return
true. So the user will not get JavaScript
error notifications and won’t be
annoyed. Continue reading “Log JavaScript Errors – Part 1”