Monthly Archives: July 2006

Vídeo verde no Windows Media Player

Finalmente!!! Há meses que eu visitava alguns sites e ou via o vídeo pelo media player embutido no navegador, ou puxava ele e via separado, e o vídeo de repente ficava verde, e o computador, todo lerdo.

Para arrumar é simples: Clique com o botão direito no seu desktop, vá em Propriedades (pra janelinha de Propriedades de Vídeo aparecer), depois em Configurações e Avançadas.

Em “Solucionar problemas”, diminua em um ponto a aceleração de vídeo e clique em Aplicar. Tente ver o vídeo que vira verde, se acontecer de novo, diminua em mais um ponto a aceleração de vídeo, até tocar direito.

Eu tive que diminuir dois pontos, mas funcionou.

What does this function test?

A function wrote by a co-worker:

1
2
3
4
5
6
7
8
9
10
11
function test($what, $where) {
    if (!empty($where)) {
        if (!empty($where[$what])) {
            return $where[$what];
        } else {
            return '';
        }
    } else {
        return '';
    }
}

When I had a look at this function I immediatlly tought: Test? What does it test? Thankfully there’s the $what argument! And look! A $where argument too!

WTF? Folks, name your functions and variables properly.

Required date and optional time fields, how to store it?

Say you have a form where your user can input a required date (MM-DD-YYYY) and an optional time (HH:MM). How do you store this?

You can be tempted to store it as a timestamp (seconds since the Unix Epoch, for example) on your database, because it represents a date + time. But if your user doesn’t fill the time field, you would need to store the time as 00:00:00, and deal with accordingly on your business/display logic.

This is bad, because some day, someone will want to record a time exactly at midnight, and you won’t be able to deal with correctly. Have two columns on your database, one for the date, and another one for the time (and make it NULL, to store the empty hours/minutes).

Another chapter of Perils of Development brought to you by Julio Nobrega (yes, this has happened to me).