Monthly Archives: February 2011

Project Euler

So I was looking around for some programming information and found Project Euler. They have a number of problems to program. You can choose any programming language, it’s just to enhance your programming abilities.

So here is the answer to problem number one.

#!/usr/bin/perl

use warnings;
use strict;

my $sum;
my $count;

for ($count = 0; $count < 1000; $count ++) {
        if (($count % 3 == 0) || ($count % 5 == 0)) {
                $sum = $count + $sum;
                print "\$sum is $sum\n"; }
        }

It’s a really simple exercise. You just need to sum of all the multiples of 3 or 5 below 1000.

Our goalkeeper scores goals too

So we at Deportivo made history being the first Galician team to win the Liga, but now we have the first goalkeeper to score a goal in first division championship history.

Yes, after another horrendous, pitiful match away from Riazor in the 93 minute Aranzubia scores the goal that ties the match and helps keep Deportivo away from relegation. This was a crucial match. Almeria is also fighting against relegation and beating Deportivo would have shortened the points difference with us. Thanks to Aranzubia’s goal Almeria is still in the 19th position with twenty-one points and Deporivo keeps the distance having twenty-six points. Relegation will be a tough fight this year.

So here is the goal. Enjoy.

Forza Depor, oe!!!

Savings script

So I was thinking about writing a script to calculate the savings over a certain matter of time and came up with the following.

#!/usr/bin/perl

use warnings;
use strict;

print "What is the yield?\n";
my $yield = <>;
print "How many years?\n";
my $years = <>;
print "How much money saved anually?\n";
my $savings = <>;
my $i;
my $new_savings = 0;

for($i = 1; $i <= $years; $i++) {
	$new_savings = $savings + $new_savings;
	$new_savings = $new_savings + $new_savings*($yield/100);
	printf "Savings for year $i are \$%.2f.\n", $new_savings;
}

Below is an usage example.

[19:43:04] xavi@ubuntu:/tmp $ ./yield.pl
What is the yield?
5.0
How many years?
5
How much money saved anually?
10000
Savings for year 1 are $10500.00.
Savings for year 2 are $21525.00.
Savings for year 3 are $33101.25.
Savings for year 4 are $45256.31.
Savings for year 5 are $58019.13.
[19:43:18] xavi@ubuntu:/tmp $

This just gives an idea of the money that can be saved over a short period of time with a five percent yield. It’s a really simple script.

Squeeze is now stable

So squeeze is now stable. Together with the new Debian stable release the guys also updated the website.

I have created a small bash script to perform the upgrade. Here it is.

#!/bin/bash
echo "Moving to /etc/apt"
cd /etc/apt
echo "Backing up sources.list"
cp sources.list sources.list.`date +%F`
echo "Changing the sources for squeeze"
sed 's/lenny/squeeze/g' sources.list > squeeze.sources.list
echo "Copying squeeze to sources.list"
cp squeeze.sources.list sources.list
echo "Performing the upgrade."
apt-get update
apt-get dist-upgrade

Run the script as root or use sudo when executing.

Resulting file should be something like the following.

## main & security repositories
deb http://ftp.us.debian.org/debian/ squeeze main
deb-src http://ftp.us.debian.org/debian/ squeeze main
deb http://security.debian.org/ squeeze/updates main
deb-src http://security.debian.org/ squeeze/updates main

References:

  1. Go2Linux
  2. Linode