Using an TV as secondary screen via HDMI – 1

January 25th, 2010

If you have a fancy HD television and a box with a HDMI port, it’s (kinda) easy to setup your TV as a secondary monitor at full resolution, with audio support. Needless to say, it’s great for watch all those HD movies in a big TV instead of staring at your monitor or a small netbook screen :-)

First, the video. Run xrandr and see which devices you have available. My Acer AS1410-8414 running Arch Linux gives this output:

Screen 0: minimum 320 x 200, current 3286 x 1080, maximum 8192 x 8192
VGA1 disconnected (normal left inverted right x axis y axis)
LVDS1 connected 1366x768+0+0 (normal left inverted right x axis y axis) 256mm x 144mm
1366x768 60.0*+
1024x768 85.0 75.0 70.1 60.0
832x624 74.6
800x600 85.1 72.2 75.0 60.3 56.2
640x480 85.0 72.8 75.0 59.9
720x400 85.0
640x400 85.1
640x350 85.1
HDMI1 connected 1920x1080+1366+0 (normal left inverted right x axis y axis) 698mm x 392mm
1920x1080 50.0*+ 60.0
1280x720 60.0 50.0
720x576 50.0
DP1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP3 disconnected (normal left inverted right x axis y axis)
TV1 disconnected (normal left inverted right x axis y axis)

The GPU is a Intel GMA 4500MHD, by the way. LVDS1 is the default LCD screen and HDMI1 the port I’m using. So, to maintain your current screen and create a new one in the TV, run:

xrandr --output HDMI1 --auto --output LVDS1 --auto --left-of HDMI1

This will output a screen on the TV with automatic resoution (1920×1080, in my case), and also keep the current one in the laptop screen at the left side of the TV. Different GPUs have different ways of doing the same thing – in a laptop with a Quadro NVS 140M I was able to use nvidia-settings to configure a second monitor, even having the option of a unified desktop using TwinView (the same effect attained here) or two separate X screens. I suspect ATI-based GPUs have a fancy GUI program as well.

In a next post I’ll explain how to easily redirect the audio to the HDMI port using PulseAudio, if your system insists on outputting sound through your computer speakers. In this case, you could just use a cable with a 3.5mm plug in each end, but why waste plastic and metal when your powerful HDMI cable can transport sound too?

P.S.: I tried to watch a sample from the Apple QuickTime HD Gallery , but my netbook’s Core2 Solo 1.4GHz just doesn’t have what it takes to watch 1080p in all its glory. Meh :P

Algumas coisas sobre Recuperação de Informação

July 27th, 2009

Antes de mais nada, um disclaimer: As informações postadas por aqui são provenientes da minha experiência pessoal com a área e de algumas pesquisas sobre o tema, portanto não garanto que sejam 100% corretas e/ou precisas. Caso você encontre algum erro ou algo do tipo, me avise nos comentários.

Não é novidade pra ninguém que existe mais informação disponível na Internet do que qualquer pessoa pode imaginar, e que é possível encontrar literalmente qualquer coisa que se queira. Devido a este fato, nos dias de hoje os serviços de busca ocupam um lugar central na experiência do usuário da grande rede, sendo integrados aos navegadores e passando a fazer bem mais do que apenas buscar informações textuais – há busca de imagens, localidades, vídeos e o que mais se puder extrair algum tipo de dado.

Apesar do uso da tecnologia ser recente, a tecnologia em si não é – remonta aos idos do século e do (pasmem) milênio passado, lá pelos idos de 1975, quando teria sido publicado por um cidadão chamado Gerard Salton um artigo entitulado “A Vector Space Model for Information Retrieval”,  que lançou as fundações para a Recuperação de Informação. No entanto, apesar de existirem diversas citações a este artigo, não há evidência que tenha sido de fato publicado e sim que tenha sido uma fusão entre dois artigos publicados por Salton neste mesmo ano e que falavam sobre o tema. Se você quiser saber mais detalhes sobre esta história, basta dar uma lida neste documento aqui.

Imprecisões históricas a parte, este artigo seminal demonstrava um modelo matemático chamado modelo espaço vetorial, ou simplesmente modelo vetorial. Este modelo representa documentos (conteúdo textual como por exemplo artigos de jornal, páginas Web, artigos científicos, etc) como vetores em um espaço n-dimensional, onde n representa a quantidade de palavras únicas (termos) que ocorrem no interior de todos os documentos, e o problema da busca torna-se então “apenas” achar os vetores mais próximos ao vetor correspondente a consulta submetida. Simples, não?

Dito assim, parece tudo muito complicado, portanto vamos a um exemplo gráfico:

Exemplo de espaço vetorial

Exemplo de espaço vetorial

Neste exemplo há apenas dois termos pa e pb, resultando em duas dimensões no espaço, e um documento, dj, onde cada termo aparece duas vezes. O vetor q representa uma consulta, que possui uma ocorrência da palavra pb e duas ocorrências de pa. Pode-se notar que há um ângulo θ entre estes vetores, que pode ser utilizado para indicar a distância entre eles. O que é utilizado, no entanto, é o cosseno deste ângulo, pois a medida que o ângulo tende a diminuir o cosseno tende a aumentar, servindo como uma medida prática de proximidade. Desta forma, quanto maior o cosseno, maior é a similaridade entre o documento e a consulta. No final das contas, basta ordenar os documentos por similaridade e voilà, uma consulta acabou de ser processada.

Uma coisa interessante nisso tudo é a noção de similaridade. Uma consulta recupera não só os documentos que contém os termos pesquisados mas também atribui a cada documento um valor que indica o quão similar ele é a consulta realizada, indo um pouco além de apenas fazer uma busca textual como qualquer SGBD faria. Há uma boa dose de matemática por trás disso tudo, pescando coisas da Álgebra Linear e da Teoria da Informação, mas isso é assunto pra um próximo post. Essa idéia de similaridade textual demonstrada aqui ainda é (imagino eu) utilizada em larga escala pelas máquinas de busca existentes nos dias atuais, juntamente com uma série de outros dados obtidos dos documentos para que no final tudo seja combinado em uma fórmula para enfim ordenar tudo para mostrar na tela do navegador. Só que isso também é assunto pra próximo(s) post(s).

Por enquanto é isso. :-)

An example of transitional packages in Debian

July 17th, 2009

When you have to change the name of your package (e.g. for complying with policies) or you make a new package that is meant to replace the old one (e.g. gcc4.2 -> gcc4.3), you’ll have to deal with the fact that the other packages that use your old package as a dependency will not be immediately updated, or maybe never will. So, to overcome this issue, there is a useful trick: transitional packages.

Transitional packages are essentially proxies – packages that pull the correct dependencies when installed and can be removed without problems as soon as the installation finishes. Some of these packages also have scripts to make/ease the transition when it is necessary. With this package you’ll be able to ship your new/updated package without worrying breaking all the others that depend on it (provided that the funcionality stays the same) and then inform the maintainers that their packages need to be upgraded to the new version of the dependency.

As an example, suppose you used to maintain a package named foo that is used by other package, baz. You have made a completely new package, bar, and intend to completely replace foo. So, for making the transitional package, you add these lines to the debian/control file of bar:

Source: bar
Section: unknown
Priority: extra
Maintainer: Bruno Araujo <bruno@baraujo.net>
Build-Depends: cdbs, debhelper (>= 5), [bar build dependencies]
Standards-Version: 3.7.2

Package: bar
Architecture: any
Provides: foo
Replaces: foo (<< 0.1-2)
Conflicts: foo (<< 0.1-2)

Depends: ${shlibs:Depends}, ${misc:Depends}, [bar dependencies]
Description: <insert up to 60 chars description>
<insert long description, indented with spaces>

Package: foo
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, bar
Description: Transitional package for bar
This is a transitional package for foo, and can be safely removed
after the installation is complete.

The bold lines are the modification needed for providing the transitional package. Two modification were made:

  • In the Package: bar section, three new keywords were added: Provides, Replaces and Conflics. They will be explained shortly.
  • The transitional package must have the same name of the package you intend to replace. Usually a short explanation about the nature of the package is written.

The three keywords added to the bar package section are used to proper inform dpkg of the transitional package and to decide which actions will be taken should the need arise.

  • The Provides keyword informs dpkg that the package bar provides a “virtual package” named foo (more details about virtual packages can be found on the Debian Policy)
  • The package bar should not be installed at the same time as the old package foo, so the Conflicts keyword indicates this.
  • If a conflict arises, the Replaces keyword indicates which package must be chosen for solving the conflict.

Now, when you try to install the package baz, the transitional package foo will be installed with its dependency bar, which is the correct dependency that should be used. For more details about these keywords, see sections 7.4-7.6 of the Debian Policy. Note that, in this case, the only transition was pulling the correct dependency; in other cases, when some extra works needs to be done before or after installing the package,  one of the ways to do this work is including the necessary scripts and putting calls to them inside <package>.preinst (pre-installation) and <package>.postinst (post-installation) inside debian directory.

Welcome. Welcome to City 17…

April 16th, 2009

…er, sorry… I couldn’t resist. Anyway, as the title of the blog implies, this is where I’ll write about some things related to software development, open source software and also about some of my topics of interest, e.g. Information Retrieval and Web search engines. “All work and no play makes Jack a dull boy”, as the saying goes, so maybe some posts about gaming (PS3 ftw!) and daily random facts may find their way here. Also, as I’m not a native speaker, please excuse me if my English seems lousy somehow.

For the time being, I’ll search for a cool theme for the blog and tweak here and there. As soon as I have some interesting information I’ll post again :P

P.S.: the title of the post is a homage to Half-Life 2, just start playing it and you’ll understand. :-)