Create and Import dumpfile or SQL datafile into mysql database


Here are few commands to easily create and import MySQL data.

To create dumpfile:
mysqldump -u USER -p PASSWORD DATABASE > filename.sql

To import dumpfile:
mysql -u USER -p PASSWORD DATABASE < filename.sql

Export MySQL database structure only:
mysqldump -u USER -p PASSWORD --no-data DATABASE > filename.sql

Export data of MySQL database only:
mysqldump -u USER -p PASSWORD --no-create-info DATABASE > filename.sql

To create dumpfile of all databases:
mysqldump -u USER -p PASSWORD --all-databases > filename.sql

To import dumpfile when either database name is not known or dump has database info:
mysql -u USER -p PASSWORD < filename.sql

USER : database username
PASSWORD : password
DATABASE : database name to which datafile is to be imported

cls: command not found


I used ‘cls’ for it does clear screen and ls.
After I upgraded my ubuntu, i can’t use that any more. It showed:

cls: command not found

Finally I have found the solution.

You have to create a alias for the command you want to use.
For example, for cls

$ alias cls='clear;ls'

You can make more aliases,

$ alias cll='clear;ls -lh'

These aliases will vanish on your next login. So to make the change permanent you can add it to your ~/.bashrc or ~/.bash_profile. Just add the whole alias line as these files are executed (as bash scripts) on login.

Install network simulator on ubuntu


This blog post is regarding installing network simulator on Ubuntu.

Make sure you have the following packages installed:

build-essential autoconf automake libxt-dev libx11-dev libxmu-dev

Download ns-allinone-2.34.tar.gz. Then execute the following using command prompt:

tar -xzf ns-allinone-2.34.tar.gz 
cd ns-allinone-2.34
./install

For Ubuntu 9.10 (karmic), you may encounter this error in the linking of otcl:

otcl.o: In function `OTclDispatch':
  /your/path/ns-allinone-2.34/otcl/otcl.c:495: undefined reference to
`__stack_chk_fail_local'
  otcl.o: In function `Otcl_Init':
  /your/path/ns-allinone-2.34/otcl/otcl.c:2284: undefined reference to
`__stack_chk_fail_local'
  ld: libotcl.so: hidden symbol `__stack_chk_fail_local' isn't defined
  ld: final link failed: Nonrepresentable section on output
  make: *** [libotcl.so] Error 1

This error is because the linker being used is “ld -shared” instead of “gcc -shared”. If you edit one line in otcl-1.13/configure, and rerun install, it should work:

--- configure.orig      2009-11-02 12:14:52.556167945 -0800
 +++ configure   2009-11-02 12:17:28.966706099 -0800
 @@ -6301,7 +6301,7 @@
          ;;
      Linux*)
          SHLIB_CFLAGS="-fpic"
 -        SHLIB_LD="ld -shared"
 +        SHLIB_LD="gcc -shared"
          SHLIB_SUFFIX=".so"
          DL_LIBS="-ldl"
          SHLD_FLAGS=""

After a long wait and a whole lot of text, you should see the installation finish up with text like the following:

Nam has been installed successfully.
Ns-allinone package has been installed successfully.
Here are the installation places:
tcl8.4.11:      /your/path/ns-allinone-2.34/{bin,include,lib}
tk8.4.11:               /your/path/ns-allinone-2.34/{bin,include,lib}
otcl:           /your/path/ns-allinone-2.34/otcl-1.13
tclcl:          /your/path/ns-allinone-2.34/tclcl-1.19
ns:             /your/path/ns-allinone-2.34/ns-2.34/ns
nam:    /your/path/ns-allinone-2.34/nam-1.14/nam
xgraph: /your/path/ns-allinone-2.34/xgraph-12.1
gt-itm:   /your/path/ns-allinone-2.34/itm, edriver, sgb2alt, sgb2ns, sgb2comns, sgb2hierns


Please put /your/path/ns-allinone-2.34/bin:/your/path/ns-allinone-2.34/tcl8.4.19/unix:/your/path/ns-allinone-2.29/tk8.4.18/unix
into your PATH environment; so that you'll be able to run itm/tclsh/wish/xgraph.

IMPORTANT NOTICES:

(1) You MUST put /your/path/ns-allinone-2.34/otcl-1.13, /your/path/ns-allinone-2.34/lib, 
    into your LD_LIBRARY_PATH environment variable.
    If it complains about X libraries, add path to your X libraries 
    into LD_LIBRARY_PATH.
    If you are using csh, you can set it like:
                setenv LD_LIBRARY_PATH 
    If you are using sh, you can set it like:
                export LD_LIBRARY_PATH=

(2) You MUST put /your/path/ns-allinone-2.34/tcl8.4.19/library into your TCL_LIBRARY environmental
    variable. Otherwise ns/nam will complain during startup.

(3) [OPTIONAL] To save disk space, you can now delete directories tcl8.4.18 
    and tk8.4.18. They are now installed under /your/path/ns-allinone-2.34/{bin,include,lib}

After these steps, you can now run the ns validation suite with
cd ns-2.34; ./validate

For trouble shooting, please first read ns problems page 
http://www.isi.edu/nsnam/ns/ns-problems.html. Also search the ns mailing list archive
for related posts.

If your ubuntu version is 9.10, you must change the variable of environment CC if not set

$ export CC=gcc-4.3

Now, You have to set environment variables

$ gedit ~/.bashrc 

Replace /your/path with the path to parent directory of ns-allinone-2.34.

# LD_LIBRARY_PATH
OTCL_LIB=/your/path/ns-allinone-2.34/otcl-1.13
NS2_LIB=/your/path/ns-allinone-2.34/lib
X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB

# TCL_LIBRARY
TCL_LIB=/your/path/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/your/path/ns-allinone-2.34/bin:/your/path/ns-allinone-2.34/tcl8.4.18/unix:/your/path/ns-allinone-2.34/tk8.4.18/unix
NS=/your/path/ns-allinone-2.34/ns-2.34/
NAM=/your/path/ns-allinone-2.34/nam-1.14/
PATH=$PATH:$XGRAPH:$NS:$NAM

Ensure that it immediately takes effect:

$ source ~/.bashrc

Validation of the installation can be tested by:

$ cd ns-2.34
$ ./validate

Now, installation of network simulator is done. Enjoy coding.

How to delete useless file in Ubuntu


Using gedit creates lot of temp files of pattern “*~”. And if you are working in multiple directories its really hard to get to all these directories and delete these files.
Also, people want to delete “Thumbs.db” from windows directories but don’t know how.

Here is a solution:

This will find all the files,

find /path_to_directory -type f -name "file_pattern"

To delete these files, you can use

find /path_to_directory -type f -name "file_pattern" -exec rm -f {} \;

where /path_to_directory is path to directory from which you want to delete the files having pattern or name file_pattern recursively.

For example, to remove files like program.cpp~ created by gedit you can use

find /home/user -type f -name "*~" -exec rm -f {} \;

and to remove Thumbs.db from windows directories you need to do

find /media -type f -name "Thumbs.db" -exec rm -f {} \;

If you want to examine the files that are going to be deleted before doing it, you should execute the same command, changing ‘rm’ for ‘ls’, like this:

find /path_to_directory -type f -name "file_pattern" -exec ls -f {} \;

In this way you may control the list of files to delete.

PS: \; is necessary.
I hope this helps.

Mathmania Report


On 13th Mar, Codefest was proud to have world’s top coders and mathematical geeks as participants in first of the three live contests, MathMania,
mathematical puzzle contest.

Overall 954 participants across 54 countries competed in the gruelling battle. It was a 6 hour contest with 10 mathematical puzzles for which participants were required to only provide the answers.

KoenR from Netherlands won the contest and was the only person to solve all the 10 problems correctly.
DrKorbin and Silence both from Russia bagged 2nd and 3rd positions with 185 and 150 points respectively.
Complete ranklist is available at http://itbhu.ac.in/codefest/mm-full-scoreboard.php. There are only 5 indians ( 2 from IT-BHU) in top 30 and that includes 4 professionals also.

The intensity of the competition can be imagined by the fact that ACRush (Google CodeJam 2008 and 2009 winner) solved the first problem in 8 mins and KoenR solved Problem 7 in the very last minute to snatch the first prize from DrKorbin. It was indeed a pleasure for the event administrators to see the actual scoreboard fluctuating almost every minute of the contest.

It was great for all of us to have positive feedbacks regarding the level of problems and the organization of the event from the various participants.

Mathmania trial round success story


Mathmania trial round was successfully organised on 13th Feb, 2010. The contest ran smoothly from 13th Feb 6:00 PM to 14th Feb 12:00AM.
The judge made by Harshath was really awesome, that it took the load of submission very efficiently and there was no problem reported.

Five prizes are to be distributed to:

The full scoreboard is available for the trial run.

One of the participants and winner Keshav Dhandhania (keshav_57) wrote an email to Codefest team after the contest. The email says

Hello

This is a mail of acknowledgment to the organizers of Codefest.

By the current standards, it is not uncommon to see a contest
organized by Indian Institutions to perform really badly. The website
maintainance is usually poor, the problem statements usually have some
technical flaw, etc, etc.
The contest I participated in yesterday (mathmania), was an exception
to all this. It was nice to see the website functioning very well
during the contest, and the problem statements very well stated. It
was also nice to see the prompt and quick responses to the few queries
that still remained. Also, the organizers were courteous enough to add
an extra prize seeing the good performance (or possibly the same
score), although I would count this as secondary, since this depends
on how much sponsor one can get.

I thank you, for doing some good to the Indian repute in such
competitions. And I hope, there will be many more such competitions
from your side, and from other Indian Institutes.
Please keep up the good work in the rest of the upcoming contests.
The contest organized by you was much better than most IIT and NIT and
other contests I have participated in.

I often curse the bad organizers, when the server goes down, or there
is a system crash. But then, lets not forget to appreciate the good
ones. That is all I intended to do with this e-mail. It is weird how
much people underestimate the importance of such appreciation.

Thanking You
Yours Sincerely
A satisfied participant

Keshav Dhandhania
kshav.91@gmail.com

Another participant wrote:

Your current tentative-scoreboard criteria is good. keep it the same in main contest.keep it the same in main contest. ….Contest was good, complements !!

Web-talk by Animesh Pathak on 13th Feb


A web-talk was held by our alumni Animesh Pathak (2003 batch) on 13th Feb (Saturday) at 2 PM. It was held in our dept in Batch of 98 Hall.

For those who dont know about him here are some facts:

  • He got 10 points in 4 consecutive semesters.
  • Was Convener of Kashi Yatra in his 4th year.
  • He is currently working in INRIA, France as Researcher
  • He is one of the most active alumni in all Institute projects.

He talked about various aspects of intern-ships.

  • Why internship is necessary?

    Intern-ship is very important for industrial exposure and working experience on live projects.
    If we apply for job, our previous experience in the field counts.

  • Which internship to pursue industrial or research?
    Both are equally important.
  • Is internship important after 1st year or 2nd year?
  • What is value of Prof. project?

Unfortunately power-cut happened before he could tell us more. We are planning to continue this workshop sooner we get the appointment from Animesh.

Here are some pics of the talk.

CT Schedules


CT1
8 Feb: Networks 10:15AM
10 Feb: Software Engineering 11:15AM
11 Feb: Artificial Intelligence 11:15AM