Category Archives: geek

How to get list of all commands run in python shell?

We most often use python interactive shell to input commands, instead of writing them as full fledged script file. This is handy and gives us a check on what libraries to import, where a possible error can occur and rectify any problem per line of code.

With Jupyter notebooks, we are able to work around very easily. But, in a traditional environment, how to get back a copy of all commands that were typed into python interactive shell?

We use readline to do this job.

import readline


The above code will store the entire command history into a text file by name python_history in the current working directory.

I always take backup of commands input and check it back in order to have a glimpse of what worked and what not.

Readline also allows us to clear the command input history :



to clear/flush the command history.


Leave a comment

Filed under geek

Building Telugu Corpus with Telugu Wikipedia data, second attempt

The earlier attempt to create a Telugu Wikipedia dump resulted in not only corpus but gave me a ready reckoner Wikipedia articles at hand.

I could access Wikipedia articles one text file per article and it helped me run various string processing commands on these per page wiki article pages and showed me many new insights.

Otherwise difficult to find out, many disambiguity pages could be easily found out.

Here, today, I tried to use a method mentioned at kdnuggets. The procedure was simple, a set of two scripts was given. The first script would take xml dump and convert it into a single text file with space seperated words of Telugu Wikipedia dump. There is no taxonomy, no distinction, the entire text of Wikipedia is dumped into a single text file.

The procedure can be checked here.

Leave a comment

Filed under geek, project

First Amazon Telephonic Interview

I had this opportunity to have interview with Amazon with the help of my friends, who referred me for SDE position.

Immediately after my friends’ reply that he has given my resume with a recruiter and I may get a call from recruiter, I got a call from some person with my interview schedule.

With a lapse of half an hour after schedule, my first interview started.

The interviewer was humble supportive one. After introductions, he straight away asked me questions one after another.

They were:

  1. Implement a stack with push, pull and findmin in O(1) time.
  2. There is an array of positive random integers. All the elements are repeated twice except for one. Find that element.
  3. Wap to stitch all the leaf nodes of a binary tree together. After stitching, the tree becomes a graph, and the stitched elements be stored in a list. Return the head node of the list.

I could quickly answer the first two ones, but had trouble writing working code for the third one. After several minutes passed. And my code messed up, I was asked to leave it. And the phone interview concluded.

With a gap of one hour, I had a second telephonic interview.

This time I was asked only two questions.

They were :

  1. Wap. There is a circular singly linked list, All elements are in ascending order. Insert a given number at its correct place in the list. The number is a random one.
  2.  There is a stair case, at each step, a person can either take two steps or one step. What is the total number of steps?

With the guilt of being unable to do the previous interview coding properly, here, I directly wrote the implementation part of the linked list, without even checking my implementation was a mere singly linked list and not a circular one. Also, missed the syntax errors like a semi-colon(;) at end of struct declaration, etc. And after correcting me for those mistakes, or rather blunders, the interviewer moved onto second question, and I was trying to solve it mathematically and come out with a polynomial expression, while the interviewer intended me to derive a recursive function out of it. After failing with it, the interviewer advised me to follow codechef, topcoder kind of websites and to do more practice.

Hours after interview, I received a mail saying, I am not offered a job/no call for further interview.

I can reapply in 6 months.

Waiting for my second turn now, and practicing for it.

1 Comment

Filed under about myself, geek

ODBC in your own linux!!

Very odd to hear?

But its true.

We can now use JDBC-ODBC bridge, which I have discovered today.

I was told that ODBC can be only used with MS-Windows.

But I have found a way to make it possible to use ODBC in Ubuntu.

Check out here:

Leave a comment

Filed under geek

Lighter side of programming

hi there,

thinking that programming is all about writing lines of code, analysing them, compiling, running and validating them only!!!!!!

Think twice before you jump to conclusions (This is the phrase used by HCR that i like the most)

There are few web portals that actually show the lighter side of programming by depicting them as cartoons.

Please, whenever you feel like getting bored. Have a look at these:

Different stages of a programmer

are you like that?

Not so funny!!!!


Then what do you say about this:

This has hundreds of cartoons

a sample for you:

Still not happy:

Look at this site, this has N such particularly witty and funny cartoons with some logic(not always programming, a bit of science too):

and a sample:

and this:

Leave a comment

Filed under geek

Drupal Hyderabad’s first workshop — a great successful event indeed

This post comes rather a bit late, owing to my ‘busy’ness as my B.Tech life is ending soon and projects, seminars and all that stuff is overhead.

Still not to trouble you all, i’ll put this post as a brief report from the participant’s perspective.

The other blogs, i read were of a “different” perspective.

This blog entry is about the first workshop of Drupal-Hyderabad held on May 1,2 at VNR VJIET, Hyderabad.

I couldn’t attend the first day’s workshop, heard that there was this session on jQuery which i regret for not attending.

Anyway I attended the second day’s workshop, which was yummmmmmmmmmyyyyy , a hands on workshop, hope, Siva could taste his spaghetti code here 😛

I dont know what the scheduled time was, I arrived at 10 hoping to be the late among all, but the scene was reverse, by 11 all of them settled and rather basic and formal sessions went on installation of Drupal.

First there was a session was on hosting and web development basics by Medhamsh, am already a great fan of medhu — need say anymore. The last emphasis he made on localisation is what i want everyone to adopt from him.

There was then a session on Intro and Installation of Drush by Srujan — the Panda of Pandas. Then a session by Asif on Drupal basics, Sai Tanay’s session on modules was awesome, but he was a bit too speed and couldn’t elaborate due to time constraints. The following session was on themes by some jwala, i expected it to be a theme creation and customisation session, but it was a theme application and usage session — regrets here for me 😦 .

The final one by Ipsita, as short session as her name and as elegant as her looks, it was an awesome presentation, with scope for me to crack jokes.

drupal-hyderabad speakers at second day

Again regrets for me to not having heard from Siva about his case study, which couldd have I think inspired few more people.

The success was evident with the responses that came out from participants in Siva hosted feedback session.

I think that was not all. We had a great lunch.

A group photo with “cheese” in everyone’s mouth.

An adventurous lift rescue operation in which I was the victim.

The rainy day — thanks God.

the bus journey was awesome with Asif’s company. It was this workshop that I met Mahesh personally for the first time, I also met all my friends back at e-swecha summercamp — Hari, Siva, Bony, Kiran, Saiprachandan, Suresh, Sravanje and our great Madhu.

Later after all this was done, We — me, Siva, Mahesh, Hari and another friend had a lavish dinner at Paradise sponsored by Hari — I suppose.

The success of this event, whether one agrees with me or not is first attributed to Bony, then Siva, then Ipsita, then Hari, Medhu, Saitanay, Sree and all others.

I will cherish these  memories of course for a looooooooooooong time and Medhamsh’s inspiration will hold me.

Leave a comment

Filed under geek

Ten tips for Ubuntu Newbies (from

Ubuntu has become the most popular Linux distribution for new Linux users. It’s easy to install, easy to use, and usually “just works.” But moving to a different operating system can be confusing, no matter how well-designed it is. Here’s a list of tips that might save you some time while you’re getting used to Ubuntu.

1. Getting multimedia to work

The default Ubuntu install contains free software only, which means that it doesn’t support some popular multimedia formats straight out of the box. This is inconvenient, but the Ubuntu folks have good reasons for not shipping with support for MP3, DVDs, and so forth — including that software could cause them some legal headaches, or incur some serious fees.

Fortunately, as a user, you don’t need to worry about fees (though some of the packages may not be legal due to patent restrictions or restrictions on circumventing copy protection, depending on where you live). The Ubuntu wiki has a page on restricted formats that explains how to get the packages you need. However, if you run Ubuntu on AMD64 or PowerPC hardware, you’ll still be out in the cold for some of the packages, since some multimedia formats depend on proprietary software that’s not available for those hardware platforms.

2. Changing the defaults

Ubuntu comes with a number of defaults that may or may not be to your liking. For example, the default editor is set to Nano, which isn’t optimal if you’re used to Vim.

The easy way to change this is to use the update-alternatives program, which maintains the symbolic links under /etc/alternatives that determine the default programs for FTP, system editor, rsh, Telnet, window manager, and so forth. Look under the /etc/alternatives directory to see what programs are managed.

To change the default editor, run sudo update-alternatives --config editor. You’ll see a dialog like this:

There are 3 alternatives which provide `editor'.

  Selection    Alternative
        1        /usr/bin/vim
	2        /bin/ed
  *+    3        /bin/nano

Press enter to keep the default[*], or type selection number:

Just type 1 to switch to Vim. Note that on my system, I don’t have Emacs or many other editors installed; if I did, the utility would offer the other editors as choices.

3. How to install packages

Most of the application software you’ll want to add to your system will be available through the Ubuntu repositories using Synaptic, Adept, or another package management tool. What if you want to install something like Opera that is available as a package for Ubuntu, but isn’t in the repositories?

In that case, download the application’s Debian package (.deb) and right-click on the file. At the top of the context menu, you should see an option to open the package with the GDebi package installer. GDebi will provide a description of the package, what files are included, and other details about the package. The package installer also has a Install Package button; just click that and it will install the package. Note that the package installer also checks to verify whether it can install the package — if it has dependencies that can’t be satisfied, GDebi will give an error and refuse to install it.

If you prefer to install packages at the command line, just use sudo dpkg -i packagename.deb.

4. Sudo and gksudo

If you’ve used Linux for any amount of time, you might be used to running programs as root directly whenever you need to install packages, modify your system’s configuration, and so on. Ubuntu employs a different model, however. The Ubuntu installer doesn’t set up a root user — a root account still exists, but it’s set with a random password. Users are meant to do administration tasks using sudo and gksudo.

You probably already know how to use sudo — just run sudo commandname . But what about running GUI apps that you want to run as root (or another user)? Simple — use gksudo instead of sudo. For instance, if you’d like to run Ethereal as root, just pop open a run dialog box (Alt-F2) and use gksudo ethereal.

By the way, if you really must do work as root, you can use sudo su -, which will log you in as root. If you really, really want to have a root password that you know, so that you can log in as root directly (i.e., without using sudo), then run passwd when logged in as root, and set the password to whatever you want. I’d recommend using the pwgen package to create a secure password not only for root but for all your user accounts.

5. Add users to sudo

When you set up Ubuntu, it automatically adds the first user to the sudo group, allowing that user to make changes as the super user (root) by typing in their password. However, it doesn’t automatically add additional users to the sudo group. If you want to give someone else superuser privileges on your shared system, you’ll have to give them sudo access.

To add new users to sudo, the easiest way is to use the usermod command. Run sudo usermod -G admin username . That’s all there is to it. However, if the user is already a member of other groups, you’ll want to add the -a option, like so: sudo usermod -a -G admin username .

If you prefer the GUI way of doing things, go to System -> Administration -> Users and Groups. Select the user you want to add to sudo, and click Properties. Under the User privileges tab, check the box that says “Executing system administration tasks” and you’ll be all set.

6. Adding a new desktop

Many users aren’t sure what packages to add in order to run KDE or Xfce window managers on a stock Ubuntu system — or what packages to add to run GNOME on Kubuntu or Xubuntu. You could add all of the necessary packages one at a time, but there’s a much easier way to go about it.

To install all of the packages that come with one of the flavors of Ubuntu, such as Kubuntu, run apt-get install kubuntu-desktop (or edubuntu-desktop, xubuntu-desktop, or xubuntu-desktop).

If the GUI is more your style, the *desktop packages can be installed using Adept, Synaptic, or another package manager.

7. How to reconfigure

Most of the time, — that’s the software that drives your video card and provides the foundation for the GUI, whether you’re running GNOME, KDE, Xfce, or another window manager — “just works” when you install Ubuntu. In fact, I’d wager that most Ubuntu users never even have to think about their video settings.

But, sometimes you need to reconfigure because Ubuntu hasn’t detected your video card and monitor properly, or maybe you’ve just purchased a shiny new video card and need to get it working with Ubuntu. Whatever the reason, it’s good to know how to reconfigure X without having to edit your /etc/X11/xorg.conf by hand.

To run through the configuration, use dpkg-reconfigure xserver-xorg at the console or in a terminal window. Then you’ll have a chance to specify your monitor and video card, the resolutions and color depths you want to run the server at, and so forth.

Since every setup is different, it’s hard to give concrete advice for configuring X, but it’s generally OK to accept the configuration defaults. Also, you’ll be given a choice between Advanced, Medium, and Simple methods for giving your monitor’s specifications. As a rule, it’s probably best to go with Simple unless you really know what you’re doing, or the Simple method doesn’t work for you.

8. Log in automagically

By default, when you boot up the computer, Ubuntu will give you a login screen before you get to your X session. From a security perspective, this is a good idea, particularly in multi-user environments or in any situation where other people have physical access to your computer. Still, many users are used to just being logged in automatically, and don’t want to fuss with logging in each time they reboot their desktop.

To set this in Ubuntu, go to System -> Administration -> Login Window. You’ll need to provide your password, then you’ll get the Login Window Preferences window with five tabs. Choose the Security tab and click Enable Automatic Login. If you have more than one regular user, make sure to specify which user should be logged in automatically.

Again, and I can’t stress this enough, this is only a good idea for home computers where only one person has access to the computer. I don’t recommend this for work computers or laptop/notebook computers, when someone else might have access to the machine.

9. Compiling from source

Ubuntu’s package repository is huge, particularly when you factor in packages in the Universe and Multiverse repositories. However, many users find themselves needing to install packages from source, either because they want to use a newer package than is available in the repository, or they want to try something that’s not in the Ubuntu repository at all.

If you want to install packages from source, you can use a few shortcuts to make life easier. First, you’ll probably want to get the build-essential meta-package if you haven’t installed any developer tools. Run sudo apt-get install build-essential; it will grab GCC, the Linux kernel headers, GNU Make, and some other packages that you’ll probably need.

Next, if you’re going to compile a package such as Gaim because a new version is out, you might be able to satisfy the new version’s dependencies with the old version’s dependencies. To do this, grab the package’s build dependencies with sudo apt-get build-dep packagename . That will grab all of the development packages you need to build the package that’s currently available in Ubuntu, and will probably satisfy dependencies for the new version you’re compiling.

Finally, don’t make install when you compile from source — use CheckInstall instead. CheckInstall will create a Debian package and install it for you, so you can remove or upgrade the software more easily later on.

Grab CheckInstall with apt-get install checkinstall. After you’ve run ./configure ; make, just run sudo checkinstall and answer a few simple questions. Note that if you compile packages on AMD64, CheckInstall will select X86_64 as the architecture rather than amd64 — which will cause the package install to fail, since Ubuntu expects amd64 as the architecture rather than X86_64.

By the way, the packages created by CheckInstall also make it easier to deploy the same package on several machines, if you happen to have several systems running Ubuntu. See Joe Barr’s excellent CLI Magic feature on CheckInstall too.

10. A new kernel

Ubuntu will install a 386 kernel for x86 machines, which probably isn’t what you’d want if you’ve got a Pentium II or better CPU. The 386 kernel is compiled to work with just about any x86 CPU, but extensions that appear in later CPUs can give your system a boost, if they’re taken advantage of. To replace the kernel, open Synaptic or Adept and search for linux-image. You’ll see several choices. Pick the one that best suits your CPU — probably the linux-image-686 package for Pentium II and later CPUs, and linux-image-k7 for later AMD processors. Note that if you’re using the AMD64 line (or Intel’s x86-64 CPUs) you should be using the amd64 images.

Of course, once you install the new kernel, you’ll need to reboot. Another benefit to the 686 kernels is that they have SMP support, which is a bonus for multi-core and Intel HyperThread CPUs.

If none of the tips cover questions that you have about Ubuntu, try checking out the Ubuntu wiki, forums, and mailing lists. As a rule, the Ubuntu users are a helpful lot, and you’ll usually be able to find someone who’s run into the same situation that you have questions about.


Filed under geek