Fedora comes with a virtual machine manager( similar to vmware products) which enables you to create a virtual machine and run various other operating system. I tried installing Windows XP on a virtual machine created using virt-manager in my Fedora. Key steps to begin ..
- Make sure libvirtd demon is running
- Allocate the space as per your needs viz hard disk, RAM etc
- This one is the key step, do not forget to add a cdrom (/dev/hdc) pointning to iso image of Windows XP Disc, as after the first boot, XP installation searches for the Windows XP disk and it cannot read the host's CDROM.
Everything goes on smooth with all these parameters.
09 October, 2008
Virtual Machine on Fedora
25 September, 2008
SELinux, Apache and Postgres SQL Connectivity
16 September, 2008
Vaccum kills us, space kills javascript
language.
21 June, 2008
Draw a Circle in Java, the fundamental "pixels" way !
The following code draws a circle of particular diameter by setting the PIXELS falling inside the circle to a different RGB value. It involves simple co-ordinate geometry fundas. There are some approximations being taken.
_______________________________________________________________________________________________
import java.awt.image.*;
import javax.swing.*;
import javax.swing.JComponent.*;
public class circles extends JFrame {
public static void main(String args[]) {
double d=Double.parseDouble(args[0]);
int diameter= (int)d;
circles ca= new circles();
ca.drawCircle(diameter);
}
public void drawCircle(int diameter) {
int x=0,y=0,radius;
JFrame frame=new JFrame();
JLabel lab;
BufferedImage bi=new BufferedImage (diameter,diameter,BufferedImage.TYPE_BYTE_GRAY );
WritableRaster raster=bi.getRaster();
double [] iPix=new double [diameter*diameter];
if(diameter%2 == 1) {
diameter-=1;
}
radius=diameter/2;
for(int i=0;i
y=y%(radius);
}
else
{
y-=radius;
y=-y;
}
if((x*x+y*y)<=((radius)*(radius))) { iPix[i]=255; } else { iPix[i]=0; } }
raster.setPixels(0,0,diameter,diameter,iPix); lab=new JLabel(new ImageIcon(bi)); frame.add(lab);
frame.setVisible(true); frame.setSize(600,600);
}
}
_______________________________________________________________________________________________ _______________________________________________________________________________________________
compile the program as javac circles.java
run as java circles diameter_value
11 June, 2008
Swap two numbers without a '=' operator
Came across an interesting problem of swapping two numbers without using '=' operator. I thought of this approach. It's little lengthy and can be modified I guess.
____________________________________________________________________________
____________________________________________________________________________
#include
static int counter;
int main()
{
int a,b;
printf("Enter two numbers");
scanf("%d%d",&a,&b);
if(a>b)
{
switch ((a-b)%2)
{
case 0 :while((a-b))
{
counter++;
a--;
b++;
}
while (counter >0)
{
counter--;
a--;
b++;
}
printf("\nThe swapped set : %d\t%d",a,b);
break;
case 1 :while((a-b-1))
{
counter++;
a--;
b++;
}
counter++;
while (counter >0)
{
counter--;
a--;
b++;
}
printf("\nThe swapped set : %d\t%d",a,b);
break;
}
}
else
{
switch ((b-a)%2)
{
case 0 :while((b-a))
{
counter++;
a++;
b--;
}
while (counter >0)
{
counter--;
a++;
b--;
}
printf("\nThe swapped set : %d\t%d",a,b);
break;
case 1 :while((b-a-1))
{
counter++;
a++;
b--;
}
counter++;
while (counter >0)
{
counter--;
a++;
b--;
}
printf("\nThe swapped set : %d\t%d",a,b);
break;
}
}
return 0;
}
____________________________________________________________________________
22 April, 2008
Determining IP address for eth0 failed
I had a tough time configuring wired internet connection on UBUNTU (7.10 Gusty Gibbon) and FEDORA Core 8 boxes. However after few amendments, I was able to fix and start internet in both. The Network Adapter (eth0) was not able to take IP address from the DHCP servers of my ISP ( Reliance, the case here) because the Linux distros support the future i.e. IPv6. Hence, the task at hand was to disable IPv6 and enable IPv4.
Let us discuss both of them in detail.
Ubuntu
There is process avahi-demon running which is responsible for IPv6 assignment. It can be disabled by removing from the following location
/etc/init.d/avahi-demon. Please not that all these should be done as sudo.
This should be able to fix the problem. You can restart the network and network interfaces by
/etc/init.d/networking restart
ifdown eth0
ifup eth0
Also, the interfaces file specifies starting of Network adapter and assigning address.
cd /etc/Network/interface
It should have following entry to take IP from dhcp server for eth0.
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
Forcibly , IP address can be assigned by dhclient eth0.
Fedora Core
Disabling IPv6 in Fedora core 8 can also be done in similar fashion.
Now here is how you can do this with FC8 to disable IPv6:
Append the following line to
/etc/modprobe.conf:install ipv6 /bin/truealias net-pf-10 off
alias ipv6 offAppend the following line to
/etc/sysconfig/network:NETWORKING_IPV6=noEnsure your network adapter is configured not to use IPv6. This is an easy edit in the
system-config-networkgui, or do it manually in/etc/sysconfig/network-scripts/ifcfg-eth0(ammend for name of your adapter) by appendingIPV6INIT=no
To restart the Network Adapter and assign address using DHCP.
ifconfig eth0 down
ifconfig eth0 up
dhclient eth0
After all these changes are made the network adapter takes an IPv4 IP address and works fine.
01 June, 2007
Hey dude, shutdown the machine, enough of surfing. Oops ! but the dude is sleeping!
File - shutdown.pl
--------------------------------------------------------------------
#! /usr/bin/perl
sleep(5400); # time in seconds after which you want to shutdown.Its 5400 seconds here or 90 minutes.
system("shutdown /s /t 00");
-----------------------------------------------------------------------------------
Run the program as perl shutdown.pl
And my job was done. However there might be more smarter ways to handle the situation.
__________________________________________________________________________________
*type shutdown on windows server 2003 command prompt and read carefully
