Uninstalling docker in Ubuntu 14.04

Docker is everywhere these days. The container management is an old concept but ops-team has struggled with horrors of lxc for many years. Docker came and solved many problems. One thing which it made sure is making ops and infrastructure related work a little more subtle.

But as latest linux kernels came out (3.18 and 3.19), people using older versions of docker started facing lots of issues. There were some good commands available in latest docker releases. So, many people tried to upgrade. But many of us fell in the trap of incompatible docker server and client installations.

After messing things up first thing we try is uninstalling the current setup so that we can do a fresh installation.

Now, sudo apt-get remove docker will simply do nothing to help in this case as you will see, almost none of the packages will be removed.
Every docker invocation will throw this error:
Is “docker -d” running ?
And docker -d will not start the daemon with issues related to aufs.

Enough said. If you are buried at this level, just follow these steps and things will work.

To uninstall docker first run these commands:

sudo apt-get remove --purge lxc-docker
sudo apt-get autoremove --purge

And now use the docker installation steps mentioned in their official documentation page:

wget -qO- https://get.docker.com/ | sh

Now create a docker group and add user there so that you don’t have to hit “sudo” with every docker command (which will also avoid messing up gcloud commands).
Just logout and log back in. Things should work now.

Let me know via comments if the issues persist.

Posted in Uncategorized | Tagged , , , , | Leave a comment

Java for Web Scrapping !!

Java is mainly famous for its awesomeness in Enterprise software and multi-threaded applications. But when you decide to use “java-for-everything”, an efficient implementation can always be done.

This blog is about web scrapping using java. This is a job for which ideal candidates suggested by experts are python and JavaScript. But java does provide this feature using the library Jsoup. If you are little bit familiar with DOM, CSS and Jquery then you are good to go and you are going to feel right at home.

By using Jsoup:

we can scrape an html from a URL, file or String.
find various html and css elements.
provide a clean and tidy html output even if the input is completely messed up.

So, my requirement was to update the users of my app of any new notifications from a collections of web pages. I didn’t want my users to navigate away from my application to those websites. So I decided to scrape the “notice-board” sections of the pages and by regularly visiting them I can look for any updates and then provide those updates in a beautiful UI in my APP.

So my design was to have String attributes set for latest entry in the notice-board. This will sit in my DB. Whenever I am scrapping again, I will get all new lines until I reach the entry in my DB and then update the DB with new entry.

So, in order to get a DOM of web page we need a document object:

Document doc = null;

//get entire page as a Document object
doc = Jsoup.connect("url_as_String").get();

Now the most basic command we can use is to look for any particular “cssQuery” in the form of String.

//get all elements of this specific type
Elements elements = doc.select("a[href]");

The cssQuery in above command is also called a Selector. A selector is a chain of simple strings, separated by combinators to find matching elements in document. Java programmers can think of it as “regex” in html world.

Now I have 3 notice-board sections in our example page. So I will read my latest line entries for all three sections from DB.

String line1 = "What a wonderful day to announce this news !!";

String line2 = "Important notice for closed communication";

String line3 = "Best Wishes for a \"Policy Compliant\" New Year 2015!!";

Finally I can iterate over the elements we extracted from document and compare the content from our Strings.

String text = null;
for (Element data : elements) {
text = data.ownText();
//and now you have the text (which is a string) you can do any comparison, manipulation etc to achieve the desired result.
}

This is a very very simple application of what this library can help us in doing. So, think a bit for some crazy stuff and dive deep right into Jsoup.

-Cheers

Posted in JAVA | Tagged , , | Leave a comment

Bird-Man: Shows me a mirror !!

As if the title was not crazy enough. Some of my closest friends were telling me not to even watch the trailer as according to them this was about some new dumb super hero. And guess what I did not watch the trailer entire year. Entire 2014 I lived in complete ignorance of possible existence of a cinematic brilliance among 100s of films that were released in 2014.

I agree with the fact that all year I was just waiting for “Interstellar” because I am a big fan of Mr. Nolan’s work. Interstellar came and I watched it 5 freaking times in theaters. It was beautiful. A masterpiece that he creates always, in all of his films. But still in some of the less known you tube channels I was constantly hearing about this bird man. And finally I decided to somehow watch it. And now at 3 AM I am writing about it.

Its a film that not everyone is going to like. I mean its sad but its the way it is made. Its not “avengers”, which we all liked. Its one of those precious gems of cinema which simply make me so happy for being able to watch it. Its not about the guy in the film. Its not about his story, its our story. Its a reality check for all of us. What we crave for in our life and how small it makes us. May be I am going through a kind of tough phase of my life. So a lot of things which I am watching or reading about is putting a deep impact on me. But I am going to suggest some of my closest buddies to watch this film. It might not touch you the way it should. But that will be so unlucky for the viewer.

Bird-man 10/10 for you. Make that sound once again 🙂

-Peace,
Vinay

Posted in Reviews | Leave a comment

Copying files from a remote Linux server to local Windows server using JAVA

 

A while ago I had this requirement in which I had to copy a bunch of files from a remote linux server to my local windows installation. Usually  clients like WinScp are handy in doing this. But I have to make this a part of some application, so I was required to do this in java.

Now copying/uploading files basically follow two protocols: ftp or http. I am not going to talk about which one is better. But I didn’t want to create any metadata and my requirement was not having a persistent pipe/channel because once after copying the file I wanted to be done with the connection, so I chose FTP.

Now in FTP there is no security. So any thing can be “over heard”. That’s why these days protocols like SFTP and FTPS are being used. I looked for some beginner material and started with SFTP. For SFTP setup we need library called JSCh by JCratft. Download this and put the source code files in your project directory. Include it in your project’s class file and you are good to go.

package sftp.apps.helper; 

import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.SftpException;


public class FileCopierOverNetwork {
    public static void main(String args[]) {
        String hostname = "hostname";
        String username = "<username>";
        String password = "password";
        String copyFrom = “file_path_in_remote_linux_server";
        String copyTo = "path_in_local_server"; 
        JSch jsch = new JSch();
        Session session = null;
        System.out.println("Trying to connect.....");
        try {
            session = jsch.getSession(username, hostname, 22);
            session.setConfig("StrictHostKeyChecking", "no");
            session.setPassword(password);
            session.connect(); 
            Channel channel = session.openChannel("sftp");
            channel.connect();
            ChannelSftp sftpChannel = (ChannelSftp) channel; 
            sftpChannel.get(copyFrom, copyTo);
            sftpChannel.exit();
            session.disconnect();
        } catch (JSchException e) {
            e.printStackTrace();  
        } catch (SftpException e) {
            e.printStackTrace();
        }
        System.out.println("Done !!");
    }
}

In the code above we have instantiated two objects JSch, Session. Now, in the try-catch block, the first statement is:

session = jsch.getSession(username, hostname, 22);  In this statement we are instantiating a session with the username, password and port for the sftp connection.

session.setConfig(“StrictHostKeyChecking”, “no”);  Here we are passing two values which is getting passed to a hash map in the class “Session”. The main thing to note is that we are disabling strict host key checking by this statement. After these two lines the code is pretty much self-explanatory which involves opening a sftp type channel and copying file from source to destination.

Posted in JAVA | Tagged , , , , , , , , | 23 Comments

I am writing this step by step tutorial to make it easy for anyone who is trying to install systemC library because I was able to do that after struggling with it for long time and searching through numerous web pages. If anybody knows a simpler way then his/her help will be appreciated. And before we proceed I want to thank all those people who have given their contribution in parts through their posts/web pages in helping me. After all as they say  “sharing is caring”…..  🙂

These steps apply for systemc-2.2.0 and I have tried this on  ubuntu 10.04, 11.04, 11.10, 12.04 and also in fedora 13, 14, 15. All are 32-bit OS. For 64-bit OS some updates have been mentioned in the bottom of the post.

STEP 1:

First of all open terminal (ctrl+alt+T), and type:

:~$ sudo apt-get install build-essential

this will download and install all the necessary compiler tools in your system.

STEP 2:

Now download systemC package from http://www.systemc.org/downloads/standards/ (a free registration is required) or any other source about which you know better than me. The downloaded package will be available in Download directory of your home folder. Extract the package using any of the following two methods:

1. right click on the .tar.gz file and select extract here option.

                                         or

2. start terminal (ctrl+alt+T) type following code:

            cd Downloads    (if that .tar.gz file is in Download directory else give wherever you have kept it)

           mv systemc-2.2.0.tgz systemc-2.2.0.tar

           tar xvf systemc-2.2.0.tar

Using any of the above two methods, you will get a folder named systemc-2.2.0 in the same folder where .tar.gz file was present (in my case it was in Download folder).

STEP 3:

Now following two steps will avoid any problems in further installation so follow them carefully:

1. go to systemc-2.2.0/src/sysc/utils and open file “sc_utils_ids.cpp” and add these    two headers

    #include <cstdlib>
   #include <cstring>

along with other header files and save it before closing.

2. go to systemc-2.2.0/src/sysc/datatypes/bit and open file “sc_bit_proxies.h” and search for keyword “mutable”. It appears 5 times in the file. Delete it from all 5 locations and save the file.

STEP 4:

Now we are ready to install the package.

open terminal again and use following codes:

:~$ cd systemc-2.2.0

:~$ sudo mkdir /usr/local/systemc-2.2

:~$ mkdir objdir

:~$ cd objdir

:~$ sudo ../configure –prefix=/usr/local/systemc-2.2

:~$ sudo make

:~$ sudo make install

STEP 5:

Now as we have not installed the package in usual place. So we need to tell the system where to find the package when required.

For this type this in terminal:

:~$ export SYSTEMC_HOME=/usr/local/systemc-2.2/

Now whatever we have done will work until we log out. So to make it permanent we need to change the path variables. For this open terminal and type:

:~$ sudo gedit /etc/environment

This will open a text file in gedit. In that file add following line in the end:

:~$ SYSTEMC_HOME=”/usr/local/systemc-2.2/”

before saving please check that the double inverted comma used above should be proper.

Now restart the system once. That’s all 😀

STEP 6:

Now to check please download sample systemC code from http://www.asic-world.com/systemc/first1.html

To compile it from terminal use this code:

:~$ g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux -o out sample.cpp -lsystemc -lm

:~$ ./out

It will print hello world as output.

If this compilation and execution of code is throwing some error regarding linking of libraries viz, “-lsystemc not found” etc, then please read following two additional things which I have added after feedback of other systemc users who were very humble while giving these useful suggestions and time. 

EDITED: (Courtesy-Dhiraj):

While executing the code if some problem occurs like: cannot find -lsystemc etc then don’t worry it is because of linking error. To get rid of it you need to set path in LD_LIBRARY_PATHS which can be done as follows:

Two solutions:
For setting your LD_LIBRARY_PATH.
     export LD_LIBRARY_PATH=/usr/local/systemc-2.2/lib-linux:$LD_LIBRARY_PATH
or, if your default LD_LIBRARY_PATH is empty
      export LD_LIBRARY_PATH=/usr/local/systemc-2.2/lib-linux

And for this fix don’t thank me but do thank the the guy who commented this suggestion below in comments. 🙂

EDITED: (Courtesy-Tianyang):

For Ubuntu 64-bit version, the lib-linux should be lib-linux64.

Thank you

Posted on by Vinay Dwivedi | 97 Comments

Miss Beautiful …..

MISS BEAUTIFUL (Direction : Makrand Deshpande
Cast : Nagesh Bhosle, Divya Jagdale, Makarand Deshpande, Ahlam Khan , Sanjay Dadhich, Anana & Vineet Sharma )

Last weekend was among the best weekends at kharagpur. The reason was none other than SPRING FEST. I have already attended the tech fest of IIT kgp in 2009 but this cultural fest was my first one. Although between the busy schedule I was only able to go for a drama Miss Beautiful. At the entrance itself me and my friends have to give a good fight to make a place in Kalidas auditorium. After almost waiting for 1 and half hour the play started.

The play is about a man whose parents are very old and are afraid of their upcoming death. And the son wanted to make it beautiful for them. I am not disclosing the story here, but yeah it was a bit experimental to perform a serious act with audience as Engineering college students. The first half  was a bit humorous and students commented like anything and the actors too enjoyed it fully.

The twist came in the second half. Many students left the hall for attending a live concert by PARIKRAMA. But those who stayed were simply mesmerized by the ability of the actors. The end was full of pain and it was visible or say can be felt among the audience too. Most of the viewers were sobbing slowly (no one admits it :D), and there were no comments, no sound, complete silence in the hall. We were simply inside the life of the characters of that play. I too have done few plays at school level but this one was beyond my imagination. Kudos to every member of the cast and crew.

At last I can simply thank IIT kgp and the Spring fest coordinators for bringing upon something of this magnitude.

Posted in Reviews | Tagged , , , , , , | Leave a comment

KINDLE e-reader in india……

Hello again,

yesterday only I got my amazon kindle here in kgp. well this is not to advertise it :P.. I am writing just to get my readers acquainted with it.

E-reading is not a fashion in our country but being here I keep getting e books of almost every field I want to read and seriously reading them all at my laptop is not a good/healthy idea, although usually we don’t have an option.

From past few months I was having my eye on this product but due to custom costs of importing it to India I was a bit reluctant at purchasing it. But now when I am having it, I can tell you yeah this is seriously the best E-reading experience.

Now the catch. The wifi doesn’t work in India. There is some problem with channel but even after setting it accordingly it is not getting connected. Second for us it seems to be quite costly for a product just giving this feature for the bucks we have paid. For those who are willing to have one, I want to tell you, without touch screen the user interface is not cool. There is no color display possible with the E-ink display tech. The $109 model is not for an average Indian.

Instead we can pay some extra money to get a tablet with capacitive touch screen with almost all features of a small notebook. So it depends how much you can pay to quench yourself. I’ll explore my device more in upcoming days, for any queries you can contact anytime.

Posted in Uncategorized | Tagged , , , , , | Leave a comment

50/50

After a curious entry to blogging world it took me a long time to return with something here. Nothing was actually touching that much to make me feel like typing my thoughts out. Finally 50/50 succeeded.

I was waiting for this movie ever since i have seen its trailer and the reason was obviously Joseph Gordon Levit. Be it “10 things i hate about you” , “500 days of summer” or “Inception” Joseph has left his impression in a different way.

His latest film 50/50 is about a cancer patient and the role is played by Joseph himself. The pace has been kept very slow just to mark out every hidden pain a young guy who may die can feel. The movie proceeds beautifully telling us what are our importance…who are people we truly want to be with in our life. I actually don’t wanna disclose things here although movie is not having any big secret ready to be unmasked in the silver screen but sometimes reviews kill the natural feelings you can get after watching any movie for the first time. Another beautiful improvement was Anna Kendrick. She has got entirely different role from what she played in “much hyped” Twilight (seriously i don’ even want to mention this name here…huh). She is playing a young doctor who is not mature, facing her own emotional problems and is very stressed about the condition of her patient (Joseph).

So, if you like a simple n sweet  film and you have seen 500 days of summer and liked it too…..go for 50/50… awesome movie because of many moments one will explore in it (you will recognize them).

Posted in Reviews | Tagged , , , , , , , | Leave a comment

Being myself……finally

Well after almost spending 3 months here at IIT kgp, i have started falling in love with this place. Puzzled ?? yeah yeah, the city (i don’t know whether you can call it one or not) doesn’t please you when you want to roam out somewhere during weekends, when you want to hang out with your buddies for some party, when you want to continue your usual window shopping and many things which we were accustomed to before coming here. Initially i used to freak out at the boredom on weekends and super busy schedule on weekdays i was facing over here. But the place has its own way to make you survive and bring the best out of you. but there is one things that triggers it, the key to unleash beautiful life here, the answer to many things I was trying to find out in last few months is again the same which helped us survive everywhere in every favorable or unfavorable situations…yeah you are correct…… its our friends.

Well I must say I got lucky in this case. i came here with 2 of my graduation days friends pankaj and tiwary, and they are now my roommates here. and in addition to this one of them is in the same branch as mine. It reduced the load here to 50 % because, when you are alone even a small knock on the head sounds like a thunder, but if you find someone right behind you, something from inside drives you like anything.

Then my new friends are also wonderful gift kgp has given me. Both BHAI (devesh) and HOOBLI (sameer) are awesome and i always find them cheering me up when i find the dullness in the air. Devesh somehow brings something encouraging even from a complete crap and useless stuff and pulls us up in our endeavors. while sameer makes sure that we don’t forget what we were upto while talking out whole day. Tiwary still holds his regular “i don care atti” but we love him because he is like this.

So, now whenever something makes me to hate this place for any possible reason,  I try to find the same feeling which brought me here….and then this place converts to the place which i loved….

Posted in Uncategorized | Tagged , , | 3 Comments