Java Script code that disables right click and prevents selecting the text on web page.

Java Script code that disables right click and selecting the text on web page.
Put the following code in your <body>........</body> tag.
<script>
function disableselect(e){return false;}
function reEnable(){return true;}
document.onselectstart=new Function (){return false;}
if (window.sidebar){
    document.onmousedown=disableselect;
    document.onclick=reEnable;
}
</script>

<script>
document.oncontextmenu = function(){return false;}
if(document.layers) {
    window.captureEvents(Event.MOUSEDOWN);
    window.onmousedown = function(e){
        if(e.target==document)
        return false;
    }
}else {
    document.onmousedown = function(){return false;}
}

For Blogger template,

  • Search for </body> in the template code
  • paste the above script just before </body> tage.
Enjoy !
You are now safe from website article thief.

facebook security bug - change password of a active user - without knowing original password

change password of a active user -without knowing original password - security bug - Facebook allows to change password in active login without entering current password

As of May 2012, Facebook has over 900 million active users. Security and privacy should be the number one concern of Facebook Inc. But I just found one BUG in Facebook security system.

This might (not) be a security bug in Facebook. And probably be fixed by Facebook when you tried to do the same, because I am going to report this to Facebook.

All the steps below that I am going to share - deals with changing someone else’s password without entering their previous/current password. I have never seen or write code for “login preference change” that allows to change password without entering previous password or other information.  I was shocked to know that Facebook allows it. I was just playing with Security option in Facebook’s Account setting https://www.facebook.com/settings. And found that.

Steps that I followed :

eclipse proguard maven project configuration - java obfuscate

I am going to describe how can can configure proguard and maven to obfuscate a java project. If you need help on how to configure maven project in eclipse see my earlier post.

A)Project configs
    <!-- Project configs -->
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.gt</groupId>
    <artifactId>maven-proguard-test</artifactId>
    <packaging>jar</packaging>
    <version>-ver.01</version>
    <name>maven-proguard-test-application</name>

    <properties>
        <project.build.mainClass>com.gt.App</project.build.mainClass>
    </properties>

Speech Recognition Java Code - HMM VQ MFCC ( Hidden markov model, Vector Quantization and Mel Filter Cepstral Coefficient)

Hi everyone,
I have shared speech recognition code in google code :
http://code.google.com/p/speech-recognition-java-hidden-markov-model-vq-mfcc/

You can find complete source code for speech recognition using  HMM, VQ, MFCC ( Hidden markov model, Vector Quantization and Mel Filter Cepstral Coefficient). Feel free to use and modify this code.

The project report that accompanies this code is here.
http://ganeshtiwaridotcomdotnp.blogspot.com/2011/06/final-report-text-prompted-remote.html

Introduction to the project :
http://ganeshtiwaridotcomdotnp.blogspot.com/2010/12/text-prompted-remote-speaker.html

colored object tracking in java- javacv code

Code for this demo video - Color Based Image Segmentation to Track Path of Moving Object


Working Source Code :
import static com.googlecode.javacv.cpp.opencv_core.IPL_DEPTH_8U;
import static com.googlecode.javacv.cpp.opencv_core.cvCreateImage;
import static com.googlecode.javacv.cpp.opencv_core.cvFlip;
import static com.googlecode.javacv.cpp.opencv_core.cvGetSize;
import static com.googlecode.javacv.cpp.opencv_core.cvInRangeS;
import static com.googlecode.javacv.cpp.opencv_core.cvScalar;
import static com.googlecode.javacv.cpp.opencv_imgproc.CV_BGR2GRAY;
import static com.googlecode.javacv.cpp.opencv_imgproc.CV_MEDIAN;
import static com.googlecode.javacv.cpp.opencv_imgproc.cvCvtColor;
import static com.googlecode.javacv.cpp.opencv_imgproc.cvEqualizeHist;
import static com.googlecode.javacv.cpp.opencv_imgproc.cvGetCentralMoment;
import static com.googlecode.javacv.cpp.opencv_imgproc.cvGetSpatialMoment;
import static com.googlecode.javacv.cpp.opencv_imgproc.cvMoments;
import static com.googlecode.javacv.cpp.opencv_imgproc.cvSmooth;
import static com.googlecode.javacv.cpp.opencv_highgui.*;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;

import javax.swing.JPanel;

import com.googlecode.javacv.CanvasFrame;
import com.googlecode.javacv.FrameGrabber;
import com.googlecode.javacv.VideoInputFrameGrabber;
import com.googlecode.javacv.cpp.opencv_core.CvScalar;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import com.googlecode.javacv.cpp.opencv_imgproc.CvMoments;

public class ColoredObjectTrack implements Runnable {
    final int INTERVAL = 1000;// 1sec
    final int CAMERA_NUM = 0; // Default camera for this time

Mouse Gesture Recognition Using Hidden Markov Model - Java Source Code

Hi everyone, I have uploaded the codes for my project - "Mouse Gesture Recognition with Hidden Markov Model - Java".

You can find it @ google code : https://code.google.com/p/mouse-gesture-recognition-java-hidden-markov-model/.

This svn repository @ google code contains eclipse source code (VQ and HMM codes from OCVolume Project.) , trained hmm models and codebook, captured data for few gestures.

Similar codes for Speech Recognition System using HMM/VQ + MFCC will be uploaded SOON.

DEMO VIDEO: http://www.youtube.com/watch?v=0CNJ2fCj4xQ


maven install jar to repository locally

Run the following command to install the "MyJar-x.x.x.jar" into Local maven repository. The underlined  values vary in your case.
mvn install:install-file -Dfile=PathOFJar_MyJar-x.x.x.jar -DgroupId=com.mycompany -DartifactId=myJar -Dversion=x.x.x -Dpackaging=jar

After installing, Add the dependency into Pom.xml :
        <dependency>
            <groupId>com.mycompany</groupId>
            <artifactId>myJar</artifactId>
            <version>x.x.x</version>
        </dependency>

As an alternative, you can directly refer to a jar file in your file system. This eliminates the hassle that every team member and build server to run the mvn:install command every time someone adds some local jar in pom.xml.

Take a look at following blog post for the details.
http://ganeshtiwaridotcomdotnp.blogspot.com/2016/12/maven-use-local-jar-without-installing.html


Java grey image from RGB image convert full source code

The java code below is for making grey image from a image
public static void main(String[] args) {
        BufferedImage org = getImage("test.jpg");
        BufferedImage greyImage = getGrayScaleAvg(org);
        new ImageFrame(org, "Original");
        new ImageFrame(greyImage, "After GrayScale");
    }

Full working source code : averages the pixels to obtain grey image
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class tempgrey {
    public static void main(String[] args) {
        BufferedImage org = getImage("test.jpg");//valid input image
        BufferedImage greyImage = getGrayScaleAvg(org);
        new ImageFrame(org, "Original");
        new ImageFrame(greyImage, "After GrayScale");
    }

    public static BufferedImage getImage(String imageName) {
        try {
            File input = new File(imageName);
            BufferedImage image = ImageIO.read(input);
            return image;

Job Interview Question Answer Frequently Asked - programmer


Some Common and most asked job interview question ( for programmer) and their answers. In Nepali Context.

These questions are the most common questions ( in my job haunt experience) that will be asked to you in your interview.

1. Tell me about yourself:
After finishing computer engineering from ABC campus last year, i worked as java developer. I have good command of Java related technologies. I also have interest in ABC. I find myself as a hard worker and quick learner. And I think i am a good candidate for the position.

2. Last Jobs:
My first job was at ABC as N months contract. Our responsibilites were bug fixing and upgrading an existing ABC system. It was a web app. I mainly worked in feature enhancement like : ABC and some business modules like report generations.
After finishing the contract, i joined ABC as java developer. There too i worked  in a business application for healthcare related dataprocessing/reporting application . I mainly write code for ABC , ABC etc.

3. Why did you leave your last job?
In fact it was a good time working for ABC but i couldnot find any learning opportunity there, I always wanted a challanging job where i can contribute myself and learn something. I worked there for N months and decided to quit the job.

What did you did in this free time :
After i quit the job - besides job haunting, i did a freelancing project- it was ABC,..,
Meanwhile, i learned android framework and teach java in an institute for about 1 month.


6. How do you know about this position?
I knew about this org from the job vacancy notice posted in ABC.com.

7. What do you know about this organization?
ABC is a 10 year old software company located in ABC. it mainly works on ABC. Its major clients are ABC. Major products are ABC.

11. What kind of salary do you need?
As i have few experience and skills, and this might be somehow different job from my previous ... ummm...well ... NN000 NRS/Mo will be fine.

13. How long would you expect to work for us if hired?
I would work as long as you and i both enjoy working me in ABC. I am certain that, I will enjoy the job at ABC##??

25. What are you looking for in a job?
Where i can contribute more and learn new things in the process . not only technically but also the detail of business domain on which i am working at.

50. Do you have any questions for me?
Well ... yes i think i  have one.

>> what will be the next possible step in selection process.
>> what type of responsibilities
>>

Correct way of connecting ADSL splitter and router

REMEMBER : If you need extensions, connect it after splitter only. 
Right way of connecting adsl splitter and router in telephone line
Wrong way of connecting adsl router, splitter in telephone line

correct adsl connection diagram, router, computer, splitter, telephone line