Friday, June 14, 2013

How To Triple Boot (Windows XP/Windows 7/Ubuntu)

Many of us want to use more than one OS on laptop or PC
One option here is to use some Vmware, Virtualbox or some other software like this. These softwares runs other OS on top of the current running OS, like you can run Ubuntu on Windows 7, but do not get some functionality with this option. Now if you do not want to do this, other option is to install other OS along with the current OS, so when you start your machine you can OS to boot from.
Click here to know how to do this.


See Also : Useful Run Commands
Ads :
Ads :
Electronics, Cars, Fashion, Collectibles, Coupons and More Online Shopping | eBay
www.ebay.com | www.ebay.co.uk | www.ebay.de

How to change Facebook default theme

Have you ever thought how good it would be if you could change default theme of Facebook. Yes, now you can do this, and do it very easily.
You Just have to use the script provided below..
Instructions :
If you are using IE then just open Facebook and copy paste the script in address bar and press enter.
If you are using Firefox Create a bookmark button on bookmark bar with the script as loaction (To add bookmark to bookmark toolbar goto bookmarks->bookmarks Toolbar). Now open Facebook and click on bookmarked button. If you cant see bookmarks toolbar select View->toolbars->bookmarks Toolbar. This is just a test version that changes all the colors.
NOTE : you can enter name of color or hex code in prompt box. If you like it please click on the ad below.

javascript:change();
function change()
{
    var x = document.getElementsByTagName('title');
    x[0].innerHTML =  "ZZ Script | "+x[0].innerHTML;
    var col = prompt("Enter Color");
    x = document.getElementsByTagName('div');
    var i=0;
    while(i < x.length)
    {
 x[i].style.backgroundColor=col;
 x[i].style.borderColor=col;
        i++;
    }

    x = document.getElementsByTagName('li');
    var i=0;
    while(i < x.length)
    {
 x[i].style.backgroundColor=col;
 x[i].style.borderColor=col;
        i++;
    }
    x = document.getElementsByTagName('ul');
    var i=0;
    while(i < x.length)
    {
 x[i].style.backgroundColor=col;
 x[i].style.borderColor=col;
        i++;
    }
    x = document.getElementsByTagName('a');
    var i=0;
    while(i < x.length)
    {
 x[i].style.backgroundColor=col;
 x[i].style.borderColor=col;
        i++;
    }
    x = document.getElementsByTagName('span');
    var i=0;
    while(i < x.length)
    {
 x[i].style.backgroundColor=col;
 x[i].style.borderColor=col;
        i++;
    }
    x = document.getElementsByTagName('input');
    var i=0;
    while(i < x.length)
    {
 x[i].style.backgroundColor=col;
 x[i].style.borderColor=col;
        i++;
    }
}
Ads :
Electronics, Cars, Fashion, Collectibles, Coupons and More Online Shopping | eBay
www.ebay.com | www.ebay.fr

Monday, January 21, 2013

File IO in Android

This article shows how to make an application that can write to external storage of android device. First off all we create a new project in Eclipse, say WriteFile.
Now, we will use the method getExternalStorageState() of Environment class to get detail about the external storage state. It will return a string showing the state of external device.
public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        String status = Environment.getExternalStorageState();
    }

}
We check if it is anything else than Environment.MEDIA_MOUNTED then we terminate the app with appropriate message else we continue.
 

        String status = Environment.getExternalStorageState();
        if(!status.equals(Environment.MEDIA_MOUNTED))
         return;

Now, we know we have external storage and it also has read/write permissions. Next is to get a File object referring to the external director. Now depending on the device this may vary. So we use getExternalStorageDirectory() method to get the File object and save reference in sdcard variable.
        File sdcard = Environment.getExternalStorageDirectory();

Now we want to create a file, say a dummy.txt in the directory. To do this first obtain a reference to that file using File(String name) constructor. Then we use character streams to write data to file (We can also use the Byte Streams). Create a FileWriter to write data to file and a FileReader to read data from the file. In both constructors pass the File object of our target file. Write() method of FileWriter is used to write data to file.
        char [] buf=null;
        File newfile = new File(sdcard.getAbsolutePath()+"/dummy.txt");
        FileWriter fileWriter = new FileWriter(newfile);
        fileWriter.write("This is a demo");
        FileReader fileReader = new  FileReader(newfile);
        buf = new char[50];
        fileReader.read(buf);
Now the data from file is in buf array. We can use it the way we want now. The Full Source code is available here .

Notes : Creating File object generates FileNotFoundExceptiion and FileReader and FileWriter Both generates IOExcption, so be carefull to surround the statements with try/catch block.

Writing to external storage requires the WRITE_EXTERNAL_STORAGE permission. In a future platform release, access to this path will require the READ_EXTERNAL_STORAGE permission, which is automatically granted if you hold the write permission.



Ads :
Electronics, Cars, Fashion, Collectibles, Coupons and More Online Shopping | eBay
www.ebay.com | www.ebay.ch | www.ebay.com.my

Friday, September 21, 2012

Moving an element along a path with jquery

Many time you want to move a object (div, img) on specific path. suppose your path is not much complicated but it the combination of line, means many lines together creates the path, then you can use the following method.
For this tutorial suppose you have a div, obj and you want it to move.
First of all you will need a to create path, so as I said earlier your path is made of lines, and line have to ends.
So we will store coordinates in a two dimensional array.

 var SIZE = 4; // No of points
 var path = new Array(SIZE+1); // one extra point to complete cycle
 
 i=0;
 while(i < path.lentgh)
 {
  path[i] = new Array(2);
  i++;
 }
 // Now we have a two dimensional array
 
 // setting path,
 path[0][0] = 0;    path[0][1] = 0;
 path[1][0] = 0;    path[1][1] = 700;
 path[2][0] = 1000; path[2][1] = 700;
 path[3][0] = 0;    path[3][1] = 7;

 //completing cycle
 path[SIZE][0] = path[0][0];
 path[SIZE][1] = path[0][1];


So now we have the path, we are going to use jquery animate function, so we are going to need time also. Now distance between two poits may vary so in stead of setting time, we will set speed and calculate time from it.
 SPEED = 3;
 var itime = new Array(SIZE);
 for(i=0;i < SIZE; i++)
     itime[i] = d(i)*SPEED;
 

Here d(i) is a function defined below that gives the distance between ith ane i+1th point and we are not using speed here its actually inverse of speed. Thus increasing it will slow the animation.

 function d(i)
 {
    // for simplicity
    x1 = path[i][0];
    x2 = path[i+1][0];
    y1 = path[i][1];
    y2 = path[i+1][1];

    return Math.floor(Math.sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ))
 }

So now we have time and points for animation. So next step is to animate it.
 t = 0;
 function animateobj(obj)
 {
    $(obj).animate({left:path[t+1][0], top:path[t+1][1]}, itime[t]);
    setTimeout(function(){animateobj(obj);}, itime[t]);
    t++;
    if(t == SIZE)
       t = 0;
 }


And you are done, now from your file, just call animateobj method with appropriate id and it will do the animation.
NOTE: set path, itime, SIZE, SPEED, and t as global do not create them inside a function and also you will need jquery which is included in demo.
Click here to download demo.

Hey, if you liked it, please click on ad below...


Ads :
Electronics, Cars, Fashion, Collectibles, Coupons and More Online Shopping | eBay
www.ebay.com | www.ebay.ch | www.ebay.com.my