Programming

Algoritmo para determinar si un entero positivo es primo en JAVA

0

A continuación tienen el archivo “primo.java”, compilarlo y ejecutarlo pasándole como argumento un número entero positivo cualquiera.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public class primo{
	public static void main(String [] args){
		int numero=new Integer(args[0]).intValue();
		boolean esprimo=true;
		int divisor=0;
		for(int i=2;i<=(numero/2);i++){
			esprimo=esprimo && (numero%i!=0);
			if(!esprimo){
				divisor=i;
				break;
			}
		}
		System.out.println(esprimo+" - el divisor es "+divisor);
	}
}

Compile linux-* kernel packages

0

In Debian Like Systems it goes like this…

Installing need packages

1
apt-get install kernel-package libncurses5-dev fakInstalling need packageseroot wget bzip2 build-essential

Download and decompress the kernel from kernel.org

1
2
3
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.22.3.tar.bz2
bzip2 -d linux-2.6.22.3.tar.bz2
tar xvf linux-2.6.22.3.tar.bz2

Configure the source for compilation

1
2
3
4
cd /usr/src/linux-2.6.22-3
make clean && make mrproper
cp /boot/config-`uname -r` ./.config
make menuconfig

Load alternate file > .config > ESC > Save? Yes

Compiling

1
2
make-kpkg clean
fakeroot make-kpkg –initrd –append-to-version=-custom kernel_image kernel_headers

Installing new linux-headers package

1
2
3
cd /usr/src
dpkg -i linux-headers-2.6.22.3-custom.deb
dpkg -i linux-image-2.6.22.3-custom.deb

Reconfiguring using new kernel (before boot or install linux-image)

1
export KERN_DIR=/usr/src/linux-headers-2.6.22.3/

Use the new kernel headers to configure you application, in my case Virtualbox

1
/etc/init.d/vboxdrv setup

Regards.

:-)

PHP Query String Class

0

This class can manipulate query strings used in HTTP requests that are used to pass arguments and values to page scripts.

It can get and set argument values, delete arguments and count the number of ocurrences in a given query string.

Download source code from:

http://www.phpclasses.org/browse/package/2378.html

Or from this blog:

Querystring-2008-02-26.tar.gz

Go to Top
?>