2011/03/30

BBC World Service English

What a perfect opportunity to practice your English than listening to the BBC World Service English! Of course it would be better to talk directly with a native speaker :-)

You can bookmark!

In your winamp (Press CTRL+L): http://mp32.bbc.streamuk.com:80/
Or in your internet browser: http://www.bbc.co.uk/worldservice/audioconsole/?stream=live

Several countries have a English version of their streams, would you like to watch the news about the natural disaster in Japan from Japan?

http://www3.nhk.or.jp/nhkworld/

You may already know that Internet is a wonderful source of material for the English student but you have to use it! Don't you?

By the way, I am a native Spanish speaker... sorry for my English (I am working on it).

Have a nice day!

2011/03/29

Mavenizing ECJ locally using maven and ANT

Sometimes you may need a useful library in your project which is not mavenized anywhere else, and you don't want to create a customized shell script to install the library in the local maven's repository for every operating system.
Of course you just can drop the jar into the project and distribute the whole project using some control version system.

This time I just preferred to have fun with maven :-)


Let maven do the job and skip any complex installation procedure needed (dependencies, tools, etc).

In this POM I used maven-antrun-plugin (ANT) to install ECJ into the local maven's repository. JDK and Maven are the only install requirements.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.university.project</groupId>
    <artifactId>X</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>ProjectName</name>
 

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <id>wget</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target name="prepare">
                                <condition property="mavenized">
                                    <resourceexists>
                                        <file dir="${user.home}/.m2/repository/ecj"/>
                                    </resourceexists>
                                </condition>
                            </target>
                            <target name="install" unless="mavenized">
                                <property name="tmp.dir" value="${user.home}/tmp"/>
                                <property name="target.tgz" value="${tmp.dir}/ecj.tar.gz"/>
                                <property name="target.jar" value="${tmp.dir}/ecj.jar"/>
                                <mkdir dir="${user.home}/tmp"/>
                                <get src="http://www.cs.gmu.edu/~eclab/projects/ecj/ecj.tar.gz" dest="${target.tgz}" verbose="false" skipexisting="true"/>
                                <untar src="${target.tgz}" dest="${tmp.dir}" compression="gzip"/>
                                <jar destfile="${target.jar}" basedir="${tmp.dir}/ecj"/>
                                <macrodef name="mvn">
                                    <attribute name="failonerror" default="true"/>
                                    <attribute name="args" default=""/>
                                    <sequential>
                                        <exec failonerror="@{failonerror}" executable="mvn.bat" osfamily="Windows">
                                            <arg line="@{args}"/>
                                        </exec>
                                        <exec failonerror="@{failonerror}" executable="mvn" osfamily="unix">
                                            <arg line="@{args} "/>
                                        </exec>
                                    </sequential>
                                </macrodef>
                                <mvn args="install:install-file -Dfile=${target.jar} -DgroupId=ecj -DartifactId=ecj -Dversion=20 -Dpackaging=jar -DgeneratePom=true" />
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

2011/03/24

Using an unofficial maven Weka repository

Today I needed to use Weka for a scholar project plus Maven but because it doesn't exist in the official maven repositories I just added it using a third party repository.

pom.xml: 

...
    <repositories>

        <repository>
            <id>weka</id>
            <name>Weka unofficial repository</name>
            <layout>default</layout>
            <url>http://maven.ch.cam.ac.uk/m2repo/</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>

    </repositories>

...

    <dependencies>
...
        <dependency>
            <groupId>weka</groupId>
            <artifactId>weka</artifactId>
            <version>3.5.7</version>
            <type>jar</type>
        </dependency>
...
    <dependencies>
...


What a wonderful tool maven is!

2011/03/05

Installing Debian GNU/Linux 6 from network using a USB flash drive and HP firmware for HP DL360 G7

UPDATE: A better way!

To install Debian GNU/Linux 6 in a server HP Proliant DL360 G7 using the network installer and a USB flash drive I wrote a shell script. Maybe you find it useful too.

You must know there is some proprietary firmware needed for the server to install (network at least).

After doing a little research, the know-how is in these sites:


http://wiki.debian.org/HP/ProLiant
http://wiki.debian.org/DebianInstaller/NetbootFirmware

In my case, the target architecture was amd64 (x86-64), but you would need some little modifications for any other architecture.

Before to run the shell script you need:

1- the network installer image from http://cdimage.debian.org/debian-cd/6.0.0/amd64/iso-cd/debian-6.0.0-amd64-netinst.iso

2- A USB flash drive (250 MB minimum).

3- A linux machine where you can run the shell script, I used a Debian GNU/Linux  Lenny.

The shell script is interactive, will download some files and write the USB flash drive. Be careful, data will be destroyed (after confirmation) because of formatting!

Remember to grant the needed permissions: chmod u+x script.sh


Use it on your own risk .



#!/bin/bash
function show
{
cat <<End-of-message
--------------------------------------------------
$0 TargetDevice TargetISO

Prepare a bootable pendrive with some HP Firmware!

Use it on your own risk.
-------------------------------------------------

End-of-message
}

##################################################################

show

# Validations

TARGET_DEVICE=$1
TARGET_ISO=$2
myPWD=$(pwd)

if [ $UID -ne 0 ]
then
    echo "You need to be root! (sudo?)"
    exit 3
fi

if [ -z "$TARGET_DEVICE" ]
then
    echo "You must specify the target device!"
    exit 1
fi

if [ -z "$TARGET_ISO" ]
then
        echo "You must specify the target iso!"
        exit 2
fi

echo "The current status of your device, beware any data will be destroyed!"

fdisk -l $TARGET_DEVICE

echo

ls -l $TARGET_ISO

echo

echo "Data will be destroyed!, press [Y] to continue"
read input

if [ "$input" != "Y" ]
then
    echo "Your answered [$input]"
    exit 0
fi

echo
echo "Creating bootable pendrive..."

if [ -n "$(mount | grep $TARGET_DEVICE)" ]
then
    echo "Unmounting $TARGET_DEVICE..."
    umount $TARGET_DEVICE

    if [ $? -ne 0 ]
    then
        echo "Error umounting the device!"
        exit 5
    fi
fi

if [ ! -e boot.img.gz ]
then
    echo
    echo "Downloading... boot.img.gz..."
    wget http://ftp.nl.debian.org/debian/dists/squeeze/main/installer-amd64/current/images/hd-media/boot.img.gz
fi

echo
echo "Formatting..."

zcat boot.img.gz > $TARGET_DEVICE
rm -fr /mnt/pendrive.tmp
mkdir -p /mnt/pendrive.tmp
mount $TARGET_DEVICE /mnt/pendrive.tmp

echo
echo "Copying iso..."

cp $TARGET_ISO /mnt/pendrive.tmp/

ls -l /mnt/pendrive.tmp/*.iso

echo
echo "Updating the initrd.gz with HP firmware..."

# Make a temp dir and transform the firmware tarball into an firmware initramfs addon
FWTMP=$HOME/tmp/d-i_firmware
#rm -rf $FWTMP
mkdir  -p $FWTMP
cd $FWTMP

target=firmware.tar.gz

if [ ! -e $target ]
then
    wget http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/lenny/current/firmware.tar.gz
fi

tar -zxf firmware.tar.gz

if [ -z "$(which pax)" ]
then
    echo
    echo "Installing pax..."
    apt-get install pax
fi

for name in *.deb ; do
    ar -p $name data.tar.gz | tar -zxf -
done

pax -x sv4cpio -s '%lib%/lib%' -w lib | gzip -c >firmware.cpio.gz

# cd to the directory where you have your initrd
cd /mnt/pendrive.tmp

echo
echo "Backing up initrg.gz..."
[ -f initrd.gz.orig ] || cp -p initrd.gz initrd.gz.orig
cat $FWTMP/firmware.cpio.gz >> initrd.gz

ls -l initrd.gz*

cd $myPWD

echo
echo "Unmounting device..."

umount /mnt/pendrive.tmp

echo
echo "Done."



Ooops, I found this a little late :-|