Saturday, October 30, 2010

The easiest SVN tutorial ever

Browsing through the Internet its extremely difficult to find  the subversion(svn) commands in an instance and be productive immediately. So here is the step by step list of instructions which can be followed to accomplish the most common tasks of svn.

We would use the project on Sourceforge named Dr. Java as an example.

If the project is already there and you wish to CHECKOUT some code to view here is the command.
$svn co https://drjava.svn.sourceforge.net/svnroot/drjava drjava
Now if you wish to add new file to the svn repository the command is very simple. For example if you wish to add the text file readme.
$svn add README_TEXT
The above command will not add it to the server but add it to the schedule. If you wish to view current status of additions, deletions that are scheduled you could use the command
$svn status
And finally if you are satisfied simple do the following and the commit will be done meaning all the changes will now be part of the repository and a new version will be assigned. REMEMBER adding/ deleting/ changing code in a repository requires permissions. Therefore you might be prompted for passwords during the process.

$svn commit
This is all the information that you need to get past the basic svn commands and concentrate on your project.

Now that you have gone through one cycle it would be easier to use the following command to explore other features of svn.
$svn help

Tuesday, October 26, 2010

MySQL quickest way to look at databases

Looking for MySQL's administration tool is a task. Installing and configuring PHPMyAdmin would take Apache, php and then successful configuration. Then what to do to look at the tables, databases in the fastest possible way to look at tables and execute queries.
$ mysql -u username -p
the command will prompt for a password
mysql> Show databases;
mysql> show tables;
 The above two commands are extremely useful when one wants to look at the databases installed and tables in individual databases.


For example to look at users tables in database drupal the following commands will suffice.

mysql> use  drupal6;
mysql> select * from users;

These commands can be used in both Linux and Windows and are very handy and dont require much to do.

PHP Issue :: preg_split instead of explode function

If the need is to parse a string and extract the words. Then its advisable to use preg_split instead of using the explode function.

Code follows :
preg_split ("/\s+/",$textInput);
where the first argument is the regular expression for finding one or more spaces and the second argument is the input text.

This option works far better than the explode(" ", $textInput).