How to use SVN (Subversion) on Google Code hosting

Google has generously offered free hosting services for free open source developers to host their projects either by using Mercurial, Subversion or git.

This blog post touches on the basic on to use SVN to maintain source code repository on Google Code Hosting.

Assumptions
This tutorial assume that you have :

  • Created an open source project on Google Code
  • Installed subversion on your GNU/Linux operating system
  • Have source code to import

Initial Import
You must perform initial check-in in order to use the SVN repository. To do that, you must go to your Google Code project, as shown in the screenshot.

subversion svn

From bash terminal, to import your project into Google Code, type:

svn import /path-to/src/ https://your-project-name.googlecode.com/svn/trunk/ --username example@gmail.com -m "initial import"

You'll be prompted to enter googlecode.com password, which you can generate from your Google project page

SVN commit
After initial import, your source code will be made available from Google Code hosting for public access.

You may 'commit' after you've made revision or alteration into the source code. to "commit" type:
[bash]
svn commit -m "added new TextField to user-interface"
[/bash]

the -m specifies change log, you shouldn't commit without a proper log message as this will help other users to track the changes that you've made with your source code.

SVN add: For adding new source files
If you add new files to your source code, just type:
[bash]
svn add <filename>
[/bash]

You may then proceed with "svn commit" to add the file to the repository server.

Recursively add unversioned files into SVN repository
If you've added several new files into source code working copy, these file will be unversioned and thus won't be committed to the subversion server.

You can use this command recursively add new unversioned files to svn repository.

[bash]

svn status | perl -ne 's/^\?\s+(\S.+)$/\1/g;chomp;system("svn add \"$_\"");'

[/bash]

**taken from http://www.amiryan.org/2009/04/22/howto-recursively-add-unversioned-files-into-svn-repository/

Using Apache mod_security and .htaccess to block comment spam on the web

Comment spam is the most annoying thing to web operators. Besides eating up bandwidth, comment spam can pollute web discussions area and which gives bad impression to visitors.

Apache HTTPD mod_security module can be configured to reduce web spam by filtering common keyword, content and referrer used by spam bots around the internet.

Here’s an example of .htaccess file to block common comment spam :

<IfModule mod_security.c>
SecFilterEngine On
SecFilterScanPOST On
SecFilterDefaultAction "deny,nolog,auditlog,status:503"
SecFilterSelective POST_PAYLOAD "(mortgage|viagra|poker|traffic|discount|medical|casino|lyrics|loan)"

</IfModule>

Please ensure that your Apache installation has mod_security module enabled. The method is suitable to be used on websites that receive a lot of user comments like forums, blogs (including WordPress and Drupal) and photo gallery.

Note: This is not a full-proof solution as it depends on the use of keywords.

How to use rsync to backup and synchronize files to USB drive

Portable USB drive (sometimes called pendrive) has gained popularity as a medium for storing documents. Computer users would work on the files that they store on the usb drive and occasionally would copy them on their computer, or vice versa.

However this would cause problems if there’s a lot of files being worked on and transfered between usb drive and computers. Valuable time might be lost solely for identifying which of the files are more recent and need to be updated.

Fortunately there’s ‘rsync’, a tool which can be used to synchronize files between the computer and usb drive. Assuming you use Debian or Ubuntu, you only need to start ‘synaptic’ and select ‘rsync’ package. Once installed, start the terminal application and you can begin synchronizing the files using this command


$ rsync -r -vv /home/username/Documents/ /media/your_usb_drive

The general format of rsync command is :

$ rsync -r -vv <local document directory> <remote backup directory>

rsync only updates file which has been changed and would save time and precious harddisk space from maintaining duplicate files.

A Windows version is also available at : http://www.rsync.net/resources/binaries/cwRsync_3.1.0_Installer.zip

3 ways to get Linux release information from bash terminal

Let’s say you’ve manage to get yourself into a GNU/Linux bash terminal. What can you do in order to determine its distro and release information? Listed here are the three methods to get release information of a running GNU/Linux box.

lsb_release method
You can type “lsb_release -a”

Cat /etc/proc/release method

/etc/*release and /etc/*issue method
Alternatively, you could try typing “cat /etc/*release” or “cat /etc/*issue”.

Cat /etc/proc/release method

/proc/version method
If else fails, you could always try the “cat /proc/version” method to see where the kernel came from.

Cat /etc/proc/release method

Hope this would help!