Monday, 7 December 2009

MANIFESTO on the RIGHTS of INTERNET USERS

1 . Copyright should not be placed above citizens' fundamental rights to privacy, security, presumption of innocence, effective judicial protection and freedom of expression.

2 . Suspension of fundamental rights is and must remain an exclusive competence of judges. This blueprint, contrary to the provisions of Article 20.5 of the Spanish Constitution, places in the hands of the executive the power to keep Spanish citizens from accessing certain websites.

3 . The proposed laws would create legal uncertainty across Spanish IT companies, damaging one of the few areas of development and future of our economy, hindering the creation of startups, introducing barriers to competition and slowing down its international projection.

4 . The proposed laws threaten creativity and hinder cultural development. The Internet and new technologies have democratized the creation and publication of all types of content, which no longer depends on an old small industry but on multiple and different sources.

5 . Authors, like all workers, are entitled to live out of their creative ideas, business models and activities linked to their creations. Trying to hold an obsolete industry with legislative changes is neither fair nor realistic. If their business model was based on controlling copies of any creation and this is not possible any more on the Internet, they should look for a new business model.

6 . We believe that cultural industries need modern, effective, credible and affordable alternatives to survive. They also need to adapt to new social practices.

7 . The Internet should be free and not have any interference from groups that seek to perpetuate obsolete business models and stop the free flow of human knowledge.

8 . We ask the Government to guarantee net neutrality in Spain, as it will act as a framework in which a sustainable economy may develop.

9 . We propose a real reform of intellectual property rights in order to ensure a society of knowledge, promote the public domain and limit abuses from copyright organizations.

10 . In a democracy, laws and their amendments should only be adopted after a timely public debate and consultation with all involved parties. Legislative changes affecting fundamental rights can only be made in a Constitutional law.


REFERENCE

Facebook group supporting the manifesto

Manifesto Signing Petition

Dangerous Anti-Sharing Law in Spain | La Quadrature du net

Saturday, 21 November 2009

Install and Configure quickly a DHCP Server

NOTE: These commands have been tested in Debian version unstable.

DHCP stands for Dynamick Host Configuration Protocol. This protocol allows to automatically obtain an IP address and set the network configuration.

We install a DHCP server:
#aptitude install dhcp3-server

Next step is configuring the DHCP server:
We have to set correcty the /etc/dhcp3/dhcpd.conf file.

There is a configuration file example at:
/usr/share/doc/dhcp3-server/examples/dhcpd.conf

e.g: I added these lines to my /etc/dhcp3/dhcpd.conf


subnet 192.168.1.0 netmask 255.255.255.252 {
range 192.168.1.2 192.168.1.3;
option routers 192.168.1.1;
option domain-name-servers 212.73.32.3, 212.73.32.67;
}


subnet and netmask indicate the network addresses of our network:
e.g: subnet 192.168.1.0 netmask 255.255.255.252 match 192.168.1.0, 192.168.1.1, 192.168.1.2 and 192.168.1.3 IP addresses.

range means which addresses can be returned by our dhcp server, here, it can return 192.168.1.2 and 192.168.1.3

routers indicates the gateway

domain-name-servers shows all dns addresses separated by commas.


Once we have correctly set dhcpd.conf file we restart the dhcp daemon:
#/etc/init.d/dhcp3-server restart


If everything has gone fine, we will execute in a client computer:
$sudo dhclient eth0

and the dhcp server will associate an IP adress to eth0 interface.

NOTE: dhcp3-client package provides dhclient command.
#aptitude install dhcp3-client

Sunday, 1 November 2009

Shell Script that shows Network Speed

The following shell script shows current download and upload speeds for the network interface you choose.

Copy the shell script in a file named, i.e: net_speed.sh

Then after setting execution permissions:
$ chmod a+x net_speed.sh

You can run the shell script passing as the first argument the network interface you want to monitor:
$ ./net_speed.sh eth0


You will get a line like that:
ppp0 DOWN:15 KB/s UP:880 B/s

This script works parsing /proc/net/dev file and calculating the difference between current transmitted or received bytes and their values one second ago.

Sunday, 11 October 2009

How to Compile the Linux Kernel in GNU/Debian and Ubuntu

NOTE: Tested in GNU/Debian Sid. Ubuntu versions should also work.


OBTAIN KERNEL SOURCE CODE:

Obviously the first step is obtaining the source code.

It is recommended to place and build linux kernel source code in /usr/src directory, although it is not required.

We create our "Linux_Kernel_Source" directory for this task.
$mkdir Linux_Kernel_Source
$cd Linux_Kernel_Source


Linux kernel source code is freely available in Internet:
http://www.kernel.org
specifically, version 2.6:
http://www.kernel.org/pub/linux/kernel/v2.6

We download and uncompress latest source code (2.6.31 when this article was written):
#aptitude install wget bzip2 # packages needed to get the kernel source code and uncompress it.
$wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.tar.bz2

Uncompress the source:
$tar xvjf linux-2.6.31.tar.bz2

/usr/src/linux is a symlink to linux sources or at least linux kernel headers. It is required.
#ln -s linux-2.6.31 /usr/src/linux

$cd linux-2.6.31


KERNEL CONFIGURATION:

Sunday, 4 October 2009

Installing Mediawiki using SQLite Database in GNU/Debian

NOTE: These article commands have been tested in GNU/Debian Sid. They should also work in Ubuntu flavours.

First we need to install php, apache and SQLite if they are not installed. This command will do the trick:
#apt-get install php5-sqlite

Following mediawiki recommendation we add some extensions to php for SQLite to work:
Edit /etc/php5/apache2/php.ini
Add these two lines in that file:

extension=php_pdo_sqlite.so
extension=php_pdo.so


To solve servername warning when launching apache daemon:
#echo "ServerName localhost" >> /etc/apache2/httpd.conf

We start apache web server:
#apache2ctl start


DOWNLOAD MEDIAWIKI SOURCE CODE


#cd /var/www

We get latest mediawiki source code tarball (current one when writting this article is 1.15.1):
#wget http://download.wikimedia.org/mediawiki/1.15/mediawiki-1.15.1.tar.gz

Uncompress it:
#tar xvfz mediawiki-1.15.1.tar.gz
#cd mediawiki-1.15.1
#ln -s mediawiki-1.15.1 mediawiki

We set writting permissions to config directory so we will be able to configure our wiki:
#chmod a+w config


CONFIGURING THE WIKI

Sunday, 15 March 2009

Creating a FEDORA 10 CHROOT Environment in DEBIAN SID

Fedora is a linux distribution supported by a community: fedoraproject.org and by Red Hat enterprise.
Fedora (Wikipedia)

Current release name is Fedora 10.


Fedora packages are provided in rpm format. We can manage these packages using rpm tool, and use yum to deal with repositories.

Debian sid provides the rpm tool so our first task will be installing it in our Debian system:
#aptitude install rpm

This tool will allow us to install fedora packages in our debian system using a separate database and a different directory than / .


We create the directory to place our Fedora chroot environment:
$mkdir Fedora
$cd Fedora
$mkdir Distro


We are going to download the minimal amount of rpm packages required for our Fedora distro.

Navigating through fedora project web page we can find some mirrors, e.g:
http://glup.uv.es/mirror/fedora/linux/
http://ftp.uni-kl.de/pub/linux/fedora/linux/
Choose one near you.

Within those mirrors we find where packages are:
http://glup.uv.es/mirror/fedora/linux/releases/10/Fedora/i386/os/Packages/
http://ftp.uni-kl.de/pub/linux/fedora/linux/releases/10/Fedora/i386/os/Packages/


We can download every package we need using wget tool.
Although we only show the installing rpm command, you will have to download every rpm package prior to install it.
NOTE: Package version may not coincide, but the same package name and same installing order are mandatory.

If we need some file to satisfy a dependency, but don't know which package contains it, this web page

Saturday, 31 January 2009

Calculating Prime Numbers using python

This blog article shows a python exercise which consists on calculating some prime numbers using trial division algorithm.

You can copy this code in a script file and then execute it!

#!/usr/bin/env python

#Prime numbers
import sys
import math

print "Prime numbers"

#Asks user how many numbers he wants to calculate.
top = int(raw_input("How many prime numbers do you want to calculate?: "))

if (top <1 ) :
print "Error: Invalid number. It must be greater than one"
sys.exit

#Initializing some variables
a = 3    # first number to test if it is prime.
result = [2]  # result list begins with prime number 2.
num = 1   # number of already calculated primes.
print 2,

while num < top : # main loop
cont = 0

# Performs the division test
while 1 :
divisor = result[cont]   # we only test with already calculated prime numbers.

(quotient, remainder) = divmod(a,divisor)  # calculates quotient and remainder at the same time.

if (remainder) :
if divisor <= quotient :
cont += 1 
else:
result.append(a)
print a,  # number a is a prime.
num += 1
break
else:
break   # number a is not a prime

a += 1   # calculate next number to test.
This other script avoids testing numbers that are multiple of 2,3,5 or 7. Also calculates the integer square root to obtain the higher divisor limit to test for each number.
#!/usr/bin/env python

#Prime numbers
import sys
import math

print "Prime numbers"

#Asks user how many numbers he wants to calculate.
top = int(raw_input("How many prime numbers do you want to calculate?: "))

if (top <1 ) :
print "Error: Invalid number. It must be greater than one"
sys.exit

#Initializing some variables
a = 11   # first number to test if it is prime
statea = 0
stateb = 0
result = [7]  # result list begins with prime number 7
num = 4   # number of already calculated primes.
print 2, 3, 5, 7,

while num < top : # main loop
cont = 0

#Calculates the integer square root of a
low = 1
upper = a
while (upper - low) > 1 :
med = (low + upper)/2
temp = med * med
if temp > a :
upper = med
else:
low = med
if temp == a :
break

# Performs the division test
while 1 :
divisor = result[cont]
if (a % divisor) :
if divisor <= low :
cont += 1
else:
result.append(a)
print a,  # number a is a prime
num += 1
break
else:
break   # number a is not a prime

# Calculates next number to test if it is a prime.
if (stateb == 4) or (stateb == 6) :
a += 6
stateb += 1
elif statea :
a += 4
statea = 0
if stateb == 7 :
stateb = 0
else :
stateb += 1
else :
a += 2
statea = 1
stateb +=1