Friday, 26 April 2013

How to configure Pidgin for Google Talk in Ubuntu?

A lot of beginners face this problem. Specially people using GTalk on Windows find themselves with no chat client on Linux. Let me explain how to configure your Pidgin with Google account -

To install Pidgin open the terminal and type in the following Command -
sudo apt-get install pidgin

After you install it you can directly launch it from your Dash Home by searching for pidgin or just type the following command in the terminal -
pidgin &

Note :  & after the pidgin command is just to inform the terminal to run the process in background. This can be used for any process you wish to tun in the background.

Once you launch Pidgin go to
Accounts ->Manage Accounts -> Add

In Basic tab set the settings as shown in the following image -
 

Note :  If you are using Google's 2 Step Verification you need to generate password for this application. If you don't know about this or haven't set it up you can proceed.

Next in the Advanced tab set the fields as show in below image -


You can set proxy in the Proxy tab if you are using any proxy. Inside it you will have many options like manually setting your proxy or using Gnome Proxy or No proxy at all.

Just click on Add button and you are done.

Note : Above images are from modify account rather that Add new Account but the settings remain the same. Only difference being you will see a Add button instead of Save button at the bottom.

Note : Sometimes buddy list may not show up. This is a bug. Just Exit pidgin and restart again.
What i would recommend is do as follows -
Open the terminal and type
killall pidgin
and then start it again using -f flag
pidgin -f

How to check your Ubuntu and Unity version?

There are two ways to check your Ubuntu version -
  1. Through System settings
  2. Command Line(Terminal)

Using System settings

     You can check Ubuntu version by going to -
     System settings -> System ->Details
You can see below screen - 
From here you can change default applications, view removable media etc.

Using Command Line(Terminal)

  Just open your terminal and type in command -
  lsb_release -a

You can see output as follows

Checking Unity version

    Checking unity version is again fairly simple. Just open the terminal and type in the command  
unity --version . 
You will then see output as follows - 

What are the Meta, Super, and Hyper keys in Linux/Unix?

Meta, Super and Hyper keys are referenced most often in various Linux Distros but many users are unaware what these really are.So let me explain each -


  •  Meta :
    The Meta key is not found on modern keyboard, it's use is sometimes emulated with AltGr (on some international layouts) or the right Alt key on the others. In addition:
    1. Sun keyboards have a meta key (◆) as well
    2. Emacs calls Esc the Meta key
  •  Super :
    The Super key is equivalent to the windows logo key or the ⌘ (command) key. In Ubuntu, it's just another name for the windows logo key.
  • Hyper :
    Hyper is the fourth (counting Ctrl) and last modifier on the Space cadet keyboard. In Ubuntu, its function is undefined (I think), but it can be mapped, as in the screen shot above, to the windows logo key, should it be needed
Though above are default setting you can change the mappings.
I am using Ubuntu 12.04 LTS and in this we can change this mapping from

System Settings -> Keyboard Layout -> options -> Alt/Win key behavior.



Wednesday, 24 April 2013

Linux Command Line Cheat Sheet

Bash Commands

 uname -a Show system and kernel
head -n1 /etc/issue Show distri­bution
mount Show mounted filesy­stems
date Show system date
uptime Show uptime
whoami Show your username
man command Show manual for command

Directory option

pwd Show current directory
mkdir dir Make directory dir
cd dir Change directory to dir
cd .. Go up a directory
ls List files

ls commands

-a Show all (including hidden)
-R Recursive list
-r Reverse order
-t Sort by last modified
-S Sort by file size
-l Long listing format
-1 One file per line
-m Comma-­sep­arated output
-Q Quoted output

Search Files

grep pattern files Search for pattern in files
grep -i Case insens­itive search
grep -r Recursive search
grep -v Inverted search
grep -o Show matched part of file only
find /dir/ -name name* Find files starting with name in dir
find /dir/ -user name Find files owned by name in dir
find /dir/ -mmin num Find files modifed less than num minutes ago in dir
whereis command Find binary / source / manual for command
locate file Find file (quick search of system index)

File operations

touch file1 Create file1
cat file1 file2 Concat­enate files and output
less file1 View and paginate file1
file file1 Get type of file1
cp file1 file2 Copy file1 to file2
mv file1 file2 Move file1 to file2
rm file1 Delete file1
head file1 Show first 10 lines of file1
tail file1 Show last 10 lines of file1
tail -f file1 Output last lines of file1 as it changes

Process management

ps Show snapshot of processes
top Show real time processes
kill pid Kill process with id pid
pkill name Kill process with name name
killall name Kill all processes with names beginning name

File Permissions

chmod 775 file Change mode of file to 775
chmod -R 600 folder Recurs­ively chmod folder to 600
chown user­:g­roup file Change file owner to user and group to group

Tuesday, 23 April 2013

Interfaces in Java

Having learned what are abstract classes and functions we are all set to dig a bit more into polymorphism. Interfaces are based on these two features.



We saw Java does not support multiple inheritance to avoid the problem of Deadly Diamond of Death. To provide functionalities that multiple inheritance support Java provides Interfaces. Interfaces are entities just like classes. We define them one per file and file name must be same as the interface name.

   Synatx for creating an interface is as follows -

    public interface interfaceName{ //code goes here}

Example of an interface is as follows -

public interface Animal{
    public void move();
}


Couple of things to note in Interfaces
  • All functions in an interface are public and  abstract by default. This means all interface contains is function prototype. It's concrete implementation will be in the class which implements it.Note the semicolon after the function. No implementation.
  • For sub class inheriting from super class we say classA extends classB whereas for interfaces we say classA implements interfaceB.
  • You can define variables in interfaces but they are final and static by default.
  • You cannot create objects of interfaces. You can think them as abstract classes for your understanding because after all it contains abstract functions and we know that non-abstract classes can't have abstract function. only abstract classes can.
 Note : If you have an abstract class will all abstract methods as per convention you should go for interface rather than abstract class (As per Java specs).
Let take a look at any class that may implement interface defined above.

 public class Dog implements Animal{
    public void move() {
        System.out.println("Moving..");
    }

    public static void main(String args[]) {
        Animal animal = new Dog();
        animal.move();
    }
}


output :  Moving..
as expected.


Note in above code we have made use of polymorphism. We are using a Animal reference to refer to a Dog object. All rules of polymorphism will follow.

Note :  We can use interface as polymorphic references in method arguments and return types. Meaning you can have a method that return Object of type Animal. At runtime you can return any class Object that implements Animal interface.


Why are the advantages of using interfaces?

  • A class can implement multiple interfaces but can extend only one class.
  • Interfaces can be used across inheritance trees. This means a class from one inheritance tree can implement interface from another inheritance tree.
  • Advantages of polymorphism follows.
  • In later parts of tutorials on Java you will realize generics , design pattens etc depend on this.

One of the OOP principle is "Code for the interface not for implementation" meaning always thing how to design your interface then to worry about your implementation.

Note :  If you have abstract class with all abstract methods (no non-abstract methods) it is better to go for an interface.
t> UA-39527780-1 back to top