Ubuntu (Linux) and Windows

The first day I was shipped a Ubuntu 6.06 CD, I was impressed, just by the service though. I didn't have any idea what worth the CD was. When I first installed it and ran, it surprised me. I was always impressed by Fedora before that, but Ubuntu had far many things to offer. They are many; I would just name the most important one - the Ubuntu community ( eg. the Ubuntu forum ). Though the 6.06 lacked several useful features that we now have in Ubuntu, the promise was there. And today, I have not been booting in windows for about three months...

There's a pride in that, the pride of not using pirated softwares, the pride that the open source community has to offer. Its an amazing feeling to be one of those millions of users who are one way or the other contributing to the development of this community. And guess what, using these softwares is one of the ways!

So why would anyone ever need to keep windows? Well, some reasons are just too good to be ignored ( for now that is ). Ubuntu currently does not support my Plustek Scanner. That gives me a reason to run windows now. For a general user, this is not the general problem. Keep it aside, and find out why you would go for the expensive or pirated windows when you have equivalent, or even better options in linux.

Why? Well, Microsoft Word, Excel and Powerpoint are some of the most successful projects of Microsoft, being the favourite of numerous users. Do I hear you tried OpenOffice.org Write, Spreadsheet or Presentation? Give the recent versions a try, I don't think you need any reason to miss your Microsoft habits. Its free, customisable, and growing!

If you are worrying about media players, Ubuntu has some quite better players to offer, eg. Mplayer. There are many more, I have a dozen listed in my menu, and some of them outruns any windows players now. Do not be fooled by any graphical comparisons, seek for the options they give you. There's more to learn about which media player's the best; just go to the Ubuntu forums and search for posts related to media players.

As a programmer, what I still miss ( now a little though ) is the MS Visual C++ IDE. Its the best IDE so far I have seen for C++, unless ofcourse I dont start talking about KDevelop and NetBeans. The latter two IDE's are hugely popular among the linux developers, especially KDevelop, supporting all the features, and even more than what MS Visual C++ IDE has to offer. Moreover, I would personally suggest all the programmers to try NetBeans. SUN developed this IDE with the aim of creating an all-purpose, all-language IDE for development, including C++, Java, Ruby, etc. They are also offering free dvd's now, and I already got my one ! :)

Yea, you might argue that Yahoo Messenger is far better than Pidgin we have now, but its just a matter of time when Pidgin gets much better, and who knows, the developers of Yahoo Messenger might also create one for Linux distros too! There's quite a good chance of everything being Linux compatible soon judging by how fast this community is growing. And I say again, its just a matter of time...

Moreover, the security and personal flavour that Ubuntu ( Linux in the general sense ) has set as a standard is quite remarkable, now that MS Windows itself is trying to learn from it!

Its actually in the feeling of using a completely my-own kind of softwares, the greatest feeling for a computer engineer like me, or those who love to have things in their own distinct ways. Why not just forget Windows and use Ubuntu ( or any other distro of Linux ) for a try? Be desperate to learn, and you would soon forget how your C:\Documents and Settings\you\Desktop looked like!

Make sure you visit:

Posted bysamir at 1:39 AM 1 comments  

Queue : STL in C++

Finally, i get to post something about the queue implementation in stl( standard template library ). The queue is a data structure that defines the so-called push and pop operation, which literally means adding new element at the end of a list, and extracting an element from the front of the list respectively. Thus, if the following numbers are pushed into the queue in order ( 1, 2, 3), the first one to be popped out is 1, then 2 and finally, 3. I hope you get the point.

Here goes an implementation using stl.

#include 
#include
using namespace std;

int main()
{
queue Q;
Q.push( 1 );
Q.push( 2 );
Q.push( 3 );
cout <<>

As you can probably guess, the output is,

1 2 3



Posted bysamir at 1:36 AM 0 comments  

Reinstalling Grub in Ubuntu

Recently I faced trouble with installing fedora with my ubuntu already installed. The grub that comes with fedora can not detect the existence of ubuntu, so I thought I virtually lost my ubuntu installation( at least, I couldn't boot from ubuntu any more )! Thanks to Zaher, da linux-guru( or goru, as i say it :p ) who solved it painlessly...:D This also works when you reinstall windows and pull your hair off trying for just another glimpse of the good-old linux you had...

  1. Boot from any other version of linux if installed( eg. fedora ) or from a live CD ( eg. ubuntu 7.10 )
  2. Open the terminal, and enter the command grub( u must be superuser, eg. in ubuntu, write sudo grub )
  3. enter find /boot/grub/stage1
  4. Here you would see a list of the drives which are potential bootables. Say you want to boot from hda0,1 ( hd0 the first harddisk, 1 stands for the partition count relative to c: )
  5. enter root ( hda0, 1 )
  6. enter setup ( hda0 )
  7. DONE! :)

Posted bysamir at 1:34 AM 0 comments  

Standard Template Library( STL ) in C++

The Standard Template Library, STL for short, adds enormous power to the C++ programmers. Efficiency in programming has been of prime importance since we started using computer as to produce business-level solutions. As a result, the search for more and more efficient data structures continued, and the sooner the programmer adapted an efficient data structure in his solution, the better. In the early programming languages, like C, solutions were possible only in the "structured" way, or I should rather use the words "structured programming" for this purpose.

Structured programming makes use of global functions to break the main problem into subproblems, and calling the required function with proper arguments. Though this seemed to be a quite clean way to deal with small programs, the size and complexity of the programs that we have to deal today demands a far more efficient solution, one that optimizes labor, as well as ensures code reusability. The overall gain demanded was that of reducing the cost of maintaining the difficult-to-deal-with structured code. This is where the need of object oriented programming was felt.

Object oriented programming uses the concept of modelling everything as an object, which may have some attributes ( properties, like the object "human" has properties : black hair, 2 hands, etc... ) and may perform some activity or function ( like the human takes food ). This way, enormous effort can be saved if we just create the required object when necessary, and make it do whatever we need to do then.
The Standard Template Library provides an Object Oriented implementation of the most commonly used data structures and algorithms used for every field of programming. The most commonly used ( as far as personal experience goes ) structures from STL are

  • Queue
  • Stack
  • Vector
  • List
  • Priority Queue
  • Set, Multiset
  • Map, Multimap
  • Bitset
  • Pair

There are also some algorithm functions already hard-coded in STL. So far, I have found the "sort" function very useful. There are many other generic ( template ) functions too, which is better learnt through a STL documentation, for example, at sgi ( http://www.sgi.com ).
From here on, I will publish the contents of each topic in seperate posts titled by the topic name to make things neat.



Posted bysamir at 1:32 AM 0 comments  

Changing The MAC Address ( physical address ) in linux

This works with the 'ifconfig' utility that Ubuntu is shipped. If you are using any other distro that does not have it installed, make sure you download it with the corresponding package manager. The following line sets the mac-address to "111122223344"
sudo ifdown eht0
sudo ifconfig eth0 hw ether 111122223344
sudo ifup eth0

My ethernet adapter was numbered eth0. Check your ether adapter no by simply writing 'ifconfig' and see the default number assigned to it. You should note however that this change is durable until the next restart. Each time you log into Ubuntu ( linux ), you must open the terminal and enter the lines above.



Posted bysamir at 1:30 AM 0 comments  

Interesting Uses of "scanf"

Adding a space after the format specifier (eg. "%d ")

This has the effect of taking an integer (or float for %f and double for %lf) as input and keep the control untill a non-whitespace character is input. This means that if the input is

123                            d

and the function call for scanf was

scanf("%d ",&n); scanf("%c",&c);

where n and c are int and char respectively, the value saved in n is '123' and in c is 'd' (not a space :-) despite the fact that the inputs were seperated by lots of spaces! This could be generalised for cases with newlines and tabs instead of spaces, where the same behaviour is observed.

Now, what's the use of such a facility? Well, in some situations, you may be asked to take a series of inputs, an int ,and then some chars, which are seperated from the int by a series of spaces or a new line. One thing that can be done is to take the whole input as a line in a char array, and use a loop to locate the chars, or do some checking for a new line. But with this trick at hand, the whole thing becomes quite effortless, and clean!



Posted bysamir at 1:25 AM 0 comments