2012 in review

The WordPress.com stats helper monkeys prepared a 2012 annual report for this blog.

Here’s an excerpt:

4,329 films were submitted to the 2012 Cannes Film Festival. This blog had 21,000 views in 2012. If each view were a film, this blog would power 5 Film Festivals

Click here to see the complete report.


Revision controlling with Subversion

Subversion also more famouly know as SVN is a version management tool used to manage source code, documents, designs, etc.. in software develpment. SVN is a centralized version control system where the main repository resides in a centralized environment and the parties involved in a project can download a copy of the repository to their local machine to introduce the changes. Once the changes are applied to the files/documents on the local copy, next step is to transfer them to the server. As mentioned SVN is a centralized version control system committing the changes to the server means incrementing the revision of the file/document on the main repository, when the other members of the team updates their local copy of the repository the change also get reflected into their local copy, where as with decentralized version control systems like Git, Mercural, etc.. the users can maintain their own local repository which they can commit the changes without pushing directly to the project in the main repository.

In the following sections I’m going to focus your attention on following aspects of setting up and maintaining a version control system taking SVN as a reference.

  • Setting up a new repository
  • Restoring and Backup a repository
  • Basic commands in SVN

Setting up a new repository

Step 1: Lets start by installing SVN(subversion) and required Apache module (libapache2-svn) into a Linux server/desktop (Debian based distributions but with rest of them are also follows the same). All the commands involve in this process needs to be executed as a super user, so always keep in mind to append sudo to the begining.

$ sudo apt-get install subversion libapache2-svn

Step 2: Creating the target directory for SVN repositories. Please note that name given to the SVN repository will be use as the base URL, which will be used to browse the repository via a web browser. The name can be mapped to any domain name or subdomain name (prefferbly via a virtual host) of your choice for easy access, which I’m not going to explore into it. Execute the following command on the terminal window.

$ sudo mkdir /path/to/svn-repository

Step 3: Introducing a new group to manage the activities of the SVN repositories. Let’s call that group as subversion, execute the following command on the terminal window.

$ sudo addgroup subversion

Step 4: Grant the ownership of the directory create to hold the SVN repositoriesy to the newly created subversion group and the www-data, the group which manages the permissions on resources that is requested via Apache Web server.

$ sudo chown -R www-data:subversion /path/to/svn-repository

Step 5: Now change the mode of the folder created to hold the repository using the following command.

$ sudo chmod -R g+rws /path/to/svn-repository

Step 6: Now we have finished the steps involve in setting up the environment, next let’s look at the steps to create a new project repository called svnproject.

$ sudo svnadmin create /path/to/svn-repository/svnproject

Step 7: Adding user(s) to the newly created subversion group. To introduce a new password file along with a new user, include -c and issue the following command, once hitting enter it prompts for the password and it’s confirmation.

$ sudo htpasswd -c /etc/subversion/passwd Hayesha

To introduce a new user to the existing subversion group to access and carry out activities execute the command as follows

$ sudo htpasswd /etc/subversion/passwd Piushan

Step 8: Grant access to the newly created SVN repository (eg: svnproject) via WebDAV protocol, configure the Apache Web server by adding the following snippet to dav_svn.conf file located under /etc/apache2/mods-available/. Place the following block of code snippt inside dav_svn.conf to reflect the parameters of the newly created SVN repository.

$ sudo cp /etc/apache2/mods-available/dav_svn.conf /etc/apache2/mods-available/dav_svn.conf.bk # Creating a backup of the existing configuration file
$ sudo vim /etc/apache2/mods-available/dav_svn.conf

<Location /svn-repository/svnproject>
    DAV svn
      SVNPath /path/to/svn-repository/svnproject
      AuthType Basic
      AuthName "Svnproject Repository"
      AuthUserFile /etc/subversion/passwd
      Require valid-user

Step 9: Grant the ownership of the newly created SVN project to subversion and www-data groups.

$ sudo chown -R www-data:subversion /path/to/svn-repository/svnproject/

Step 10: Now change the mode of newly created SVN project using the following command.

$ chmod -R g+rws /path/to/svn-repository/svnproject/

Step 11: Restart Apache server.

$ sudo /etc/init.d/apache2 restart

Reference: https://help.ubuntu.com/community/Subversion

Restoring and Backup a SVN repository

  • Backup a SVN repository
    • The SVN‘s administrative tool named dump will be used to backup a project inside the SVN repository, this can be achieved using following cmmand.

      $ svnadmin dump /path/to/svn-repository/svnproject > /path/to/backup/svnproject_25_11_2012.dump

  • Restoring SVN project to an existing repository using a SVN backup (dump).
    • Create a new project called recoverproject inside the SVN repository as follows

      $ svnadmin create /path/to/svn-repository/recoverproject

    • Load the SVN dump of the project into new repository location as follows. This may take a while depending on the number of revisions had on the SVN dump used for the restoring.

      $ svnadmin load /path/to/svn-repository/recoverproject < /path/to/svn-project-backup.dump

Reference: https://wiki.archlinux.org/index.php/Subversion_backup_and_restore

Basic commands in SVN

Getting a checkout from a main repository of a SVN project. The syntax is svn checkout <url> or by using svn co <url>, co is the shorten form of checkout.

$ svn checkout http://svn.example.com/svn-repository/svnproject/trunk/xxx

To update the local copy (development version) with the main repository of the SVN project. Navigate to the location of the local copy and execute the following command. svn update or by using svn up (up is the shorten form for update.

$ svn update

In the instances where the local copy (development version) of the code base is out of sync (in a lower revision number(s) compared to main repository of the SVN project’s revision numbers), need to execute the svn cleanup command to sync the local copy to bring it to the server’s current revision in order to avoid conflicts that experience while committing the code.

$ svn cleanup

To transfer the modifications in the local copy of the code base to the main repository of the SVN project need to use the svn commit command. It’s always considered a best parctice to introduce a comment using -m ‘comment’ along with the commit command.

$ svn commit -m "adding the modification done to bla_bla-bla.ext" <filename.ext>

To introduce new file(s) and folder(s) to the SVN project on server use svn add folowed with svn commit commands.

$ svn add <filename.ext> or <folder name>
$ svn commit -m "adding the new file(s) or folder(s) called filename.ext or foldername/" <filename.ext> or <foldername/>

To remove file(s) and folder(s) from the main repository of the SVN project use svn update, svn delete followed by svn commit commands.

$ svn update
$ svn delete <filename.ext> or <folder name>
$ svn commit -m "removing existing file(s) or folder(s) called filename.ext or foldername/" <filename.ext> or <foldername>


    Setting up osTicket to handle customer inquires

    osTicket is a widely used open source ticket management systems that can be easily configured to create tickets to inquires via emails, web interface, etc…


    It is always advisable to download the latest stable version of osTicket and move it to preferred location to continue the installation process.

    Configuration & Database creation

    Move the content inside uploads/ to root of the installation folder.

    Navigate to includes/ folder and rename ost-config.sample.php to ost-config.php and grant write permission.

    $ cp ost-config.sample.php ost-config.php
    $ chmod +w ost-config.php

    Connect to MYSQL server and create a new database to hold the tables and the corresponding data of the ticket system.

    $ mysql -u<username> -p<password>
    mysql> create database <database_name>
    mysql> show databases;

    Basic Installation: Step 1

    As shown in Figure 1 provide the relevant information to suite your requirement and click Install to proceed to next step. The information it captured is categorised in to following subsections.

    • Web path & title – Installation URL path and the Title(provide a meaningful title to describe your exact purpose) of the osTicket system
    • System email – The email address which acts as the sender for all the outgoing email via the ticket system.
    • Admin user
    • Database

    osTicket - Basic Installation

    Figure 1: osTicket – Basic Installation

    Basic Installation: Step 2

    As shown in Figure 2 once the installation is successful carry out the following two tasks.

    • Revoke write permission from ost-config.php using the following command
      • $ chmod 644 include/ost-config.php
    • Delete the setup directory
      • $ rm -fr setup/

    Installation success

    Figure 2: osTicket – Installation Successful


    Configuration: General Preferences and Settings

    Login to Administration section (http://www.site-url.com/scp/login.php) or click on the Admin Panel link as shown in Figure 2 or invoke Admin Panel (http://www.site-url.com/scp/admin.php) section using the upper navigation bar found on the top right corner. Refer Figure 3.

    osTicket - Configuration - Admin Panel

    Figure 3: osTicket – Configuration – Admin Panel

    Next click on the Settings tab as shown in Figure 3. This section let you manage parameters such as General Settings, Date & Time, Ticket Options & Settings, Email Settings, Autoresponders and Alerts & Notices. I’ll be mainly focusing on parameters found under General Settings and Email Settings.

    • General Settings – Common parameters like Site URL, Title, Site Online/Off-line, Enable Auto Cron, etc…
      • Helpdesk Status – This lets us manage the ticket system go online or off-line.
      • Helpdesk URL – This allows to update the URL fro the ticket system.
      • Default Department – The categorisation which the system used to managed the Staff/Users in the system.
      • Enable Auto Cron – This enables the cronjob tasks scheduled by the system. I’ll be discussing how to configure and set the conjob tasks on the server.
    • Email Settings – Especially important if planning to use the ticket system to fetch email to generate tickets.
      • Incoming Emails – This settings provide the ability to control fetching of emails via POP/IMAP email and email piping.
      • Outgoing Emails – The mail server which outgoing email will be handled.
      • Default System Email – The email address which acts as the sender for all the outgoing email via the ticket system.

    Configuration: Admin Panel -> Settings -> API

    This section provide the facility to generate the API key used in remote email piping feature. This key needs to be updated in the automail.php or automail.pl files located inside scripts/ folder. Please provide the following two information to generate the API key.

    • Add New IP – Provide the IP address assigned to the server/instance the system is hosted.
    • API Passphrase – This will be used to generated the API key used in email piping feature.

    Setting up Email address(es) to automatically fetch to generate tickets.

    Lets see how to configure an email account in osTicket to automatically generate a ticket(email ticket) for each email received to the email address. Navigates to Admin Panel -> Email -> Add New Email. Please provide the following information described below.

    • Email Info – Settings are mainly for emailed tickets.
      • Email Address
      • Email Name – The text used as the FROM name of the email.
      • New Ticket Priority – The priority level which the ticket should be assigned.
      • New Ticket Dept – The department which the ticket should get categorised.
      • Login info – Required when IMAP/POP and/or SMTP are enabled
        • Username – The email address or the email ID of the email account.
        • Password – The password of the email account.
    • Mail Account – Setting for fetching incoming emails. Mail fetching must be enabled with autocron active or external cron setup.
      • Status – Enable/Disable email fetch feature
      • Host – Hostname of the POP or IMAP service of the email server
      • Port – The port number which POP or IMAP service available
      • Protocol – IMAP or POP
      • Encryption – Yes or NO
      • Fetch Frequency – The time interval which the ticket system to check for new emails.
      • Maximum Emails Per Fetch
    • SMTP Settings – When enabled the email account will use SMTP server instead of internal PHP mail() function for outgoing emails (optional).
      • Status – Enable/Disable the use of following SMPT details for all out going communication
      • SMTP Host – Hostname of the SMTP service of the email server
      • SMTP Port – The port number which SMTP service available
      • Authentication Required? – Yes or NO

    Scheduling the Cron job task

    Under General Preferences and Settings we came across a parameter to enables the cronjob tasks scheduled by the system. Open up your favourite editor (preferably vi). and issue following commands.

    $ crontab -l //to list already scheduled tasks
    $ crontab -e //to scheduled a new task

    If this is the first time it will prompt you to select the editor, select one that preferred by you and it will open up the crontab, schedule the task as follows.

    # m h dom mon dow command
    MAILTO="hayeshais at gmail.com" # this will fire an email upon failure to execute any of the scripts to this email address
    */5 * * * * nobody /usr/bin/php /var/www/api/cron.php
    */5 * * * * nobody wget -q -O /dev/null --user-agent=4816EC4CA293EE2EFCA2C89C88750F4A http://<www.helpdesk.examplesite.com>/api/cron.php
    */5 * * * * nobody /usr/bin/php -q /var/www/api/cron.php


    The value of Education looses when it is given a price tag

    All these years every citizen of our country was blessed with free education and thanks to that the literacy rate was well over 90%. As Sri Lanka being a third world country majority of the citizens falls between middle and lower income category, so the free education plays a critical role to help build their lives by opening up the doors to reach out the world.

    I’m happy to say that thanks to our country’s free education policy I was able to continue my education up to obtaining my Bachelor’s Degree, which helped me to engaged in a field that gave me the opportunity to give something valuable to my country and to its people. While I was in the university got the opportunity to enrich my knowledge across vast number of areas. Although my degree title says B. Sc. in Information Technology but the content of it didn’t restrict me to a limited knowledge domain. During my eight semesters and four June terms I took around 5o modules but for a student how does a similar degree in a private institute will get the opportunity to take just above half of it. In my three years of industry engagement I got the opportunity to work with just over 50 odd people and to interview nearly 100 candidates, the common factors I notice while working and interviewing people who obtained their bachelors degree from private institutions them are as follows.

    • Majority of them lack the knowledge of fundamentals.
    • Majority of them knew just to shoot out fancy words but failed to deliver results.
    • Majority of them lacked the enthusiasm of learning and advancing themselves to the next level.
    • Majority of them used that knowledge just to earn a salary.

    By looking at the current situation of our country’s education I really feels scary about its future because we have come to a critical point which is at the verge loosing the benefit of free education. Our country has three ministers assigned to look after the activities of the education system but unfortunately what has happened can be easily describe by saying “too may cooks spoil the broth”.

    • Every year all the major public exams are full of faulty questions
    • Results of the public exams are faulty.
    • Officials responsible for the above mentioned issues were not properly punished and same issues were repeated every year.
    • Has drastically reduced the government funding over the years to less than 2 % of the GDP.

    We should get together and join hands to protect the free education for our future generation, failing to do so will cause a great misery to the development of our country and will made our future generation suffer from it. For example currently the US citizens are facing a huge crisis settling the loans obtain for their education, lets not help to develop such a staggering environment here.

    Run nodejs server continuously using forever

    By last Friday morning the open bugs count raised above 150 mark and we managed to take it down to under 25 by the end of the day, thanks to the dedicated effort by the team. Among them, one was to make the Nodejs server run continuously. In our application we are using the Nodejs to implement a near-realtime notification module, which involved pushing notifications and updates to the Web application as well to the Mobile application. Faye module was used to implement the identified channel patterns required to identify different user types and their respective activities each user type executes.

    Nodejs is a powerful, Event-driven, I/O based or JavaScript based server that can be used to develop interactive applications. It was developed on top of the V8 JavaScript engine.

    Installing Nodejs on Ubuntu

    I came across an easier approach to install Nodejs via the Ubuntu Package Manager.

    $ sudo apt-get install python-software-properties
    $ sudo add-apt-repository ppa:chris-lea/node.js
    $ sudo apt-get update
    $ sudo apt-get install nodejs npm

    Install Forever

    In the last command it installed the Node Package Manager(npm). The npm provides the facility to install any module to Nodejs in a manner similar to installing application on Ubuntu via apt-get.

    $ sudo npm install forever --global

    Setting the –global parameter makes the module accessible globally

    Updating Nodejs & the modules to latest stable release

    Nodejs comes with a module called n aka node version manager provides the facility to update the module to its latest or stable release.

    Install n

    $ sudo npm install --global n

    Updating Nodejs using n

    $ sudo n --global latest/stable
    $ sudo n --global custom v0.x.x

    Updating Nodejs modules using n

    $ sudo n --global npm
    $ sudo n --global forever

    « Older entries Newer entries »