Tuesday, 26 November 2013

Cyberroam Tricks Part 1

Most of the colleges or Offices have Cyberroam to restrict user from accessing certain websites. This can also be used to limit the speed of your Internet. I am in college and My college installed Cyberroam when I was in 2nd year of my Engineering. Every sem they introduce something to put limitation on us and everytime we had to find something to bypass that limitation.

I will mention all the limitation that our college has put on us and how to overcome that limitation.

1. The very first one was when we had to enter username and password provided by the college after regular interval which was very annoying. I got automatically solved. I don't know. I guess college professor found the option in cyberroam which was causing this. But there was a time when If we remove the LAN wire (cross cable) from laptop without logging out then It will not work on your laptop for certain amount of time. Then you will have to insert into someone's other laptop and then again insert it into your laptop and then It will work. If something like this happens to you then the very basic solution to this problem is to renew your IP address assigned to you. You can do this by executing the following commands in command prompt.

ipconfig /release

and then this command

ipconfig /renew

Now you will be able to see the cyberroam login page where you can login and use the internet. This happened with us a lot in a semester as in hostel the mostly the lan wire was damaged so even If we move the laptop a little the lan wire got removed from the laptop accidently and the internet would stop workign and I had to run these commands to make it run again.

2. The second problem I faced due to cyberroam was that I was unable to download anything from torrent. uTorrent didn't work. Then we found a solution to this problem also. Now the solution is very simple. Goto Options menu (ALT + O) in utorrent and then Preferences, then select Bittorrent in the list given on the left side. Now you will see a option named in Protocol Encyption in the right side. There will be 3 values. Select Forced. and click on OK. Now your utorrent will work even in cyberroam. Now the main problem was to get the torrent file. All the torrent websites were blocked so we were unable to download any utorrent file. One simple solution to me right now is to go to katmirror.com which is a copy of kat.ph which is not blocked here at my college. So I can download torrents from this website.


The solutions to cyberroam will continued in the next blog. I will provide more solution to the problem mentioned above by telling your how to use proxifier. So Stay tuned. Enjoy.!!!

Thursday, 1 August 2013

Sync your fork and Original Resipository

I just started working for a organisation whose code is on Github. I cloned their repository and after making changes I tried to push changes to their repository But I couldn't. The reason was obvious. I cloned their repository. I don't have the permission to make changes in their repository.

Thats why you fork a repository. You can make any kind of changes in it. So I did that. But after I cloned it, I realised that the repository was too old. I hadn't merge the changes made in the original repository into my repository. I used to think that my fork automatically gets updated to the latest changes made in the original repository. Stupid thought? I know :P

Now you have to manually sync both of the repositories i.e. Your fork and the original one. I am writing this from this blog.

http://bradlyfeeley.com/2008/09/03/update-a-github-fork-from-the-original-repo/

I assume you have a local copy of your repository. Now issue the following commands

Now you need to add a remote branch to your repository which points to the original repository.

Issue the following command to do that

$ git remote add --track master mleung git://github.com/mleung/feather.git

Now here are 3 parameters i.e. master, mleung and git://github.com/mleung/feather.git

First one is the branch from which you want to merge. Most of the times it is master. In my case it was develop so I replaced it with develop. The next parameter is just a label. You can write whatever you want the name to be like repository_remote. And now the third parameter which is the link to the original repository. This command will add a remote branch to your repository. As you have noticed this command fetches nothing from the Internet. Now the next command is to do the same. Now before doing that you can also check if a remote branch was added from your above command using the following command

$ git remote

Now we can fetch the remote branch using

$ git fetch mleung

Now that you have fetched the changes and you have it in your repository. You can merge it which is the easiest thing to do. Now here specify the name of the remote branch that you have used above

$ get merge mleung/master

Now you successfully synced your local repository with the latest changes. Now you can push that changes in your remote repository with pride :P

$ git push

Happie Gitting :P

Sunday, 30 June 2013

Keyup event not responding to preventDefault()

I was working on jQuery's autocomplete/ Bootstrap typeahead kind of thing for phpBB.
It is basically used to provide user with suggestion/options when user enters something in the input or textarea
Now the default behaviour that you will see of the following keys is as follows:

For Arrow Up
If some option was already selected, then select the option just above it.
If no option was selected previously then select the very last option.

For Arrow Down
If some option was already selected, then select the option just below the current option
If no option was selected then select the first option

For Enter button
Now when enter button is pressed, check if any option was selected by the user. If yes then, insert that options value in the input

Now here we have to supress default actions of these above buttons. As if users presses Upper button the cursor moves to the first position i.e. before the text so to suppress this action you will have to use
Event.preventDefault function. Now If you use this function inside keyup then this might not work as the event that you are trying to start has already happened. So instead of using keyup you will have to do use keydown as the event of the keydown happens before event of keyup. So the preventDefault was not working. Now you can suppress these actions using the preventDeafult

Happie Coding!! :)

Friday, 7 June 2013

Setting up vim for C/C++

This post if about the changes that I make in the configuration of vim to use it as an editor for C/C++ Programs. Now first of all make a file named .vimrc in your home directory

$ touch .vimrc
And also make a directory named .vim in the very same folder i.e. your home directory

$ mkdir .vim
Now here is the link of the things that you have to put in the .vim directory.

http://www.vim.org/scripts/script.php?script_id=213

Download the cvim Zip file from the link and extract the contents to the .vim directory
$ tar zxvf cvim.zip .vim/
Now copy paste the following in the .vimrc file

" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below.  If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed.  It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.

" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim

" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible

" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
  syntax on
endif

" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark

" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
"  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif

" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
"  filetype plugin indent on
"endif

" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd " Show (partial) command in status line.
"set showmatch " Show matching brackets.
"set ignorecase " Do case insensitive matching
"set smartcase " Do smart case matching
"set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make
"set hidden             " Hide buffers when they are abandoned
"set mouse=a " Enable mouse usage (all modes)

" My Style
"set columns=70
set textwidth=70
set ruler
set nu
set shiftwidth=4
set autoindent
set smartindent
filetype plugin on
let g:C_SourceCodeExtensions = 'h cc cp cxx cpp CPP c++ C i ii Makefile'
set expandtab           " set tab to spaces
set tabstop=4           " set tab size = 4
set colorcolumn=70      " set column color to indicate not to extend 
                        " more than 72 chars

" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif
And now you are all set and done. Happy Coding.
 
 

Sunday, 2 June 2013

Came Across The R Project, Installing RTextTools

While I was searching Text Classification Machine Learning library for C++ I came across The R project. It is basically a library for statistics related programming which Machine Learning is all about.

So I found a library called RTextTools which uses R Project. I haven't yet used RTextTools so cannot comment about that. So I had to install RTextTools.

To install RTextTools, I will first have to install The R. Here I found all the instruction on how to install The R Project on Ubuntu. So the very first step given is to add the repository in your sources.list file
You will have to add the following line to your sources.list file which is present in /etc/apt/sources.list

deb http://<my.favorite.cran.mirror>/bin/linux/ubuntu quantal/

Now replace <my.favorite.cran.mirror> according to your location. I live in India so I choose this.

http://ftp.iitm.ac.in/cran/ 

Take care of the duplicate http://. Now before updating your apt packages cache you will have to add the key of the repository which can be added using the following command which is also mentioned in the file I have mentioned above. 

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9

Now you can issue the following command

$ sudo apt-get update

and then 

$sudo apt-get install r-base

After installing the above package, you can install the rtexttools by issuing the following commands

$ sudo R

The above command will take you to R console 

Now here you can issue the following command to install it.

install.packages("RTextTools")

Now this will install RTextTools. I will soon be posting on how to use RTextTools and its various function which Currently I also don't know. :)

Saturday, 1 June 2013

Save dialog coming up while executing main.cgi

Every time I re-install my operating system I have to setup every damn thing again. Anyways! I am writing here the problem that I faced while setting up my cgi-bin folder. After installing apache server, CGI will work fine in /usr/lib/cgi-bin folder. But I was setting up the cgi-bin folder in my home directory as I had to install a software named BAKAPLAN made by one of my friends.

If you check the BAKAPLAN github page that I have mentioned above you will find the basic instruction on how to setup cgi-bin folder in public_html folder. I followed all the instruction written in there. Still when I tried to execute my own CGIPhotoAlbum, instead of executing it, It showed me dialog box to save the file. The executable file that I was trying to run had name "main.cgi". I don't know the reason behind this. May be because I was using an extension .cgi. Maybe I had not given the appropriate permissions to the files in the cgi-bin folder.

So the first thing I did was to give permission the folder. I issued the following command.

chmod -R 755 public_html/

Execute this command when you are in your home directory. "$ cd ~"

So next thing that I thought of was to tell the apache server that .cgi is also a cgi script. This reason kindof not making any sense but just for sake my some part of brain add the following line in /etc/apache2/sites-available/default or edit if it is already there

<Directory "/home/*/public_html/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                SetHandler cgi-script
                AddHandler cgi-script .cgi
                Order allow,deny
                Allow from all
        </Directory>

Notice the AddHandler line. That is what I added. This solved my problem. Hope it does yours too. :)

Tuesday, 29 January 2013

CGI C++ Photo Uploader

This project was given to me as an entrance test for GD. So I started off preparing for it from the very time when it was given to me. I faced many problems and I got to learn lots of things.

The very first problem was I was not familiar with CGI and I had never used CGI with C++.
So the first thing was to learn about CGI So I searched for CGI and collected some information about it. After this was to the turn to configure apache to support CGI. So I searched How to do it and started doing it Everything was already configured and CGI was working already.

Now I could start working with the project. CGI files are placed in /usr/lib/cgi-bin/ But you can change this directory and use your own directory by changing apache configuration in /etc/apache2/site-available//default file. Now I can start working on the project.

The very first problem that how to parse the POST, GET data and how to handle File Uploads with CGI. So After researching a little I found a library RUDECGI which allowed me to do that. It is a very simple library with lots of usefull function.

Installation procedure is pretty simple
./configure
make
sudo make install

How to use RUDECGI

Include file: rude/cgi.h

and use -lrudecgi while compiling to link the libraries. like this

g++ -o main main.cpp -lrudecgi

Initializing CGI object syntax: CGI cgi
There are many methods of the object but I have used only the following method in the program
cgi.value("")  This function to get value of get or post data.
cgi.isFile() Check if file was uploaded then
cgi.filename to get the name of the uploaded file

Now was the turn to learn about database. I was only familiar with MySQL So I thought of using some other DBMS this time. I had heard about SQLite and that it is very small and takes very small space and is even used by many mobile operating systems. So I thought about using it for my project

Sqlite header files can be installed by by executing the following commands in terminal

sudo apt-get install libsqlite3-dev sqlite3

to create a database you can use the following command

sqlite3 <database-name>

and then start entering your sql comands

or you can use sqlitebrowser

sudo apt-get install sqlitebrowser

After creating database, Now was the time to create connection to database through c++

sqlite3_open to open connection to the database
sqlite3_exec to execute sql commands which do not return anything such as INSERT, DELETE

To execute sql commands which return something we will use series of commands
sqlite3_prepare_v2() to prepare the sql statement if this return SQLITE_OK then you can proceed
sqlite3_step() to process all the rows

This was all about the database, the next problem that I faced took a lot of my time. Everything that you will put in the cgi-bin folder apache will consider it a cgi script and execute it. So you cannot store any of your javascript files,css files, and in my case photos. So I searched alot and people suggested to keep these files in document root folder for eg in /var/www as it is outside of cgi-bin folder so cgi will not execute it.

The other error I got was of C++ such as illegal conversion from const char* to char* etc which can be solved by using sstream.

All went well in the end and My task was complete and I got to learn lots of things in this week. :)) Happy Coding..

Sunday, 28 October 2012

Compiling a Boost program

Here is a sample Filesystem tutorial program

http://www.boost.org/doc/libs/1_50_0/libs/filesystem/example/tut1.cpp

We will try to compile this program

So Assuming that you have installed boost libraries. If not then read my previous post

Now to compile any boost related program we will be needing the header files, the libraries and the boost_root folder. Boost_root folder is the folder from where you have installed boost. In my previous post my boost_root is boost_1_50_0. Next step is very easy you have to run the following command in Terminal.

g++ tut1.cpp -o first -lboost_filesystem -lboost_system -I path/to/boost_1_50_0

Feel free to comment if the above command is not working for you

Installing Boost 1.50 in Ubuntu 12.10

Source:http://ubuntuforums.org/showthread.php?t=1180792

I have made few changes

Welcome. This a guide on how to install the Boost libraries from source. Although the boost libraries are available in the universe repository there are people who have tried to install from source for one reason or another (myself included) and, because of the unfamiliar method by which Boost choose to create their libraries, fall into trouble or else never really understand what to do (even though it's not all that hard actually).
This is only a very simple guide on how to get the source compiled and installed and I wont go into more advanced topics on how to customize the installation (because I don't know myself) or on how to cross-compile (since I've tried and given up on that -- the problem being that the boost build system doesn't use the correct cross-compiling binaries for compiling and creating the libraries and it's next to Alchemy trying to understand how to get the thing to use the correct ones. As a last resort, not even creating symlinks from the the cross-compiling binary to the corresponding normal build binary didn't work!).

-1) General Information

This guide is specifically written for boost libraries version 1.39.0. The general idea of what we're doing will probably still apply for some of the more recent older library version; but, there will be crucial differences, like the fact that the file configure will exist instead of bootstrap.sh.

0) Pre-requisites

0.1)
You will need the necessary compiling tools (g++, ld, etc...); so, first, install them:
Code:
sudo apt-get install build-essential g++
0.2)
You will need the source code! Boost's website is not the best when it comes to finding where things are, so just navigate to their getting started page and under the section Get Boost follow the link to the download page and download tar.bz2 file (the tar.7z file has Windows line-terminators, so reading those files in Linux will cause errors). Incidentally, that getting started page is the general reference from which I've derived this guide (along with a bit of trial and much error).

1) Compile the library

1.1)
Go to where you downloaded the directory and uncompress it:
Code:
cd download_location
tar xjf boost_1_50_0.tar.bz2
Note that the uncompressed source is over 250Mb; so if space is an issue, make the necessary sacrifices!
Then change directory into the boost directory:
Code:
cd ./boost_1_50_0
1.2)
Next, we'll need to build the bjam binary and perhaps also set some options on what to compile and where to. Read the next three sub-sections carefully and read it all before you do anything! 

1.2.1)
Firstly, you will not want to compile the whole boost library since that means compiling a lot of libraries that you don't want or wont use. So, to see a list of the libraries that need compiling, run:
Code:
./bootstrap.sh --show-libraries
Pick which ones you want and remember them: I'll be choosing filesystemprogram_options and system. Note that picking system is needed since it contains the error class that filesystem uses, and I bet that, since the majority of you readers will be looking to compile the filesystem library, this means cutting a few problems out later on for a lot of you!
What you'll need to run is the command:
Code:
./bootstrap.sh --with-libraries=filesytem,program_options,system
But don't do that just yet: keep reading!
If you do want to compile the whole damned thing, then you don't need to bother with the command above: you'll just run bootstrap.sh as it is:
Code:
./bootstrap.sh
Again, don't run anything yet: still keep on reading!

1.2.2)
Next, you'll need to consider where you want the library installed to. By default, the header files are installed to /usr/local/include, and the libraries themselves are installed to /usr/local/lib. These locations will be more than adequate (it's not recommended to install stuff to /usr/include, /usr/include/lib or /lib); but, if you do want/need to specify a different location, you'll need to run bootstrap.sh like this:
Code:
./bootstrap --libdir=/my/lib/dir --includedir=/my/include/dir
which will install the libraries to /my/lib/dir and the header files to /my/include/dir.
Note: there is a bug in that the libraries are installed to /lib and not /usr/local/lib by default; so I'd recommend explicitly telling the build process to install to /usr/local/lib. Do this by adding the flag: --exec-prefix=/usr/local.
Still, don't run anything yet! Keep reading!

1.2.3)
OK, now bring the info from the last two sub-sections together: you'll want the command:
Code:
./bootstrap.sh --exec-prefix=/usr/local --with-libraries=desired_list_of_libs --libdir=/my/lib/dir --includedir=/my/include/dir
For example, I want to only install the filesystemprogram_options, and system libraries, and just to the default lib and include directories; so, I'll personally run:
Code:
./bootstrap.sh --with-libraries=filesystem,program_options,system --exec-prefix=/usr/local
Having done this (or something similar depending on what you want to do) you'll see the message:
Quote:
Bootstrapping is done. To build, run:

./b2

To adjust configuration, edit 'project-config.jam'.
Further information:

- Command line help:
./b2 --help

- Getting started guide:
http://www.boost.org/more/getting_st...-variants.html

- Boost.Build documentation:
http://www.boost.org/boost-build2/doc/html/index.html
At this point, you can then do the compiling proper...

1.2.4)
Run the command:
Code:
./b2
And that's it!

2) Installation

Immediately after compiling, and before we install them, the header files will be in the directory boost, and the libraries in the directory stage/lib. To install them, just run:
Code:
sudo ./b2 install
Note that, on my system, that command seems to hang for a while; so, give it a chance before killing it.

In my case there was no need to do this step as libboost_filesystem.so was already there in /usr/local/lib

Now, there is one "bug" in the installation process. The installation procedure does not create a symlink called libboost_filesystem.so. It's not really a problem, but it's very useful if it does exist. Look in your library directory to see if it's there, or else create it:
Code:
sudo ln -s /usr/local/lib/libboost_filesystem-gcc43-mt.so /usr/local/lib/libboost_filesystem.so
And change /usr/local/lib if you changed where you installed your libraries to at stage 1.2.3, and amend libboost_filesystem-gcc43-mt.so if it's different on your system. (Post a comment if you are having trouble with this since the names will probably be different from system-to-system and don't do anything if you're not at all sure on how libraries are named and symlinked).

3) Using the libraries

This bit normally causes a few problems, so read it carefully!

3.1)
Include your header files as usual in your code like:
Quote:
#include <boost/filesystem.hpp>
and then tell your compiler where the include libraries are with a -I flag:
Code:
g++ -I/usr/local/include/boost-1_39 ...
If you changed your include directory at stage 1.2.3 by issuing:
Quote:
./bootstrap.sh --includedir=/my/include/dir
then you'll need to amend the g++ command to:
Code:
g++ -I/my/include/dir/boost-1_39
3.2)
Then, we'll also need to make sure we can link to the libraries.
If you did not change the directory to where the libraries are installed to from the default at stage 1.2.3, then simply run:
Code:
sudo ldconfig

Note: If you are using Filesystem then also add lboost_system with it as it is dependent on it

And you can start linking the library as usual:
Code:
g++ -lboost_filesystem -lboost_system ...
If you did change the lib directory at stage 1.2.3 by running:
Quote:
./bootstrap.sh --libdir=/my/lib/dir
then you'll need to run the linking stage as:
Code:
g++ -L/my/lib/dir -lboost_filesystem
Hopefully, that's it! You should now be able to use boost!

So The final Code to be run on terminal will look something like this if you have not changed the installation directory on step 1.2.3

Sample.cpp //Sample program to check if boost is working or not
#include<boost/filesystem.hpp>
int main()
{
//anything here
return 0;
}

Code:
g++ -lboost_filesystem -lboost_system Sample.cpp
Feel free to comment below if I have missed something! Happy Coding

Always remember in perl

Use eq to compare string and == to compare numeric

Tuesday, 16 October 2012

Need for Speed Most Wanted Lan Multiplayer problem

NFS MW is the best game ever made by EA that still millions are playing even after 7 years of its release. The best thing it had was the gameplay and the story. We often used to play LAN Multiplayer in it. But after installing Windows 7, most of the times it stopped working after connecting to the host player or while connecting to host player. The Need for speed is causing these problems because Windows is not providing him with enough privileges to connect to the port. So run it in as Administrator in Windows 7. Everything will work fine. :)

Tuesday, 24 July 2012

Download Youtube Videos from terminal

It is very simple to download videos from Linux terminal.
Just download the following package using this command in Ubuntu

$ sudo apt-get install youtube-dl

After the installation is complete, use the following command to download videos from youtube

youtube-dl www.youtube.com/watch?v=(random)

Videos by default are downloaded in home folder. Look in your home folder for downloaded videos

Sunday, 6 May 2012

Ubuntu Showing old GUI buttons and menus

One day when I started my ubuntu, everything was changed. It was suddenly changed into Windows 95. I thought of googling it but was not able to figure out what to write in google. After a little search and help from AskUbuntu.com I was able to figure out the reasons. But none of them worked for me. Here the page where solutions are given
http://askubuntu.com/questions/73576/appearance-does-not-change-on-switching-the-theme

 You can take help from this page but none of them worked in my case. After sometime I was hit bya n thought that I had installed GTK 3.4.2 recently on my Ubuntu. So I removed it and rebooted and every thing was working just fine...:)

Wednesday, 2 May 2012

Nvidia Drivers Installation on Dell N5110

Don't expect me to write the steps of installation of Nvidia drivers on Ubuntu because you will not install it as it will lead to very harmful consequences. Enjoy your laptop with nvidia drivers, Drivers will not improve the performance of laptop in any way so please.

Sunday, 29 April 2012

Default Arguments in Javascript

I don't know why javascript do not support default arguments. They should add that. Anyhow there is a another way to perform the same operation. Here is an example
In other languages we pass default arguments like this
int function( var=value,var=value)

We don't have this facility in Javascript so we length of code increases a bit. We can do the same by following method.

function sum(a1,b1)
{
a1=a1?typeof a1=="undefined": default-value;
//meaning
//if the type of variable a1 is undefined that means that the user has not passed any value so we can assign
//our own default value.
typeof operator in javascript returns a string telling the type of variable

for eg:
var abc="Piyush";
alert(typeof abc);
this will return string signifying that the variable is string.

It is very simple.
Happy Coding.

Tuesday, 24 April 2012

Recovering MySQL Database without using MySQL

This post will tell you how to recover your databases without using MySQL or when you are not able to access MySQL. I had to do this when while experimenting I ruined my Ubuntu. I had to recover data from it. So I used Ubuntu Live Cd to excess the ubuntu ext4 drive to backup the data. From live cd we cannot access MySQL but I had to backup my database. So I just copied my database folder from /var/lib/mysql. After installing Ubuntu and MySQL and other softwares all over again I thought of just replacing database folder with the one which I copied but that didn't worked.

Recently I had used dpkg-reconfigure to solve some password problem. So I tried using that and my database was working just fine after that.
Now How to do this in detail :P
You will find folder for each of your database in /var/lib/mysq. You need root permissions to view files of this folder. You can do this by executing the following command in the terminal:

$ sudo nautilus

Then navigating to /var/lib/mysql. In this folder you will find one folder for each of your databases and other mysql files. I copied whole of the folder and kept at some safe place. Now after reinstalling Ubuntu and Lamp-server, I had to get my databases back. So I just made the same database in mysql so that a folder in /var/lib/mysql gets created. I did this because I thought mysql has other places where it saves information such as current databases and all. So by doing this thing, mysql will do all of its stuff and update all of its settings. Now just stop mysql services using:

$ sudo service mysql stop

After that I copied my database folder from backup mysql folder to the current mysql folder that is in /var/lib/mysql
You will be needing super user privileges for this. 
Don't think that the work is finished mysql will not work after this. You can check this by opening it in phpmyadmin or through mysql console.It will give some error. Now you have to reconfigure mysql package to make it work. Execute the following command in the terminal.

$ dpkg-reconfigure mysql-server-5.4

After executing this command it will reconfigure whole of the mysql server and will ask for passwords and all. Enter your password for mysql and you are done. Mysql service will automatically start after this. Just check your database after this using phpmyadmin or mysql console. In my case it was working just fine and hoping the same from your side.

Friday, 23 March 2012

Installing CMU Sphinx in Ubuntu 11.10

It took me 2 installation to install CMU Sphinx successfully. But finally now it is working. Actually I also don't know how to install it but the internet helped me out. So the very first thing that you should do to download latest sphinxbase and pocketsphinx from their website.
http://cmusphinx.sourceforge.net/wiki/download/

After downloading the packages Its time for you to download dependencies. Here is the list of packages that I had to install to make it working. Screenshot of my Ubuntu Software Center.


Install all the packages that I have installed today in the screenshot. After installing all the packages now you can extract sphinxbase compressed file and open the directory and open the sphinxbase directory through the terminal and run the following commands which are normally executed to build a packages manually.
./configure
sudo make
sudo make install
Now unpack the pocketsphinx file and enter extracted directory of pocketsphinx using terminal using the cd command. and the above commands again
./configure
sudo make
sudo make install

After executing these command you can also execute this command to clean up all the mess created.
sudo make clean


NOTE: While executing ./configure focus on the output, It still there is any dependencies left to be installed, the configure script will issue an error something like that this package is missing. Install that package and then try again running the ./configure command.
Best of luck
Happy Coding.!! :)

Edit: List of packages so that you can copy and paste

libdpkg-perl
fakeroot
debhelper
libalgorithm-merge-perl
libgstreamer-plugins-base0.10-dev
libalgorithm-diff-xs-perl
po-debconf
libgstreamer0.10-dev
intltool-debian
gir1.2-gst-plugins-base-0.10
build-essential
dpkg-dev
html2text
patch
libalgorithm-diff-perl
pocketsphinx-hmm-wsj1
libpocketsphinx1
libsphinxbase1
pocketsphinx-utils
pocketsphinx-lm-wsj
gstreamer0.10-pocketsphinx
gir1.2-gstreamer-0.10
libqtgstreamer-0.10-0
libglib2.0-dev
zlib1g-dev
libqtglib-2.0-0
libtool
libltdl-dev
autoconf
automake
autotools-dev
bison
m4

Saturday, 11 February 2012

Installing Opencv 2.3 in Ubuntu

Opencv is an awesome library for Real-Time Computer Vision. You can read my article on the same blog  for details about Opencv. I found this atricle in the internet which is the best article for installing Opencv on Ubuntu. You can visit the following link or you can read it on my own blog.
http://thebitbangtheory.wordpress.com/2011/10/23/how-to-install-opencv-2-3-1-in-ubuntu-11-10-oneiric-ocelot-with-python-support/#comment-224
I will be commenting in between, on how I installed it and what problems I faced


This “how to” is a mix of two other great tutorials on OpenCV installations: A Compreehensive Guide to Installing and Configuring OpenCV 2.3.1 on Ubuntu from ozbots.org; and the OpenCV Installation Guide on Debian and Ubuntu from the OpenCV Wiki. I used this procedure to successfully install OpenCV on two amd64 computers (a laptop and a desktop) running Ubuntu 11.10 Oneiric Ocelot. However, if you find any problem you can check the Comprehensive OpenCV Installation Troubleshooting Guide from ozbots.
1. Remove any installed versions of ffmpeg and x264
1sudo apt-get remove ffmpeg x264 libx264-dev
2. Get all the dependencies
This will take lots of time seriously. The problem I faced here was that some of the packages are not there or are missing so It was not executing the command.Here is the trick that I used while Installing for the following steps
You can use the very first command as it is i.e. sudo apt-get install update
You can break the second apt-get command like this
sudo apt-get install build-essential
sudo apt-get install checkinstall
sudo apt-get install git
See and compare.
.... and so on
Copy all these commands in a file named try and save it. Now run the following command in the terminal
sudo bash try
This execute each command serially and so even if some packages are missing it will install the other packages. And don't worry about the missing packages..You will be doing fine without them.
1sudo apt-get update
2sudo apt-get install build-essential checkinstall git pkg-config cmake libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev libpngwriter0-dev libpngwriter0c2 libfaac-dev libjack-jackd2-dev libjasper-dev libjasper-runtime libjasper1 libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev texi2html yasm zlib1g-dev zlib1g-dbg zlib1g libgstreamer0.10-0 libgstreamer0.10-dev libgstreamer0.10-0-dbg gstreamer0.10-tools gstreamer0.10-plugins-base libgstreamer-plugins-base0.10-dev gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-ffmpeg pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-prog libavcodec-dev libavcodec52 libavformat52 libavformat-dev libxine1-ffmpeg libxine-dev libxine1-bin libunicap2 libunicap2-dev libdc1394-22-dev libdc1394-22 libdc1394-utils swig python-numpy  libpython2.7 python-dev python2.7-dev libjpeg-progs libjpeg-dev libgtk2.0-0 libgtk2.0-dev gtk2-engines-pixbuf
3. Download and install x264 – download any recent stable snapshot from ftp://ftp.videolan.org/pub/videolan/x264/snapshots/  (I used x264-snapshot-20111012-2245-stable.tar.bz2) and extract it to a folder. Then enter the folder and configure and build it:
This step will not take much time
1./configure --enable-static
2make
3sudo make install
NOTE: In my computers (64-bit) I had to add the flags “–enable-pic –enable-shared” to the configuration. Otherwise I would get compilation errors when building OpenCV. If you get them too, run
1sudo make clean
and reconfigure and rebuild using
1./configure --enable-static --enable-pic --enable-shared
2make
3sudo make install
4. Download and install ffmpeg – download any recent stable snapshot from http://ffmpeg.org/download.html (I used ffmpeg-0.8.5.tar.gz) and extract it to a folder. Then enter the folder and configure and build it:
This may take some time.
1./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
2make
3sudo make install
NOTE: Once again, in my computers (64-bit) I had to add the flags “–enable-pic –enable-shared” to the configuration. Otherwise I would get compilation errors when building OpenCV. If you get them too, run
1sudo make clean
and reconfigure and rebuild using
1./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-pic --enable-shared
2make
3sudo make install
5. Download and install v4l – download any recent stable snapshot from http://www.linuxtv.org/downloads/v4l-utils/ (I used v4l-utils-0.8.5.tar.bz2) and extract it to a folder. Then enter the folder and build it:
1make
2sudo make install
6. Download and install OpenCV – download OpenCV 2.3.1 from  http://sourceforge.net/projects/opencvlibrary/files/ and extract it to a folder. Then enter the folder and build it:
This step can also take some time. Just sit behind and watch.
1mkdir release
2cd release
3cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..
4make
5sudo make install
7. Configure Linux – add the following line to your .bashrc in order to tell linux where the shared libraries for OpenCV are located without having to enter it everytime you start a new terminal:
1export LD_LIBRARY_PATH=/usr/local/lib
using any text editor add the following lines to the end of your /etc/bash.bashrc file
root permission should be given to gedit. You cannot edit the bash.bashrc file without it.
The following command will work for you
sudo gedit /etc/bash.bashrc
1PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
2export PKG_CONFIG_PATH
8. Reboot.
That’s it! If you perform all the steps indicated you should have OpenCV installed in your system. You can check the samples in <your opencv folder>/samples/ . To compile all the C/C++ samples at once you can enter the <your opencv folder>/samples/c folder and give the build_all.sh script permissions to be executed
1chmod +x build_all.sh
Then just run
1./build_all.sh
and all the samples will be compiled.
To make python work run
1python
2import cv2
If no error occurs, then the python wrappers are successfully installed.
To compile code that uses OpenCV libraries use
1g++ `pkg-config --cflags opencv` my_code.cpp -o my_code `pkg-config --libs opencv`
If you find any problems in this tutorial post them in the comments. I can’t promise that I’ll find the solution, since I’m not an expert, but I’ll try.
Update (24/10/11): I placed an entry on this blog on How to use CMake with OpenCV to build projects that use the OpenCV libraries.Check it out if you want
Update (29/01/12): As suggested by blog reader Cactus (thanks for your contribution :) ), I’ve added the packages “libopencore-amrnb-dev” and “gtk2-engines-pixbuf” to step 2.
Later I’ll post some basic projects using OpenCV.

 I successfully installed opencv on my system. Hoping same from your side. Gud Luck . Happy Coding.