Install Firefox 4 On Ubuntu 10.04/10.10

March 24th, 2011 No comments

Firefox 4 is out and is much better, faster, sleeker and safer ! Here’s how you can install or upgrade your Firefox in Ubuntu to Firefox 4. Type the following commands into your Terminal.

Step 1 : Add the official Mozilla Firefox Ubuntu PPA by
sudo add-apt-repository ppa:mozillateam/firefox-stable
Step 2 : Update the repository.
sudo apt-get update
Step 3 : Then, install Firefox 4 package.
sudo apt-get install firefox ubufox

Note : ubufox adds Ubuntu-specific modifications to Firefox.
That’s it !

The mozillateam is the group who maintains Firefox packages for Ubuntu. The stable release is in firefox-stable. Note, that this will upgrade your current Firefox version to 4.0. The packages in this PPA will not be parallel installable with the packages in the official Ubuntu archive. Installing Firefox from this PPA will provide Firefox 4 in English. For other languages you’ll have to install an extension.

Enjoy :)

Check if a given number is power of 2

March 8th, 2011 No comments

Given a number N, we will have to check if N is a power of 2. Powers of 2 include 1,2,4,8,16,32… and so on. Following are FIVE different approaches to solve the problem.

I. This is the shortest method. We perform bitwise AND operation on the given number N and N-1. If the result is 0, then N is a power of 2. If the result is non-zero, it’s not a power of two.
Bitwise AND Operator


int power_of_two(int n)
{
return !(n&(n-1));
}

II. This method uses the basic definition of a logarithmic function. For N to be a power of 2,(log N to the base 2) must be a whole number and not a fraction.


int power_of_two(int n)
{
float x;
x=log(n)/log(2);
if(x-(int)x==0.0) return 1;
else return 0;
}

III. This method makes use of the fact that any number that is a power of 2, has exactly ONE 1s in its binary representation. Hence the above code just counts the no. of ones in the binary representation of the given number.


int power_of_two(int n)
{
int count=0,rem;
while(n>0)
{
rem=n%2;
if(rem==1||n==1) count++;
if(count>=2) break;
n=n/2;
}
if(count==1) return 1;
else return 0;
}

IV. This is a brute-force method which generates powers of two and checks if it is equal to the given number N.


int power_of_two(int n)
{
int count=0,temp;
do
{
temp=(int)pow(2,count);
if(temp==n) return 1;
count++;
}while( temp < n );
return 0;
}

V. This is a recursive implementation. When a number N which is a power of two is divided by 2, the quotient obtained will also be a power of two.


int power_of_two(int n)
{
if(n==1) return 1;
if(n%2!=0) return 0;
if(!(power_of_two(n/2))) return 0;
}

Run MASM 8086 Assembler in Ubuntu or Windows 7(x64) using DOSBox

March 4th, 2011 94 comments

Here’s how to run 16 bit DOS executables like the MASM assembler or Turbo C compiler in Ubuntu (GNU/Linux) or in 64 bit editions of Windows 7 using DOSBox, a DOS environment emulator. DOSBox is available for Linux as well as Windows.

DOSBox installation

For Ubuntu users (using repository)
Open the terminal and type in the following commands to download and install DOSbox in Ubuntu
sudo apt-get update
sudo apt-get install dosbox

You will find it installed under Applications_Menu->Games->DOSBox Emulator

For other GNU/Linux users
Download DOSbox from here.
Open terminal and cd to the directory containing the downloaded tar.gz file. Type in the following commands to build and install :
tar -xzvf dosbox-0.74.tar.gz
cd dosbox-0.74
./configure
make

Check the src subdir for the binary.

For Windows users
Download DOSbox from here.
Run the downloaded .exe file and install it like any other software.

Now that you’ve installed DOSBox, you’ll be able to run any 16bit or 32bit DOS executable inside it.

Download the 8086 MASM Assembler from here. The zip file contains the following files :
masm.exe, tasm.exe, link.exe, bin2hex.exe, exe2bin.exe, td.exe, edit.com and debug.exe

Windows users extract the .zip file into C:\ so that the path C:\8086 contains all the above mentioned files. GNU/Linux users can extract it and place it in say /home/prashanth/8086

Launch DOSBox and type the following commands :
For Linux users :
mount c /home/prashanth/8086
c:

For Windows :
mount c c:\8086
c:

DOSBox in Ubuntu

DOSBox running in Ubuntu

Now the contents of the folder /home/prashanth/8086 or c:\8086 is mounted as c: drive inside the DOS emulator. You can assemble programs inside DOSBox as you do in your Microprocessor Lab under Windows XP; i.e your usual sequence of commands -
edit file.asm
masm file.asm
link file
debug file.exe

When you are done, type exit to quit DOSBox.

P.S : For GNU/Linux users, there’s an alternative assembler known as the NASM. NASM is considered to be one of the most popular assemblers for GNU/Linux.

Downloads :
DOSBox for Linux : dosbox-0.74.tar.gz
DOSBox for Windows : DOSBox0.74-win32-installer.exe
8086 Assembler : 8086_Assembler.zip

TCS Rural IT Quiz National Finals 2010

October 30th, 2010 7 comments

These are the questions from the National Finals of TCS Rural IT Quiz 2010 held at Chowdiah Memorial Hall, Bangalore on 30-10-2010.

First Round (Login)

  • Old IBM(CTRC) logo
  • Hector Ruiz (AMD) pictures
  • Robert Kahn’s picture (TCP/IP guy)
  • Osborne-1 picture(first portable computer)
  • Gordon Moore picture
  • Gopher definition
  • First high-level programming language created by John Backus for IBM in 1954. Original name – ‘speedcoding’ – FORTRAN
  • Alan Turing’s picture

Second Round (Password) – Crossword

  • First mobile was created by ? Motorola
  • Moone Charles wrote a book ‘Superman of Computing’ about whom ? Seymour Cray
  • Ursala Burns is CEO of which company ? XEROX
  • Symantec’s main product ? Norton
  • Passages from life of a philosopher ? Charles Babbage
  • Tanaka Engineering Works is today known as ? Toshiba
  • D2H is a direct to home service by whom ? Videocon
  • Seamus Backley made the design of this ? Xbox
  • Do Communication over Mobile ? DoCoMo
  • Lord Byron’s daughter – Ada Lovelace
  • Greek origin which means Wind Horse ? Asus (from Pegasus)

Third Round (Random Access)

  • Which IT company is called the Big Blue ? IBM
  • This famous processing tool was released with the name ‘MicroPro’ ? WordStar
  • This hardware device is used to connect portable device to[...] ? Cradle
  • In 1982, two friends Warnock and Geshcke found this company ? Adobe
  • How many terrabytes make a petabyte ? 1024

Fourth Round (India Inspired)

  • Logo of the ADHAR project, India’s UUID project
  • ISRO logo
  • Picture of India’s EKA supercomputer
  • C-DOT logo

Fifth Round – TCS (Thirty Crucial Seconds, not TCS ;) )

  • A German Engineer developed a programming language called “Plan Claculus” in 1948. Created the first program controlled Turing-complete computer called Z3 ? Konrad Zuse
  • Originally owned by Seattle Computer Products, created by Tim Patterson ? DOS
  • Slate and Tablet were expected names of this device ? iPad

Score Board
PPC, Udupi, Karnataka : 120
DAV Public School, Orissa : 100
Sanmati High School, Madhya Pradesh : 30
Vibjyor High, Gujarat : 20
Nalanda Vidyaniketan, Andhra Pradesh : 10
St. Xavier High School, Jammu & Kashmir : 0
Virat Public, Rajasthan : 0
Model High School, Nagaland : 0

The competition between teams from Karnataka and Orissa was tough. Nakul and Athreya from PPC, Udupi finally bagged the trophy and a cash scholarship of 75K with an impressive show and loads of goodies. I couldn’t believe that I had won this same quiz two years back. Their level of quizzing and the competition now was way too high. Being their 5th time @ TCS Rural IT Quiz, this was their last chance, so they were determined to take the trophy home this time and were confident that nothing could stop them. Congrats !
P.S: The show’s gonna air on Doordarshan. I don’t know when.

To Webmasters : You are free to copy this article to your blog/website, but kindly link back to this post :)

TCS IT Wiz 2010 Bangalore Edition

August 6th, 2010 12 comments

To Raveesh and Vikram….

Prelims Questions(20 questions, 700 to 800 teams participated !)

Logo shown ? Ubuntu
Company from Canada, Blackberry ? RIM
Retina display technology ? iPhone 4
‘Nothing Like Anything’ tagline ? Micromax
‘What’s the point of option when…” tagline ? monster.com
First browser to have speed dial and mouse gesture features ? Opera
India’s 20$ laptop project name ? Saakshaat
First game to be imported to US from Russia ? Tetris
MobileMe is from ? Apple
This company is called Logicool in Japan, what in India ? Logitech
TelePresence is a Teleconference product from which company ? Cisco
Logo/screenshot ? Apple appstore
Galaxy brand ? Samsung
Expand HTC ? High tech corporation
WebOS ? Palm
Six axis ? Game controller
Decision engine ? Bing
What is the name given to 10 to the power of googol ? Googleplex Read more…