quinta-feira, 4 de junho de 2009

7zcat

Sometimes you just want to "grep" someting in a compressed text file, but it is too big to be decompressed and then processed. This is why I love zcat and bzcat: I could decompress and pipe it on the flow to grep/awk/whatever, but unfortunately I do not see a 7zip cat like.

7zip is so awesome because I got better and faster compressions using it, but it's command line options are too many and hard to remember, so I put this alias in my ~/.bashrc:
alias 7zcat='7za e $@ -so 2> /dev/null'
OBS.: the redirection of stderr to /dev/null is because 7z doesn't have a --quiet option.

P.S.: I wonder if there is some way to compress with 7zip exactly like I do with gzip:
echo "foo" | gzip -c > foo.gz
The 7zip manpage gives this example (with gzip compression):
echo "foo" | 7za a dummy -tgzip -si -so > foo.gz
but with 7zip compression, the closest i got was
echo "foo" | 7za a -t7z -si foo.7z
so, how to redirect the output to /dev/stdout when reading from stdin? I mean, it is this possible via some bash-fu, named pipes, etc?


domingo, 15 de fevereiro de 2009

Do We Need a New Internet?

After reading the NYTimes article "Do We Need a New Internet?", I can't stop laughing about the ingenuous opinions expressed there.

The real issue isn't the Internet security, but the security flaws at the most used Operational System. The communication layer is not responsible for keeping the user data at his computer secure, but the OS is. What we really need is more secure and less bugged OS, but wait, we already have this! So, if the computer users want security, they should choose an alternative OS and not giving up their freedom because of obscure excuses...

An example: the Conficker worm infected 12 million computers, but not GNU/Linux or Mac computers. According to Wikipedia,
Conficker is a computer worm that surfaced in October 2008 and targets the Microsoft Windows operating system. The worm exploits a known vulnerability in the Windows Server service used by Windows 2000, Windows XP, Windows Vista, Windows Server 2003, Windows Server 2008, and the Windows 7 Beta.

So, according to "engineers and security experts", if your house is frequently invaded by mosquitoes, you should move to another country, when all you have to do is close your windows.

quinta-feira, 12 de fevereiro de 2009

Install Ekiga 3 on Ubuntu 8.10 (Intrepid Ibex)

I always was worried about Skype closed-source code, but after reading this article about "NSA offering 'billions' for Skype eavesdrop solution", I became almost paranoid... Happilly there is nice and free open-source apps availiable, like Ekiga.

Ekiga is an open source VoIP and video conferencing application, using H.323 and SIP protocols, suporting many audio and video codecs. You can read some good reviews here and here.

Ekiga 3.1 it has major improvements as support for the G.722 audio codec (HD voice), better notifications and more efficient memory handling. Even with all this advantages, Ubuntu 8.10 ships with the old and ugly Ekiga 2.0. Ok, I known that Ekiga 3.1 is a beta version, but what about Canonical choose of Pulse-Audio 0.9.10 that f***ed my system audio???

Well, there is no shinny ekiga 3.1 deb packages on the ubuntu repositories to update from, so we have to install it from sources. To make this process pain-free I made a script to automate the download-compile-install based on this, this and this pages. So, here it goes:

cd /tmp
#install ptlib
wget -c ftp://ftp.gnome.org/pub/gnome/sources/ptlib/2.5/ptlib-2.5.2.tar.bz2 && tar xjf ptlib-2.5.2.tar.bz2 && cd ptlib-2.5.2
./configure --enable-sunaudio=no --enable-oss=yes --prefix=/usr --disable-sdl --disable-avc --disable-dc --enable-v4l
make && make install
checkinstall -D -y --pkgname="libpt-2.5.2"
#install opal
apt-get install libspeex-dev libx264-dev libtheora-dev libavcodec-dev libavformat-dev x264
wget -c ftp://ftp.gnome.org/pub/gnome/sources/opal/3.5/opal-3.5.2.tar.bz2 && tar xjf opal-3.5.2.tar.bz2 && cd opal-3.5.2
./configure --prefix=/usr --enable-localspeex --enable-sip --enable-h323 --enable-video
make && make install
checkinstall -D -y --pkgname="libopal-3.5.2"
#install ekiga-snapshot
apt-get install autoconf automake docbook-utils evolution-data-server-dev gettext gnome-common gnome-doc-utils intltool libavahi-client-dev libavahi-common-dev libavahi-glib-dev libdbus-glib-1-dev libebook1.2-dev libgconf2-dev libgnome2-dev libgnomeui-dev libgtkmm-2.4-dev libldap2-dev libsasl2-dev libsigc++-2.0-dev libxml++2.6-dev libxml2-utils libxml-parser-perl libxv-dev libxvmc-dev scrollkeeper xsltproc
svn co http://svn.gnome.org/svn/ekiga/trunk ekiga
cd ekiga
sed -i -e 's/GNOME="disabled"/GNOME="enabled"/g' -e 's/NOTIFY="disabled"/NOTIFY="enabled"/g' -e 's/XCAP="disabled"/XCAP="enabled"/g' -e 's/GSTREAMER="disabled"/GSTREAMER="enabled"/g'
./autogen.sh --prefix=/usr --sysconfdir=/etc/
make && make install
#checkinstall -D -y --pkgname="ekiga-snapshot"


Happy VoIP-ing!


terça-feira, 10 de fevereiro de 2009

lit2pdf: Convert Microsoft Reader .lit ebooks to PDF

The .lit files are Microsoft Reader proprietary ebook files, but you can convert them to HTML with clit (ConvertLit).

To install clit from source, follow this tutorial (or just download this and this .deb compiled versions and double-click them to install).

After installing it, you can use this script
that convert the .lit to .html and open it with firefox browser. At the
browser, you can "print" them as PDF or just save the HTML, if you want.

I've made this script to install everything and also create an lit2pdf script to make things easier:
#install clit
cd
/tmp
wget -c http://ace-host.stuart.id.au/russell/files/debian/sarge/libtommath/libtommath_0.37-1_i386.deb
wget -c http://ace-host.stuart.id.au/russell/files/debian/sarge/clit/clit_1.8-1_i386.deb
sudo dpkg -i libtommath_0.37-1_i386.deb clit_1.8-1_i386.deb
wget -O cleanlit.sh -c http://ubuntuforums.org/attachment.php?attachmentid=30912&d=1177590357
#install litreader script
chmod
+x /tmp/cleanlit.sh
sudo mv /tmp/cleanlit.sh /usr/local/bin/litreader
#install lit2pdf script
sudo apt-get install htmldoc
echo '
echo "[Stage 1] converting $1 to HTML..."
HTML_DIR=`litreader "$1" | grep Exploded | sed -e "s/Exploded .* into //g" -e "s/\.$//g" -e "s/\"//g"`
echo "HTMLs saved to $HTML_DIR"
BOOK_TITLE=`basename "$1" .lit`
sed -i -e "s/<title>New Page 1<\/title>/<title>$BOOK_TITLE<\/title>/g" ${HTML_DIR}*.htm
echo "[Stage 2] converting the HTML to PDF..."
#htmldoc -t html -f "$1.html" --book --no-toc --no-title ${HTML_DIR}*.htm
htmldoc -t pdf13 -f "$1.pdf" --webpage --no-toc --no-title ${HTML_DIR}*.htm
echo "PDF saved to $1.pdf"
evince "$1.pdf"

'
> /usr/local/bin/lit2pdf
chmod +x /usr/local/bin/lit2pdf
Then you can associate your .lit files with litreader and create an nautilus-actions entry to convert an .lit file to .pdf.

:-)

P.S.: thanks to kleeman, elgreengeeto, aircooledbusnut and all the others from this ubuntuforums thread.

doc2odt: Converta seus documentos para um formato aberto e padronizado

Que tal converter seus arquivos do Microsoft Word pro OpenOffice? Utilizar um formato internacionalmente padronizado tem uma série de vantagens, sendo a principal delas você ter a possibilidade de abrir seu documento no programa que preferir:

Os arquivos .doc do famigerado Word além de serem grandes demais, a cada atualização do Microsoft Office ficam incompatíveis com versões anteriores do mesmo. Já os arquivos .odt são padronizados (ou seja, compatíveis com diversos softwares de edição de texto) e também bem menores (ex.: no caso do OpenOffice, já vem "automaticamente compactados"). Além disso, os documentos da família ODF (OpenDocumento format) consistem num formato aberto e público, aprovado como norma ISO/IEC e também pela Associação Brasileira de Normas Técnicas (ABNT).

É por essas e outras é que eu sempre utilizo o ODT como formato para documentos de texto. Na pior das hipóteses, quando necessito enviá-lo para algum usuário do Windows+MSOffice, converto-o para PDF e aproveito para sugerir que ele experimente o OpenOffice.

Porém, o que fazer quando obtém-se uma grande quantidade de documentos do Word? Converter manualmente um a um no OpenOffice via "Salvar como"? Felizmente, praticamente toda tarefa dita repetitiva pode ser automatizada pelo conputador, geralmente de maneira bem simples. Aqui no Ubuntu encontrei um programinha muito bom para este tipo de tarefa de "conversão em lote", chamado unoconv. Para instalá-lo basta executar num terminal:
sudo apt-get install unoconv
e execuar no diretório onde estão os arquivos do Word o seguinte comando:
find ./ -name "*.doc" -exec doc2odt {} \;
e pronto! Após alguns segundos todos seus documentos estarão convertidos para .odt, e com o bônus de seu tamanho cair praticamente pela metade :-)

Se você ficou satisfeito com o resultado, agora basta apagar os arquivos originais assim:
find ./ -name "*.doc" -exec rm -f {} \;
P.S.: o unoconv também possibilita converter para diversos outros formatos, como PDF e TXT, bastando informar o tipo de formato desejado com a opção -f.

quinta-feira, 29 de janeiro de 2009

dmesg fun: endless printing like "hacker movies"

Did you notice that every Hollywood movie that show some guy hacking in a deep-voodoo-programming-frenesi has some cool stuff being printed in a lot of black-green terminals? And that nonsense lines are printed so quickly that only the "hacker" can read??

When I'm programming or analyzing logs, the line-breaks flow slow and boooring... The closest thing is when I'm compiling something with 'make'. So I was thinking: why I can't have my own hacker-like cool printing to impress my girlfriend by pretend doing important stuff?

Yes I can!

Then i wrote this (useless) command to print a looping dmesg in a black-green terminal:

xterm -bg black -fg green -e "while [ 1 ]; do bash -c 'dmesg | while read line; do echo \$line && sleep 0.05; done' && sleep 0.2; done;"

Now you just have to associate this with some alias like dmesgl or hacking-the-cia or whatever you like!

quarta-feira, 17 de dezembro de 2008

gMplayer: Como Exibir Legendas Abaixo do Filme

Eu sempre gostei do Mplayer, mas uma coisa que me incomodava era o fato das legendas serem exibidas por cima do vídeo. Sempre procurei por uma solução pra isso na Web mas nunca encontrava nada, até que um belo dia me deparei com este script que propunha uma maneira "alternativa" de conseguir o efeito desejado. Eu simplifiquei o tal script e cheguei na seguinte solução:

#!/bin/bash
#
# Exibe a legenda abaixo do vídeo (na "faixa preta")
#
# Version 0.1
# (c) 2008 Everthon Valadão under the GPL
# http://www.gnu.org/copyleft/gpl.html
#
gmplayer -vf expand=0:-130:0:58 "$@"


Basta salvar este script como /usr/local/bin/gmplayersub e associar o "abrir com" à ele. Voilà!