Wednesday, May 11, 2016

Web-based Notifications Implementation

Hi, The following code samples may help you in implementing web-based notifications in your portal/website without using any third party library.

Notification Window CSS Code:
Notification Window UI Code:
Notification window UI will look like, as follows
JavaScript Code to View / Hide Notification Window:
Expanded notification window will be look like, as follows

Monday, March 14, 2016

Shell Script to Extract Email ids from Website URL

It is always tedious work to extract e-mail ids from websites for publicity purpose. So I created a shell script which automate the extraction of mail ids from URLs.

#!/bin/bash

# SCRIPT NAME: mail_id_extractor_from_url.sh

# DESCRIPTION: This script takes a list of seed URLs and extracts all sub URLs and referenced URLs from seed URLs. Visits all sub and referenced URLs of seed URLs and extracts mail ids.

# USAGE: bash mail_id_extractor_from_url.sh website_list.txt
# website_list.txt file contains all seed URLs to extract mail ids.

#AUTHOR: Reniguntla S

filename="$1"
while read -r seed_url
do
    name="$seed_url"
    lynx -dump $seed_url | grep "http" >> sub_urllist0.txt
done < "$filename"

cat sub_urllist0.txt | awk '{print $2}' > sub_urllist1.txt
sort sub_urllist1.txt | uniq -u > sub_urllist.txt
rm sub_urllist0.txt sub_urllist1.txt
echo "Extraction of sub URLs of seed URLs done"

mode=1
if [ "$mode" -eq "1" ];then
echo "Be patient, It will take some time :-)"
cat sub_urllist.txt | while read url
do
echo $url
curl $url > url_text.txt
grep -E -o "\b[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+\b" url_text.txt >> mailids.txt
done
fi

sort mailids.txt | uniq >> extracted_mail_list.txt
rm mailids.txt url_text.txt
echo "Email ids extraction done. Check extracted_mail_list.txt file"
exit 0

# End of script


Thursday, March 3, 2016

Short Term Courses on Data Science

Call for Participation
Short-term courses on Data Science
CDAC, Kharghar, Navi Mumbai

We are living in a Data Age. Data is being continuously generated and consumed in various formats, and sizes from a number of varied sources. This data can be a big asset if stored, processed and analysed efficiently in real time with the help of intelligent algorithms. There is a growing interest to utilize such data for the improvement of business, health, education, society, etc. There are many ways to process and analyse such data spanning techniques like data visualization, text analysis, predictions and recommendations etc. Applications of these techniques can give companies and organisations valuable insights leading to competitive advantage, efficient service delivery and above all customer satisfaction. And so the demand for skilled resources in these fields is growing day by day.


With this view, CDAC, Mumbai is announcing the following short-term courses in Data Science and Machine Learning.
--Using R for data visualization and analytics
--Text Analytics
--Predictive Analytics and Recommender Systems
For more details and registration, please visit at http://www.kbcs.in/datascience.



Wednesday, September 9, 2015

Accessing MySql Database in R for Analytics

Step-1: Open / connect to your MySql by running following command.                                        
Step-2: Create test database and ensure test database created or not as shown in following figure.














Step-3: Now create a table student with student id and total marks as its fields as shown in following figure.












Step-4: Insert some data into student table as shown below.


Now student data is ready in MySQL. Now we will see how we can access student data in R.

Step-5: Before installing RMySQL package in R make sure you installed mysql-connector-c. To install mysql-connector-c run the following command in terminal.

sudo apt-get install libmysqlclient-dev    // on debian or ubuntu

yum install mysql-devel   // on RHEL, Cent OS, Fedora

Step-6: Now Open your RStudio and install MySQL package. To Install MySQL package click on Tools ->Install Packages...

Step-7: Now write a R Script as shown in following picture to read student data from MySQL. For more details please read the comments mentioned in below R code.


Tuesday, September 8, 2015

Fixing GPG NO_PUBKEY Error

              By default R version 2.14.1 available on my Ubuntu 12.04 LTS system. I decide to generate some interactive graphs in R but I was not able to generate them because 2.14.1 is very old version of R. So, I decided to upgrade my R from 2.14.1 to 3.2.2 version. So, added an entry into sources.list as shown in following picture.

List of R mirrors can be found at https://cran.r-project.org/mirrors.html.

After made an entry into sources.list and update the system by running following command.

sudo apt-get update

This update command some times throws an error like "GPG error NO_PUBKEY". We can fix this error using y-ppa-manager. To install y-ppa-manager run the following list of commands.

sudo add-apt-repository ppa:webupd8team/y-ppa-manager  // adding repository for y-ppa-manager

sudo apt-get update // updating repository

sudo apt-get install y-ppa-manager // Installing y-ppa-manager

After installing y-ppa-manager, start y-ppa-manager by typing the same in the terminal and it will display GUI as shown below.























Click on Advanced Option and then Select "try to import all missing GPG keys" and click on OK as shown in following figure. It will fix the error "GPG error NO_PUBKEY". Run sudo apt-get update again to see error is fixed or not.


Wednesday, August 26, 2015

R and JRI Integration with Java for Analytics

Different ways(rJava with JRI, RServ, RCaller, Renjin) are there to integrate R with Java to perform some analytic work inside the Java (Servlet / controller). In this post I would like to show, how you can integrate rJava and JRI with java to run R code inside Java.

JRI Integration with Java: JRI stands for Java-R Interface and It is a part of rJava. Using rJava we can manipulate Java objects inside R using JNI (Java Native Interface) which is the natural way of calling compiled binary code in Java but JRI is reverse of it. In JRI we can call R inside Java. This library has some merit among others, in means of full interoperability between R and Java using callbacks. It is robust for large scale projects, however, it is painless at start-up process for relatively small projects.

To Install R on debian based systems run the following command
sudo apt-get install r-base-dev

Now to install rJava package in R run the following command
sudo apt-get install r-cran-rjava

Other wise you can run following command in R to install rJava
install.packages("rJava")

Once you install the R and rJava, to find the location of JRI inside rJava run the following command in R.
system.file("jri",package="rJava")







Now export R_HOME=/usr/lib/R, LD_LIBRARY_PATH=/usr/lib/R/site-library/rJava/jri into environment and add both of them in the Java library path also.

Now open your eclipse create a simple Java project "JRITest" with the below mentioned code. Before running the code in eclipse set R_HOME and LD_LIBRARY_PATH environment variables in eclipse. For setting up environment variables in eclipse

Right Click on Project -> Run As -> Run Configurations -> Environments then add environment variables with their values as shown below.





Sample Code To Test JRI In Java:
Sample Input Output:


Tuesday, June 23, 2015

Problems Faced By Motor Disability Persons In HCI

                    Computer trainers often comment on the fact that conventional devices are hard to use whose fingers might not be as steady or mobile anymore. Moreover Limited muscular control can cause lack of coordination or involuntary movement or impede movement altogether. Wide range of problems are faced by physical / motor disability persons in accessing computers, Some of them are as follows.

  • Pressing key board keys continuously- A physically challenged user can find pressing key board keys continuously for typing to be laborious due to limitations in motor control.
  • Long key press problem- An alphanumeric key is unintentionally pressed by differently enabled user for longer than the default key repeat delay because of slow typing speed.
  • Additional key press problem- During typing, A key adjacent to the intended key may be activate accidentally.
  • Key bounce problem- The end user may unintentionally presses the intended key more than once.
  • Difficulty in using hot keys- Some times it is not even easy for normal users to use hot keys. So, obviously motor disabilities find it more difficult to use SHIFT, CTRL and ALT keys with the combination of any other Keys.
  • Keys transposition error- When two keys are typed in the wrong order, a transposition error has occurred. Motor disabilities usually face this problem.
  • Mouse pointing problem- Mouse pointing is there in almost every operation of mouse like selecting one icon, among so many icons and closing an active window with mouse etc. So, pointing is the most fundamental mouse operation and also one of the most difficult for motor disabilities because Mouse pointing involves moving pointer in a desired direction and positioning at required place.
  • Navigation problem- For example in Debian based systems, if user wants to open gedit text editor, then user needs to navigate through Applications ->Accessories ->gedit. This requires three mouse button clicks which is inconvenient for some kind of motor disabilities.
  • Selection of text- involves to hold down mouse button and drag or hold down Shift key and press right arrow continuously. So, physically challenged people face problem in selection of text.
  • Hand-eye coordination problem- Hand-eye coordination is the ability of the vision system to coordinate the information received through the eyes to control, guide, and direct the hands in the accomplishment of a given task. Some kind of motor disabilities suffer from this problem because their hands doesn't give them enough support to process information received by eyes.
  • Drag and drop problem- Once a drag had been started, the most common difficulty is in raising the mouse button in the correct position at the end of the drag. Another common problem is in holding down the mouse button while moving the mouse to the target.