by Lucas De Marchi
RSS icon Home icon
  • ANNOUNCE: codespell 1.0

    I’m glad to announce codespell 1.0! After 3 RCs and patches submitted to several projects, I thought it was stable enough to call it 1.0. You can download the 1.0 version below:

    http://packages.profusion.mobi/codespell/codespell-1.0.tar.bz2

    See my previous post if you are willing to know what codespell is or read the README file inside the package.

    I have already filled a TODO file with ideas for the next version. They came to mind after I’ve generated a giant patch for the Linux kernel. It is the biggest patch I’ve ever produced with codespell. Really, I think it’s the biggest patch I’ve produced ever. I hope Linus accept that patch as is because without the changes I’m planning for codespell 1.1, it’s a pain to fix some corner cases.

    Some people are sending me suggestions and more misspellings to my email. I appreciate those emails and seeing they are successfully using codespell in other projects. If you want a faster way to have your changes incorporated into codespell, you may also send patches through git-send-email or just use my repository on github to send me pull requests.

    UPDATE (04/11/2011): Linus accepted the patch. There’s also a discussion with further improvements for codespell on LKML.

  • On typos and misspellings

    This week I’m in a release mood, so I’m releasing several projects I’m involved with. If you lost the first two, checkout dietsplash 0.3 and genslide 0.3 (though the announcement was in Portuguese).

    After developing for several projects I’ve noticed most of them contain typos and misspellings. Even if this does not directly affect the source quality (unless the misspellings are in documentation), if we left the comment there, we’ve left it for a reason: because we want the reader of that code to stop and read it. It’s particularly good to have the correct spelling of each word when there are people from several parts of the word that maybe do not have English as their mother tongue (as I don’t). This way we can be more sure the correct message is being given through code, comments  and documentation.

    Thinking a bit on this I made some bash and awk scripts to fix misspellings based on the list of common misspellings available on wikipedia. I’ve successfully sent patches for projects like the Linux kernel, ConnMan, oFono and EFL. After some of them were accepted and after I decided to run the scripts again, I noticed how slow they were (if you are curious what they did, you can google on the oFono mailing list, in which I explain the scripts). So, I started a new, very short project: codespell. Measuring against the Linux kernel tree, it runs circa 20x faster than the previous scripts. Its current version is 1.0-rc1 and I’d like to have some more testers before I release the final 1.0.

    Codespell is designed to fix misspellings in source code, but it can be applied to any type of text files. When possible, codespell will automatically fix the misspelling. Otherwise it will give some suggestions about possible changes. For example, running against the Linux kernel tree, it gives me several lines like below:

    drivers/target/target_core_transport.c:2528: competion  ==> competition, completion

    drivers/edac/cpc925_edac.c:186: MEAR  ==> wear, mere, mare

    WARNING: Decoding file drivers/hid/hid-pl.c

    WARNING: using encoding=utf-8 failed.

    WARNING: Trying next encoding: iso-8859-1WARNING: Decoding file drivers/hid/hid-pl.cWARNING: using encoding=utf-8 failed. WARNING: Trying next encoding: iso-8859-1

    drivers/net/niu.c:3276: clas  ==> class  | disabled because of name clash in c++

    FIXED: ../kernel/drivers/scsi/aacraid/aacraid.h

    FIXED: ../kernel/drivers/scsi/lpfc/lpfc_sli.c

    FIXED: ../kernel/drivers/scsi/aacraid/aacraid.hFIXED: ../kernel/drivers/scsi/lpfc/lpfc_sli.c

    (This is all in beautiful colored lines! Test it to see the true output)

    The first two illustrate some changes that cannot be automatically done because that misspelling is a common one for more than one word. So, codespell gives you the file and line where they occur.

    The WARNINGs are related to the encoding of the file. Codespell will default to parse files in UTF-8 encoding, which will handle ‘ascii’ as well. If it fails to decode any line, it will try the next available encoding, i.e. ISO-8859-1. Using these two encodings I have successfully ran codespell with all the projects I care about.

    Codespell allows some changes to be disabled. This is shown by the “clas => class” fix, that are not always safe to do because of name clash with C++ code.

    The lines prefixed with “FIXED” show the files that were automatically fixed. In current Linus’ master branch, this resulted in:

    2545 files changed, 5007 insertions(+), 5007 deletions(-)

    These were the automatic fixes, that may contain some false positives. The funniest one is the on found in Documentation/DocBook/kernel-hacking.tmpl:

    /*
    * Sun people can’t spell worth damn. “compatability” indeed.
    * At least we *know* we can’t spell, and use a spell-checker.
    */
    As can be seen by the number above, this is not really true ;-) .
    So, there it’s: codespell 1.0-rc1. Get it. Test it. Report problems. Tell me about projects that were successfully patched.

  • git repository is down

    I’m turning down my repository at politreco.com. All my projects are now available either on ProFUSION’s repo or on github.

  • ANÚNCIO: genslide 0.3

    É com satisfação que anuncio a primeira versão do programa genslide, genslide 0.3. É um simples programa que criei para facilitar a conversão de letras de música em slides, salvando-os em pdf através de Latex/Xelatex. Esses slides podem ser usados durante shows e cultos e venho usando-os já faz 6 meses na igreja que eu frequento. Embora ainda tenha bastante coisa para ser feita, ele já se mostra bastante útil e facilita bastante na hora de criar novos slides.

    A ideia é que o usuário não se preocupe com muito com a formatação, apenas com a divisão de título, estrofes e coro. Se você é da área de computação, isso se traduz dizendo que a gramática é bem simples. Uma símples música, contendo o título e 2 estrofes:

    Esse é um título de exemplo

     

    A primeira linha da primeira estrofe

    A segunda linha da primeira estrofe

    A terceira linha da primeira estrofe

     

    A primeira linha da segunda estrofe

    A segunda linha da segunda estrofe

    A terceira linha da segunda estrofe

    Existem alguns recursos adicionais, como marcação de uma estrofe como coro e marcação de um trecho da música para repetição. Além disso, nem sempre a frase cabe nos espaço disponível do slide. A divisão em várias linhas é feita de forma automática, bem como a divisão entre os slides. Assim, se você tiver uma linha da forma abaixo, ela será automaticamente dividida em 2 ou mais linhas.

    Essa é uma linha realmente longa que não caberia em uma única linha no slide

    Outro recurso interessante é a integração com o site de letras do Terra. Dessa forma é possível gerar os slides simplesmente passando o link para a letra nesse site. Por exemplo, para gerar um slide da música “Pra cima Brasil”, do João Alexandre:

    $ genslide-bin http://letras.terra.com.br/joao-alexandre/46505/

    A aparência dos slides finais é dada por um conjunto de arquivos que formam um tema. O tema que uso atualmente é bem simples, mas nada impede que temas mais sofisticados sejam criados. Atualmente a linha acima geraria o conjunto de slides abaixo. Espero que esse programa seja útil não só para mim, mas para todos que precisam fazer esse tipo de conversão.

    Download

    Você pode fazer o download de genslide na página de downloads do programa. A última versão, 0.3, pode ser obtida em formato tar.bz2 ou zip. Tudo o que você precisa é ter python3 instalado (testado somente em Linux).

    Hacking e feedback

    O código-fonte da última versão está disponível acima ou, para a última versão de desenvolvimento, você pode fazer o download no repositório do projeto.

  • ANNOUNCE: dietsplash 0.3

    I’m pleased to release a new version of dietsplash.  This is the first announcement for dietsplash, though it has always been open source software. Here it is, dietsplash 0.3.

    dietsplash is a small boot splash screen for Linux. Its aim is to do the minimal work possible so you can see your system booting without getting bored about the messages going on (or better, your client doesn’t complain to you that it’s ugly to see all those messages). Its main target is embedded systems, where running a full/big splash like plymouth is an overkill. Special attention is given to keep it small: as of now, it produces a binary of just 14KB without images and 34KB using the images that come as example bundled into the binary.

    Running it is very simple, requiring very little configuration if you don’t have any splash screen yet. If you are already running another splash like plymouth or psplash, you’ll first have to disable it. Please, see the README file that details what you have to do in order to have it up and running.


    DOWNLOAD

    Releases are available at http://packages.profusion.mobi/dietsplash/. Here is the latest release: dietsplash 0.3.

    HACKING

    Patches and feedback are very welcome. You can either send me an email or use the infrastructure at github, where there’s a “mirror” of the git repository.

    Git repositories: git://git.profusion.mobi/users/lucas/dietsplash.git (where the fun happens) and git://github.com/lucasdemarchi/dietsplash.git (synchronized every now and then).

  • ProFUSION work on oFono and ConnMan

    As some of you know, I’m working on some open source projects at ProFUSION. Among them there are two projects started by Intel that are now part of Meego. If you look at Meego Architecture you’ll see these components are a great part of the Communications domain.

    In ConnMan ProFUSION made mainly some bug fixes and minor improvements while we were creating a binding for e_dbus and a module for E17. It’s working pretty well, it’s fast and reliable. Examining my logs in my desktop system I can see that in less than a second ConnMan is up with wired and wireless interfaces and the IP is already discovered through dhcp.

    In oFono we did a bit more work, implementing missing features in the core and also in drivers of Huawei and MBM (sony-ericsson) modems as well as on the phone simulator, phonesim.

    It’s great to see on Marcel’s reports last month that in 2010 ProFUSION was the 3rd major contributor for oFono and the 5th for ConnMan. I’m happy to be one of the developers contributing to these 2 great projects.

  • Open source hardware – Arduino

    This post is just forward of an amazing documentary I saw today. It’s Arduino The Documentary. How open source hardware became cheap and fun. It’s worth watching all its 27min.

    I think universities in Brazil should learn about and join projects like this.

  • EFL 1.0 Beta 2

    EFL team is proud to announce beta2 of the coming EFL 1.0. WebKit-EFL also received a new snapshot as well as several other related projects. For more information, take a look at the announcement.

  • Criando imagens customizadas de endereços de email

    Endereços de email são muitas vezes mascarados na web para que não sejam facilmente obtidos por programas que tem por objetivo enviar spam. É relativamente fácil escrever um programinha que fica vasculhando a web em busca de endereços de email, cadastrá-los em um banco de dados e depois utilizá-los como quisermos. Para que isso não ocorra, várias vezes nos deparamos com endereços de email passados como “joao AT gmail DOT com” ou alguma coisa do tipo.  Outra técnica muito utilizada é transformá-lo em uma imagem. Dessa forma o programinha malicioso que a princípio era fácil se torna bem mais difícil.

    Eu acho que hoje em dia temos bons programas de anti-spam, o que torna os métodos acima não tão relevantes. Porém, acredito que converter o endereço de email em uma imagem o deixa bonito. Veja por exemplo a minha página de contatos. Fazer imagens desse tipo apara domínios conhecidos como “gmail.com”, “hotmail.com” e “yahoo.com” é bem fácil: vários sites permitem que você escolha um desses domínios e escreva o seu email. Um que eu gostei foi o do freetechjournal, pois tem vários domínios ali dos serviços de email mais populares. É fácil encontrar serviços semelhantes que permitem alguma customização.

    Procurei bastante na web algum site que permitisse criar um email com uma imagem de domínio customizada, porém não achei nenhum. Como é uma operação bem simples, resolvi fazer um script em python para isso. Estou disponibilizando o iconifymail, que contém também a imagem usada para a empresa em que trabalho, ProFUSION, que pode servir como base para que você faça a sua própria imagem (obrigado, Marina). O uso é bem simples, basta passar como primeiro argumento a imagem a ser utilizada como domínio e, como segundo, o seu endereço de email (sem o domínio). Algumas coisas eu deixei hard-coded no script, mas creio que seja fácil adaptá-lo para o tamanho de imagem que você quiser. O resultado final é o que pode ser visto abaixo e também na minha página de contatos:

    Essa é a versão 0.1 do iconifymail, open source, disponibilizado sob GPLv3. Se você quiser contribuir, pode usar os repositórios git: oficial ou mirror.

  • Easily embedding WebKit into your EFL application

    This is the first of a series of posts that I’m planning to do using basic examples in EFL, the Enlightenment Foundation Libraries. You may have heard that EFL is reaching its 1.0 release. Instead of starting from the very beginning with the basic functions of these libraries, I decided to go the opposite way, showing the fun stuff that is possible to do. Since I’m also an WebKit developer, let’s put the best of both softwares together and have a basic window rendering a webpage.

    Before starting off, just some remarks:

    1. I’m using here the basic EFL + WebKit-EFL (sometimes called ewebkit). Developing an EFL application can be much simpler, particularly if you use an additional library with pre-made widgets like Elementary. However, it’s good to know how the underlying stuff works, so I’m providing this example.
    2. This could have been the last post in a series when talking about EFL since it uses at least 3 libraries. Don’t be afraid if you don’t understand what a certain function is for or if you can’t get all EFL and WebKit running right now. Use the comment section below and I’ll make my best to help you.

    Getting EFL and WebKit

    In order to able to compile the example here, you will need to compile two libraries from source: EFL and WebKit. For both libraries, you can either get the last version from svn or use the last snapshots provided.

    • EFL:

    Grab a snapshot from the download page. How to checkout the latest version from svn is detailed here, as well as some instructions on how to compile

    • WebKit-EFL:

    A very detailed explanation on how to get WebKit-EFL up and running is available on trac. Recently, though, WebKit-EFL started to be released too. It’s not detailed in the wiki yet, but you can grab a snapshot instead of checking out from svn.

    hellobrowser!

    In the spirit of “hello world” examples, our goal here is to make a window showing a webpage rendered by WebKit. For the sake of simplicity, we will use a default start page and put a WebKit-EFL “widget” to cover the entire window. See below a screenshot:

    hellobrowser - WebKit + EFL

    The code for this example is available here. Pay attention to a comment in the beginning of this file that explains how to compile it:

    gcc -o hellobrowser hellobrowser.c \
         -DEWK_DATADIR="\"$(pkg-config --variable=datadir ewebkit)\"" \
         $(pkg-config --cflags --libs ecore ecore-evas evas ewebkit)

    The things worth noting here are the dependencies and a variable. We directly depend on ecore and evas from EFL and on WebKit. We define a variable, EWK_DATADIR, using pkg-config so our browser can use the default theme for web widgets defined in WebKit. Ecore handles events like mouse and keyboard inputs, timers etc whilst evas is the library responsible for drawing. In a later post I’ll detail them a bit more. For now, you can read more about them on their official site.

    The main function is really simple. Let’s divide it by pieces:

        // Init all EFL stuff we use
        evas_init();
        ecore_init();
        ecore_evas_init();
        ewk_init();

    Before you use a library from EFL, remember to initialize it. All of them use their own namespace, so it’s easy to know which library you have to initialize: for example, if you call a function starting by “ecore_”, you know you first have to call “ecore_init()”. The last initialization function is WebKit’s, which uses the “ewk_” namespace.

        window = ecore_evas_new(NULL, 0, 0, 800, 600, NULL);
        if (!window) {
            fprintf(stderr, "something went wrong... :(\n");
            return 1;
        }

    Ecore-evas then is used to create a new window with size 800×600. The other options are not relevant for an introduction to the libraries and you can find its complete documentation here.

        // Get the canvas off just-created window
        evas = ecore_evas_get(window);

    From the Ecore_Evas object we just created, we grab a pointer to the evas, which is the space in which we can draw, adding Evas_Objects. Basically an Evas_Object is an object that you draw somewhere, i.e. in the evas. We want to add only one object to our window, that is where WebKit you render the webpages. Then, we have to ask WebKit to create this object:

        // Add a View object into this canvas. A View object is where WebKit will
        // render stuff.
        browser = ewk_view_single_add(evas);

    Below I demonstrate a few Evas’ functions that you use to manipulate any Evas_Object. Here we are manipulating the just create WebKit object, moving to the desired position, resizing to 780x580px and then telling Evas to show this object. Finally, we tell Evas to show the window we created too. This way we have a window with an WebKit object inside with a little border.

        // Make a 10px border, resize and show
        evas_object_move(browser, 10, 10);
        evas_object_resize(browser, 780, 580);
        evas_object_show(browser);
        ecore_evas_show(window);

    We need to setup a bit more things before having a working application. The first one is to give focus to the Evas_Object we are interested on in order to receive keyboard events when opened. Then we connect a function that will be called when the window is closed, so we can properly exit our application.

        // Focus it so it will receive pressed keys
        evas_object_focus_set(browser, 1);
     
        // Add a callback so clicks on "X" on top of window will call
        // main_signal_exit() function
        ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, main_signal_exit, window);

    After this, we are ready to show our application, so we start the mainloop. This function will only return when the application is closed:

        ecore_main_loop_begin();

    The function called when the application is close, just tell Ecore to exit the mainloop, so the function above returns and the application can shutdown. See its implementation below:

    static Eina_Bool
    main_signal_exit(void *data, int ev_type, void *ev)
    {
        ecore_evas_free(data);
        ecore_main_loop_quit();
        return EINA_TRUE;
    }

    Before the application exits, we shutdown all the libraries that were initialized, in the opposite order:

        // Destroy all the stuff we have used
        ewk_shutdown();
        ecore_evas_shutdown();
        ecore_shutdown();
        evas_shutdown();

    This is a basic working browser, with which you can navigate through pages, but you don’t have an entry to set the current URL, nor “go back” and “go forward” buttons etc. All you have to do is start adding more Evas_Objects to your Evas and connect them to the object we just created. For a still basic example, but with more stuff implemented, refer to the EWebLauncher that we ship with the WebKit source code. You can see it in the “WebKitTools/EWebLauncher/” folder or online at webkit’s trac. Eve is another browser with a lot more features that uses Elementary in addition to EFL, WebKit. See a blog post about it with some nice pictures.

    Now, let’s do something funny with our browser. With a bit more lines of code you can turn your browser upside down. Not really useful, but it’s funny. All you have to do is to rotate the Evas_Object WebKit is rendering on. This is implemented by the following function:

    // Rotate an evas object by 180 degrees
    static void
    _rotate_obj(Evas_Object *obj)
    {
        Evas_Map *map = evas_map_new(4);
     
        evas_map_util_points_populate_from_object(map, obj);
        evas_map_util_rotate(map, 180.0, 400, 300);
        evas_map_alpha_set(map, 0);
        evas_map_smooth_set(map, 1);
        evas_object_map_set(obj, map);
        evas_object_map_enable_set(obj, 1);
     
        evas_map_free(map);
    }

    See this screenshot below and  get the complete source code.

    EFL + WebKit doing Politreco upside down