terça-feira, maio 26, 2009

How to boot Ubuntu in console mode (no X)

Despite the fact that graphical user interface is easier to daily work, I really prefer command line interface.

I tried to disable graphical startup on Ubuntu by editing inittab file, but what a surprise when I did not find it.

Where is it? After some googling I found out that to always boot in console mode you must execute this command:
sudo update-rc.d -f gdm remove
Every time you wish you can invoke Gnome from command line by typing
startx <ENTER>

quinta-feira, maio 21, 2009

How to declare 64 bits in Visual Studio 6

Did you ever needed to declare a 64 bits integer using Visual Studio 6?

On newer versions of Visual Studio and on gcc you can use the ll to tell the compiler that the value is 64 bits wide. But Visual Studio 6 does not understand it.

How do you do? You must use the keyword
__int64.

I discovered it because a project I wrote using Visual Studio 2005 that must be compiled using Visual Studio 6.

Below you can see a sample code that compiles both in VS 6 and 2005.

#include
#include "stdafx.h"
#include

int main(int argc, char* argv[])
{
__int64 i = 0;

printf("Hello World! %08x %08x\n", i);

#ifdef _MSC_VER
#if _MSC_VER <= 1200
// Visual Studio 6 or lower do not accept ll as 64 bits constants.
#define __IGNORE_LL_MODIFIER_MS
#endif // _MSC_VER
#endif // _MSC_VER

#ifdef __IGNORE_LL_MODIFIER_MS
i = ((__int64)0x1234567890123456);
#else
i = 0x1234567890123456ll;
#endif

printf("Hello World! %08x %08x\n", i);
getchar();
return 0;
}
I really hope this piece of information will be helpful to someone.

segunda-feira, maio 18, 2009

Get your own bazaar hosting service for free

I was looking for a free bazaar hosting service that let me use it with my private projects. Unfortunately I was not able to find anyone.

This week I came across DropBox. DropBox is a site that let you share files between computers (and between people if you wish to). The basic plan give you 2GB for free!

DropBox interface is pretty easy to use. One folder (usually named DropBox) will be used to share your files.

You put a file into the folder and it will be available into any computer you log in. have you changed the file? DropBox will update it.

Don't you want the file anymore? Delete it from your Dropbox folder and it will be delete from other computers too (as soon as you get logged into them). DropBox will keep your files synchronized. You don't have to worry about it.

So, I decided to use it as a bazaar repository. I created a folder named bzr.d under DropBox. All files I want to keep under source control are inside this folder.

Now I have my own bazaar hosting for free. And know what? You can share your bazaar repository (bzr.d in my case) with some friends and all of you will be able to develop the same project. It's a bad idea to share your repository as I've told. The reasons were pointed out by our friend Andreas (see bellow on comments). Andreas, many thanks for pointing this out.

This solution (Dropbox + bazaar) works well when there is just one developer working on it. I do it since a long time without any problem.

You can even have many repositories at the same time (since they don't occupy more than 2GB).

Do you need more space? DropBox has two paid plans (50GB and 100GB).

And you can use it as a hosting for git and mercurial too.

Edited: As you can see in comments, our friend JavaJim gave us a nice tip (Thanks JavaJim):

"If you init your bazaar repository with command bzr init-repo --no-trees my-new-dropbox-repo you can save a lot of space on dropbox. Plus, you force your friends to work on their own branches instead of editing files on dropbox directly (with no-trees bazaar hides the source files)."

I think it's worth a try.

quarta-feira, maio 13, 2009

GMouseTool on the fourth annualSourceForge.net Community Choice Awards

I've nominated my project for the fourth SourceForge.net Community Choice Awards.

It is the election of the best programs of the year that have been choosed by users.

I am not under any illusion that I will win. GMouseTool is a very tiny project. And, as far as I know, there are only two GMouseTool users: me and another person named Ryan Reif.

It it is just for fun. You can vote for GMouseTool. Click into the image below. You must supply a valid e-mail. Then you confirm your nomination using the link Sourceforge will provide.

GMouseTool already have a vote. Now I need you vote for it ;)


GMouseTool no quarto SourceForge.net Community Choice Awards

Acabei de inscrever o meu projeto no quarto SourceForge.net Community Choice Awards.

É a eleição dos melhores programas do ano feita por voto direto dos usuários.

Não tenho a menor ilusão que vou ganhar alguma coisa. Além do GMouseTool ser um projeto muito pequeno, até onde eu sei, ele só tem dois usuário: eu e outra pessoa chamada Ryan Reif.

Mas vale a diversão. Se quiseres votar no GMouseTool, é só clicar na imagem abaixo e fornecer um e-mail válido. Aí o SourceForge vai te enviar um link que tu clicas para confirmar o voto.

Um voto o GMouseTool já tem. Agora só falta o teu voto. ;)


terça-feira, maio 05, 2009

Vim usando o corretor ortográfico Vero

O pessoal do BrOffice tem um verificador ortográfico chamado Vero, que já está adaptado ao novo acordo ortográfico.

Neste artigo vou mostrar como fazer o Vim utilizar o dicionário implementado no Vero.

1 - Baixe o corretor ortográfico no site do BrOffice: http://www.broffice.org/verortografico/baixar.

Eu baixei o arquivo Vero_pt_BR_V204AOC.oxt (a última versão no momento em que escrevo este artigo).

2 - Descompacte o arquivo (apesar da extensão .oxt, ele não passa de um arquivo zip). Será criada uma estrutura de diretórios semelhante a mostrada na figura 1.

Figura 1 - Estrutura de diretórios criada após descompactação

3 - Entre na pasta Dictionaries (ver figura 2), abra o Vim (ou o GVim) e, no modo de comando, digite:
:mkspell pt pt_BR <ENTER>

Figura 2 - Diretório de onde deve-se executar os comandos

O Vim irá processar os arquivos pt_BR.aff e pt_BR.dic e irá gerar um terceiro arquivo chamado pt.utf-8.spl.

4 - Crie a pasta ~/.vim/spell, se a mesma ainda não existir.

5 - Copie o arquivo pt.utf-8.spl para ~/.vim/spell ou $VIMRUNTIME/spell.

Agora Tu tens duas opções para utilizar a verificação ortográfica:

1. tu podes habilitá-la quando necessário, digitando no modo de comando:
:set spell <ENTER>
:set spelllang=pt <ENTER>
2. Tu configuras o arquivo .vimrc para que a correção esteja habilitada o tempo todo, acrescentando as linhas abaixo

e a desabilita quando não quiseres utilizá-la, digitando no modo de comando
:set nospell
Para reabilitar a verificação ortográfica, basta digitar no modo de comando
:set spell <ENTER>
Pronto. O Vim já está apto a usar o dicionário com a nova ortografia que emprestamos do Vero / BrOffice.

Outra coisa que podes fazer é utilizar o dicionário como fonte das palavras sugeridas no autocompletar.

Podes digitar no modo de comando
set complete+=kspell <ENTER>
ou incluí-la no .vimrc.