Download Managers for Ubuntu

 

I left Download managers long time as the Firefox or even chrome (though it doesn’t support resume in a good way) is reliable enough. But recently on downloading Windows 8 Developer preview image I was a bit skeptical on using the built-in download manager of Firefox especially because of slow Internet connection I have.

gwget (have your heard of old wget utility?) and uget are the popular download managers available for Ubuntu Linux. gwget is a classic download manager. It’s doesn’t have much flashy features. It simply works. On the other hand uget is also available for free which has lot of additional features we’re looking for.

You can see the features in the respective websites

UGet Features
gwget features

Install gwget

sudo apt-get install gwget

Install uget

sudo apt-get install uget

 

IDLE A Simple IDE for Python

 

Learning Python is really cool stuff. Python is an interpreted language and an IDE is not really required to write Python programs (a.k.a scripts). But during the learning, going back and forth between the editor and console and running programs are not so convenient.

The default distribution of Python (the latest stable version when writing this post is 2.7) includes a very basic yet flexible IDE( you can directly execute within) called IDLE . This fundamentally enough for learning purpose but it’s not recommended for managing large projects.

The options are pretty simple and straightforward as notepad but it provides a proper editor with syntax highlighting and auto alignment (which is quite important for Python programs). IDLE uses tkinter GUI toolkit. It’s coded 100% in python (it’s even a python file if you see). Of course it works with variety of platforms including Windows and Linux. Also contains a basic (not full fledged) debugger. It also contains the python console (interactive interpreter) where you can try out the things without writing the programs in the files

You can start it by executing idle.py located under Python Installed folder (C:\Python27\Lib\idlelib) ( start using python idle.py from command prompt)

 

How to sort a List of custom object?

 

To use the List::Sort() function with user defined class objects,
Either we have to provide comparator function
or
Derive the corresponding class from IComparable interface and implement CompareTo function to define the behavior of the compare functions.

This is not only applicable for list but also any other generic containers or array to use the built-in sort option.

Either the comparator or the interface implementation must return an int Less than zero - This instance precedes obj in the sort order.
Zero - This instance occurs in the same position in the sort order as obj.
Greater than zero - This instance follows obj in the sort order.

See the examples below

Using Comparator

class Book
{
    public Book(string id, string name, string author)
    {
        ID = id;
        Name = name;
        Author = author;
    }
    public string ID { get; set; }
    public string Name { get; set; }
    public string Author { get; set; }

}
......

List listBook = new List();
        listBook.Add(new Book( "103", "Code Complete", "Steve MC"  ));
        listBook.Add(new Book("101", "Effective C++", "Scott Meyers"));
        listBook.Add(new Book("102", "CLR Via C#", "Jeff Prosise"));

    listBook.Sort( CompareBook );

......
    static int CompareBook(Book a, Book b)
    {
        return a.ID.CompareTo(b.ID);
    }

Using delegates

Delegates are also similar to function pointers

        listBook.Sort(
            delegate(Book a, Book b)
            {
                return a.ID.CompareTo(b.ID);
            });

Using IComparable

class Book : IComparable
{
    public Book(string id, string name, string author)
    {
        ID = id;
        Name = name;
        Author = author;
    }
    public string ID { get; set; }
    public string Name { get; set; }
    public string Author { get; set; }

    public int CompareTo(object obj)
    {
        return ID.CompareTo(((Book)obj).ID);
    }
}