Hi,

Today I’m going to show you a very small script that allows you to convert any video (as long as it is supported by mplayer) to a GIF.

Required tools:

* mplayer

* convert

 

mplayer is popular media player available for multiple operating systems that support a wide range of video formats. The convert tool is an utility that lets you convert between multiple image formats among other definitions.  Since the mplayer takes screenshots using jpeg format, we need to use the convert tool to do the convertion to aGIF format.

 

Copy the following code, save it to a file and change its permissions (chmod a+x) and you are ready to roll 🙂

 

 

#!/bin/sh
TMPDIR=/tmp/animated
shopt -s nocaseglob
if [ ! -d "$TMPDIR" ]
then
        mkdir $TMPDIR
fi
 
\rm $TMPDIR/* &> /dev/null
 
if [ $# -lt 3 ]
then
        echo -e "Usage: $0    []\nExample:\n$0 00:15:11 10 myvideo.avi 320:240"
        exit 1
fi
 
if [ -n "$4" ]
then
        SCALE="scale=$4"
fi
 
echo "Generating screenshots. Please be patitent..."
mplayer -ao null -ss $1 -endpos $2 $3 -vo jpeg:outdir=$TMPDIR/ -vf $SCALE &> /dev/null
if [ -f $TMPDIR/00000001.jpg ]
then
        echo "Finished generating frames. Assembling the animated GIF..."
        convert -delay 5 $TMPDIR/*.jpg $TMPDIR/output.gif
        echo "Done! Please check the $TMPDIR/output.gif"
        exit 0
else
        echo -e "Oops\! Something went wrong and the frames were not generated. Check your parameters\!"
        exit 1
fi

Just try it and let me know 😉

I’ve been trying to learn how to use Perl to do some simple stuff whenever I just cannot use PHP. PERL is a language that I have access on every machine under my control, but unfortunately I cannot say the same thing about PHP and that is why I have decided to start learning using this ultra flexible language.

Now, the first thing I have developed (aside from the popular Hello World – LOL) was a simple script to check for website updates. This was particularly useful to check for updates on a website related to a contest.

use strict;
use warnings;
use LWP::Simple;
use Digest::MD5 qw(md5 md5_hex md5_base64);
use Encode qw(encode_utf8);
 
my $link                = 'http://www.foobar.com';
my $email_from          = '[email protected]';
my $email               = '[email protected]';
my $email_subject       = 'Website Changed!';
my $email_body          = 'Hello! I just want to let you know that the website ' 
                          . $link . ' have just changed!';
my $tmp_file            = '/tmp/stored_hash';
 
my $web_source = get( $link );
my $current_hash =  md5_hex(encode_utf8($web_source));
 
if(-e $tmp_file)
{
        open FH, "<$tmp_file" or die "could not open: $!\n";
        my $mod_hash = <FH>;
        if( $current_hash ne $mod_hash )
        {
                open(MAIL, "|/usr/sbin/sendmail -t");
                print MAIL "To: $email\n";
                print MAIL "From: $email_from\n";
                print MAIL "Subject: $email_subject\n\n";
                print MAIL "$email_body\n";
                close(MAIL);
 
        }
        close FH;
}
        open FH, ">$tmp_file" or die "could not create: $!\n";
        print FH $current_hash;
        close FH;

Just replace the email and link stuff to suite your needs and you are all set! Enjoy!

If you are thinking about using domainsarefree.com to register a website, please think twice! I tried to register a domain which failed because I couldn’t find my credit card. I just thought “No problem, I will search for my wallet and register the domain later…”

Two days later when I tried to register that domain again it was already registered! And I thought to myself: “how the heck did that happen? That domain is complex with so many letters and not even related to a recent hot topic, this can’t be a coincidence!”

I don’t like to be paranoid, but after reading a few links like this one I now understand what happened.

So be aware: If you want to register a domain, either do it fast or don’t even use domainsarefree.com otherwise you will end up with a robbed domain.

A few months ago I got tired of using eclipse as my IDE because it is extremely slowwww, so I’ve decided to give an opportunity to IntelliJ Idea.

It seems faster than eclipse. No doubts about that. But then I came across these king of lame errors:

I’m getting tired of using such lame IDEs with basic bugs. Any alternative to develop Java/Android applications?

I wish someone could develop a Visual Studio clone for java 🙁

This is probably a common problem among all the people trying to get audio over HDMI under Linux using an EN210 graphics card (or similar).

Even though the HDMI may appear in your available cards listed in proc (/proc/asound/cards) you will probably see that you cannot find it using the aplay utility. Just check it running the command “aplay -l”. The HDMI device isn’t listed here isn’t it?

The reason for this issue is related to the ALSA driver version 1.0.21 (or older) which is quite buggy for these graphics cards.

You can check which version you are using by executing the following command:

cat /proc/asound/version

If you get a version older than 1.0.21 then you need to upgrade it. You can check your favourite distribution’s repository for an update or you can try to compile it from source code.

If you can’t find an update, check this page: http://ubuntuforums.org/showthread.php?t=1681577

It might help you 😉

If you are an Android Developer you probably know how hard it may be to develop webservices based applications. The lack of official support for these implementations is compensated by some modules like ksoap2 that handle de SOAP stuff and communication.

For simple cases where you just have to send/receive simple data types it is easy to use, but things can get a bit complicated when you need to handle complete data types with dozens of different functions.

That’s why someone created the automatic stub generator. A stub is a set of classes generated automatically from the WSDL so you don’t have to create all functions, definitions and data types available in the WSDL by hand.

You can download the ksoap2 jar from here.

You can download the stub generator from here or you can try my online version of the stub generator filling the input box with the WSDL URL and press download.

Talvez por os tempos serem de crise, tenho andado a pensar nos últimos tempos como rentabilizar ao máximo os fundos de que disponho actualmente. A ideia é pegar numa determinada quantia e fazer uma aplicação durante alguns anos reinvestindo todos os anos o valor inicial incluindo os juros ganhos.

Criei um simples simples script que me efectua este calculo. Já existem calculadoras destas às paletes, apenas criei uma nova para simular variações nas taxas de juros entre os vários anos.

A ideia é simplesmente utilizar como limites de variação de juros fornecidos pela instituição financeira e assim tentar ter uma ideia mais real (que na realidade até pode ser bem menos real) do resultado final.

Utilizem o seguinte formulário para efectuarem o calculo:

 

[INDISPONIVEL AINDA]

Já chegaram as duas competições que te podem levar a passar umas férias no outro lado do mundo, ou a passear pela Europa no teu novo Mercedes.

São eles a XTB Trading Cup e o Jogo da Bolsa do Jornal de negócios.

O objectivo é simples: Investir uma determinada quantia de dinheiro virtual em instrumentos financeiros e rentabilizar ao máximo durante um período de tempo. No final, ganha quem tiver ganho mais.

Os prémios são no mínimo muito aliciantes. Na XTB Trading Cup o primeiro prémio é nada mais nada menos que um Mercedes SLK. Haverá ainda prémios para o segundo classificado e para os vencedores semanais.

No caso do Jogo da Bolsa os prémios são mais simpáticos, mas não deixam de ser bastante aliciantes. Para o primeiro classificado será entregue um cheque de quatro mil euros, com prémios garantidos até ao quinto lugar. Tal como no concurso patrocinado pela XTB, aqui também haverá prémios para os vencedores semanais.

Mais informações no site oficial do Jogo da Bolsa e no site da XTB Trading Cup.

Hoje lembrei-me de um jogo que costumava jogar nos jantares académicos. Chama-se general peck e consistia em fazer algumas afirmações e gestos sob pena de ter de beber uma bebida algo de penalti.

Cada pessoa vai ter de repetir todos estes passos. Se falhar algum destes passos, então tem de beber e recomeçar de novo. Aqui fica um resumo de como o jogar:

O Bar está cheio e todas as pessoas envolvem o GENERAL PECK.
Todos demonstram curiosos com a cena.
Vemos uma mesa com um copo grande vazio e uma garrafa de vinho cheia.
O General Peck está de pé e olha para os presentes com confiança.

GENERAL PECK
(enchendo o copo de vinho)
O General Peck vai fazer uma demonstração.

O General Peck sabe que não pode falhar, com a penalização de beber tudo de golada e começar de novo.
Silêncio na sala.
Pega no copo com o polegar e um dedo.

GENERAL PECK
O General Peck vai beber pela primeira vez.

Bebe um golo de vinho e bate o copo uma vez na mesa.
Pega no copo com o polegar e dois dedos.

GENERAL PECK
O General Peck Peck vai beber pela segunda vez.

Bebe dois golos de vinho e bate o copo na mesa duas vezes.
Pega no copo com o polegar e três dedos.

GENERAL PECK
(Lentamente)
O General Peck Peck Peck vai beber pela terceira e ultima vez, . . .

Olha em redor.

GENERAL PECK (CONT’N)
. . . e no final vai colocar o polegar direito sobre a mesa.

INSERE – GRANDE PLANO GENERAL PECK A BEBER

Bebe três golos de vinho até esvaziar e bate o copo na mesa três vezes.

REGRESSA À CENA

Olha em redor com ar vencedor. Levanta a mão direita sem copo e aponta o polegar para cima.
Mostra o polegar a toda a gente e num movimento brusco coloca o polegar direito sobre a beira da mesa.
Os presentes enchem a sala de palmas.

Pessoalmente preferia esta versão à do jogos dos limões por ser mais elaborada. Testem um dia com amigos :-)

After upgrading my HTPC to Ubuntu 10.04, nvidia drivers stopped working without any reason. After googling a bit, all the answers pointed to a problem related with Ubuntu upgrade system not updating restricted drivers. I have tried manually to update and use all the available versions, but without any success…until I found the cause and solution.

It happens that Ubuntu does not remove old drivers correctly, leaving you with multiple versions which were confusing the operating system. The solution was to purge the system from all nvidia drivers and reinstall just one of them.

You can run the following commands to clean the system:

sudo dpkg --get-selections | grep nvidia | grep -v deinstall | awk '{print $1}' | xargs sudo apt-get remove -y
sudo apt-get install nvidia-current
sudo nvidia-xconfig

sudo reboot

The system will then reboot and if everything is OK, Ubuntu will be as good as new.