Saturday, February 23, 2013

jQuery Hello World Plugin

jquery hello world plugin tutorial
In this tutorial we are going to make a very simple jQuery plugin. Sometimes its important just to see the simple first step, instead of getting caught in the complexities of detail. So lets start writing the our Hello World Plugin sayHello.



(function ( $ ){
 $.fn.sayHello=function(){
  this.html("Hello World from jQuery Plugin");
 };
})(jQuery); 

First we need to wrap our code into an self executing function, so that when the page load it executes. Then we pass a jQuery object $ as a parameter to avoid variable conflict. Next we need to extend the jQuery Prototype $.fn. and add a new function sayHello, this function will change the HTML of the target div with the content as shown above. You can use it as shown below,

<div id="helloWorldDiv"></div>
<script>
$(document).ready(function () {
  $('#helloWorldDiv').sayHello();
});
</script>

That's it for this tutorial, in coming tutorials we will look deep in jQuery Plugin development.
Continue Reading...

Friday, February 22, 2013

Backtrack 5 Screen Resolution VMware

i have download Backtrack 5 r3 and install it in VMware, everything went smooth unit when i start the GUI. The display was very small, as i am not a Linux pro, i started to here and there to change the screen resolution. Then i googled and found tutorials regarding screen resolution most of them i had seen describe to change xorg.conf file, i tried but nothing happened. Then i happened to cross a forum post which gives the most easiest and quickest solution to all i.e.

Goto System -> Preferences -> Monitors as shown in the screenshot below:

Backtrack 5 Screen Resolution VMware

There will be a popup window on which you adjust your desied screen resolution and click apply, you dont have to restart the machine or need to alter any file.

Change Screen Resolution in Backtrack 5


Continue Reading...

Thursday, February 21, 2013

Capturing a Screen Shot in JAVA

This tutorial provides you with code to capture a screen shot using java. You can capture a part of screen or the whole screen as well. Just copy the below code and save the file as ScreenShotPanel.java compile and run it using java SDK.

import java.awt.*;
import javax.swing.*;

/**
 *
 * @author Originative
 */

class ScreenShotPanel extends JPanel{
    Image screenShot=null;
    Rectangle area = null;
    private Image image;
    public ScreenShotPanel(){
        JLabel imagePanel=new JLabel();
        
        // Capture a particular area on the screen
//        int x = 100;
//        int y = 100;
//        int width = 400;
//        int height = 400;
//        area = new Rectangle(x, y, width, height);
//        screenShot=ScreenShotPanel.captureImage(area);
        
        // Capture the whole screen
        area = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
        screenShot=ScreenShotPanel.captureImage(area);
    }
    
    
    public static Image captureImage(Rectangle area){
        Image img=null;
        try{
            Robot robot = new Robot();
            img = (Image)robot.createScreenCapture(area);   
        }
        catch(Exception e){
            System.out.println(e);
        }
        return img;
    }
    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.drawImage(screenShot, 0, 0, null);
    }
    public static void main(String []nix){
        ScreenShotPanel screenShotPanel=new ScreenShotPanel();
        JFrame screenShotFrame=new JFrame();
        screenShotFrame.add(screenShotPanel);
        screenShotFrame.setSize(800, 800);
        screenShotFrame.setVisible(true);
        screenShotFrame.setTitle("Capturing a Screen Shot - Tutorial Jinni");
        screenShotFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}


if every thing works as excepted then you will see a similar window as below.

Capturing a Screen Shot in java

Continue Reading...

Wednesday, February 20, 2013

Videojs Flash Fallback Example

Videojs Flash Fallback Example
VideoJS is a HTML5 Video Player, recently i started using it in a project i choose it for is supper easy installation which is easy by just adding one video.js file and video-js.css a css file, both are hosted on free CDN. While working on the project i find out that it does not fall back on it own when using an flv or MP4 source file in Firefox web browser, i googled a bit and found out that Firefox can not play MP4 files, to make consistent in all browser i have to force video.js to play in flash to make this this work you have to do the following in your embed code.

<video id="example_video_1" class="video-js vjs-default-skin" controls preload="none" width="640" height="264"
      poster="http://html5video.org/players/media/sintel.jpg"
      data-setup='{"techOrder": ["flash", "html5"]}'>
    <source src="http://html5video.org/media/sintel.mp4" type='video/mp4' />
</video>

All you need is to change this order

data-setup='{"techOrder": ["flash", "html5"]}'

A sample player with the above config is shown below, it force videojs to fallback to flash.

Continue Reading...

Tuesday, February 19, 2013

No response from subprocess ( (cpanel)) with exit signal: 0

Today, I tried logging into my cpanel and got the following error message:

No response from subprocess ( (cpanel)) with exit signal: 0
to my reckoning this may be the result of an up-gradation of cpanel software, to fix this issues you need the shell and on it type the command, this will fix the errors you receive in cPanel, WHM & webmail.

service cpanel restart

or

/etc/init.d/cpanel restart

or you may try this..

/scripts/upcp -force

if none of the above works then consider submitting a ticket to cpanel support or your hosting provider to assist you.
Continue Reading...
 

Blog Info

A Pakistani Website by Originative Systems

Total Pageviews

Tutorial Jinni Copyright © 2015 WoodMag is Modified by Originative Systems