Invertendo os Canais de Áudio no Linux

Se você, como eu, teve de dispor suas caixinhas de som ao contrário em sua prateleira simplesmente porque o comprimento do fio não dava conta de chegar ao outro lado, pode aproveitar esta dica aqui e de quebra evitar ter de fazer mais uma gambis na sua mesa.

Como root, abra o arquivo /etc/asound.conf:

nano /etc/asound.conf



Obs: você pode trocar o nano pelo editor de sua preferência, apenas tenha certeza de estar logado como, ou com direitos de, superusuário (root). Adicione sudo no começo desta linha de comando para adquirir a permissão automaticamente ou simplesmente digite su, pressione enter e entre com a senha de root logo antes de tudo.

Agora, basta copiar e colar o seguinte trecho para dentro do arquivo:

pcm.swapped
{
    type route
    slave.pcm “cards.pcm.default”
    ttable.0.1 1
    ttable.1.0 1
}

pcm.default pcm.swapped

Finalmente, salve o arquivo (no caso do nano, aperte Ctrl-X seguido de Y e Enter) e tente lançar alguma aplicação de áudio. Os canais agora devem estar trocados 🙂

System.Windows.Forms.Cursor.Position

I’ve found several places mentioning the use of the Windows native method GetCursorPos(POINT lpPoint) as a way to get the mouse cursor position outside a System.Windows.Form in C#. But why not use the built-in .NET Framework method, System.Windows.Forms.Cursor.Position instead? A quick look using Reflector show us that Cursor.Position is merely a managed call to another method,

UnsafeNativeMethods.GetCursorPos(lpPoint);

which is, in turn, the exact unsafe native method I mentioned previously.

[DllImport(“user32.dll”, CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern bool GetCursorPos([In, Out] NativeMethods.POINT pt);

Thus, using Cursor.Position and GetCursorPos returns the same results, but the former is the clearly prefered option as it is a built-in method and is therefore a more portable option. Plus it provides additional permission checks to ensure your application has the right privileges to run prior to execution.

So, unless you are trying to avoid adding a reference to Windows.Forms in your project, there is no reason to use interop when System.Windows.Forms.Cursor.Position is an option.

Building a Hexadecimal Display using AHDL

qgc18e0000001qdf

Here is the code for a Binary-to-Hexadecimal Decoder for seven-segment displays implemented on Altera’s Hardware Decription Language (AHDL), the language for building logic blocks inside Altera’s Quartus II.

An optional invert input (named N) is provided to invert the decoder outputs, which is often necessary if you plan to emulate your device using a FPGA and it happens to have its output display with inverted logic activation. This code also serves as a example on how to program a logic function by using its truth table directly in AHDL.

To use this code in your Quartus II project, open up your project, then click

“File -> New”,

choose “AHDL File”, copy and paste this code and then click

“File -> Create / Update -> Create Symbol Files for Current File”

to create its symbol file. After that, you may add the decoder to your schematics as if you were adding a common component to your circuit using the Symbol Tool dialog. The symbol should be located under the Project library.

For more information about using AHDL and Quartus, you may read this guide, Using AHDL in the Quartus II Software. There is a lot of other resources available online teaching how to use Quartus II out there. Some of them can be found on the following links:



Altera, The Programmable Solutions Company, the stylized Altera logo,
specific device designations, and all other words that are identified
as trademarks and/or service marks are, unless noted otherwise, the
trademarks and service marks of
Altera Corporation in the U.S. and
other countries. Other linked content from here are copyrighted from its respective owners. The AHDL code provided above belongs to the
public domain.

A few Chrome thoughts

Chrome_nav_150x75

Chrome is obviously missing an undo close tab function. It is really annoying to mistakenly click “close tab” (the x button next to the tab’s name) while switching tabs. Also, I would expect Chrome to remember what I typed on a form whenever I go back and forth in a site just like Opera does.

On Opera, the only thing one has to do to restore a recently closed tab is hit Ctrl-Z so the tab magically reappears with all information one had previously typed in. It is true the browser can restore itself whenever it crashes, but this ain’t necessarily true for user-typed information. I think this, the lack for mouse gestures and good bookmark synchronization are the only major drawbacks for the browser at the moment.

Also, Chrome doesn’t seem to perform very well on old machines, such as the old 1GHz Athlon Thunderbird box I use when I’m back to my hometown on the weekends. Opera and Internet Explorer ran just fine, but Chrome is sometimes sluggish, specially with Youtube videos or with more than 5 tabs open. Bad news, since I like to start mid-clicking everything I find interesting, opening new tabs in the background for later reading. This is probably due to how Chrome manages tabs using separate processes, but is a drawback, nonetheless.



Last note: In order to get the dead tab picture, I googled for some random website and started middle-clicking it like crazy. After 10 or more clicks, one of the new tabs (only one) finally crashed, showing that picture. But after a few seconds, all my other tabs (including the Blogger’s post editor I was using to write this) began chaging to the same screen! I think those tabs processes aren’t exactly as separate as it seems!

Debian APT sources.list

This is my apt sources list. If you just need a quick setup for your Debian, copy & paste this text into /etc/apt/sources.list, save the file and then update your package cache with apt-get update. Please note that many of the unofficial repositories listed here exists to serve non-free, non-gpl and/or other commercial stuff.

After you have configured your sources, you may check this post for some cool packages you can download using apt-get.