Friday, 3 May 2013

Writing Code - Building a chat application in Java - Session 1


Hey Guys! In this series, we will be building a chat application in java. I think this will be a great chance for you all guys out there wanting to do something hands on in Java.

Thursday, 2 May 2013

Removing password expiry from your unix machine (Linux and Solaris)

Here's a quick one. If you have a server and you do not want the password for a user to expire (as it can screw some things up while its active), you need to execute the following commands as root:

passwd -x -1

where is the username whose password expiry you wish to remove. For instance, in my case, if username is dm014, I executed:

passwd -x -1 dm014

I have tested this and it works flawlessly on linux and solaris.

Wednesday, 1 May 2013

Compiling C++ easily on Linux (Easy C++ build system)

I was developing some C++ stuff on my Linux virtual machine and wanted to create something that would make it easy for me to compile C++ code. So I wrote up some bash code and added it into .bashrc as a function. Here's the code:

function cpprun(){
        echo "Checking if output directory exists..."
        if [ ! -d "./output" ]; then
                echo "Creating output directory..."
                mkdir "./output"
                echo "Output directory created."
        elif [ -f "./output/cpprun.o" ]; then
                echo "Backing up previous output..."
                mv ./output/cpprun.o ./output/cpprun.bak.o
                echo "Backup finished."
        fi

        echo "Running g++ compile..."
        g++ -o ./output/cpprun.o *.cpp
        if [ -f "./output/cpprun.o" ]; then
                echo "Compile finished."
                echo "Running output..."
                echo "-----------------"
                ./output/cpprun.o
                echo "-----------------"
                echo "Run finished."
        else
                echo "Compile failed."
        fi
}


Add this to your .bashrc script and then you should be able to compile your C++ code by typing cpprun in the base directory.

Saturday, 20 April 2013

Changing mysql username and password used by phpmyadmin

So, I had to do this the other day and I got a bit confused. After poking around a bit, I finally found it. If you have xampp installed, go to the install directory. In my case, this directory is C:\xampp which is the default directory. Locate the phpmyadmin folder and open it. Locate the config.inc.php file within the phpmyadmin folder. Open up the file. You need to make change in the following two lines:

$cfg['Servers'][$i]['user'] = 'root'; 
$cfg['Servers'][$i]['password'] = 'password'

The underlined parts are the ones that you've got to change. This file contains a lot of admin stuff so make sure you look around a bit and understand what it does.

If you don't know what you are doing, ensure you take a backup of the file before changing things.

Sunday, 14 April 2013

How to prevent class redefinition errors in C++

I have just started learning C++ and have been getting a lot of these errors. I finally found a solution to this after spending some time on the internet.

Say for instance you have a class called "Animal" and g++ complains that this class is being redefined. Just add the following two lines at the very top of the Animal.h file:
#ifndef ANIMAL_H
#define ANIMAL_H


and add the following at the very bottom of the file:
#endif

So, if your class is called SomeClass, then it will be SOMECLASS_H instead of ANIMAL_H. You should have these in every header file. It prevents that header file from being redefined more than once.

Saturday, 13 April 2013

How to tell which Linux partition a directory is on?

This is really simple. First of all, you need to know the full path to that directory. "cd" into that directory and type:
pwd

and it will display full path of the directory you are in. Remember that or even better, copy it to the clipboard. Type the following command to know the name of the partition:
df

where replace with the full path of your directory. This in my case becomes "df /data/android/sample".

If you are already in the directory, you can type "df ." and it will give details about the partition you are currently on.

The output should be something like:

Filesystem    1024-blocks      Free %Used    Iused %Iused Mounted on
 /dev/hd4            32768     16016   52%     2271    14% /


The highlighted part is the name of your partition.

Saturday, 12 January 2013

Pizza Ordering System source (Session 2)

Hey Guys! Thanks for watching my video. In case you haven't, the video is down below:



I hope the video as helpful to you. Please comment below the video or this post for any suggestions/queries. You can download the source code by following the link below:
https://www.box.com/s/civvyq1d2wzz69xydqi4