Blog pessoal de Felipe Portella

Archive for the ‘Uncategorized’ Category

Como configurar o Notepad++ para editar LaTeX

without comments

Achei o guia definitivo com todas as dicas que precisava nesse site:


inclui um script que não só compila, mas como faz um link entre a linha que vc está editando e em que ponto o PDF será aberto, facilitando muito a revisão.

Written by Felipe Portella

novembro 15th, 2013 at 5:48 pm

Posted in Uncategorized

Tagged with ,

How swype works?

without comments

Nice simple Python code to undestand how swype works:





Swype is an awesome software which makes typing in mobile phones using the qwerty keyboard very easy. This is how it looks:


I was just thinking how this could be implemented. It boils down to a string sub-sequence problem. The path traced by the user consists of all the characters in a word. This is an ideal situation, but many a times, we do not take care of all the characters in between and miss many of them.

Some of the characteristics i have considered:

1. Filtering of words based on the first and last character.
2. Characters which are buried among other characters in the path traversed by the user.
3. The number of traversals between different rows of the keyboard gives us a fair idea about the length of the word.

We can use a number of such characteristics and increase the chances of suggesting the right word. One such hint i can think of is:

Split the words in sets of three characters:
Lets take the case of the word "English" here. The actual trace may be like "edfgbnbghjkliugfdsdfgh"

Groups like bnb, bgh, kli, dsd strongly suggest that there is a turn which signifies a character which has a higher probability of being present in the word.

I wrote a basic version of this using python and this wordlist. Some basic introduction to some of the functional programming used here is discussed in this link

WORDS = open('wordlist.txt').read().split()
KEYBRD_LAYOUT = ['qwertyuiop', 'asdfghjkl', 'zxcvbnm']

def match(path, word):
    """ Checks if a word is present in a path or not. """

        for char in word:
            path = path.split(char, 1)[1]
        return True
    except : return False

def get_keyboard_row( char ):
    """ Returns the row number of the character """

    for row_no, row in enumerate(KEYBRD_LAYOUT):
        if char in row:
            return row_no

def compress(sequence):
    """ Removes redundant sequential characters. ex : 11123311 => 1231 """
    ret_val = [ sequence[0] ]
    for element in sequence:
        if ret_val[-1] != element:
    return ret_val

def get_minimum_wordlength(path):
    Returns the minimum possible word length from the path.
    Uses the number of transitions from different rows in 
    the keyboard layout to determin the minimum length
    row_numbers = map(get_keyboard_row, path)
    compressed_row_numbers = compress(row_numbers)
    return len(compressed_row_numbers) - 3

def get_suggestion(path):
    """ Returns suggestions for a given path. """

    suggestions = filter(lambda x: x[0] == path[0] and x[-1] == path[-1], WORDS)
    suggestions = filter(lambda x: match(path, x), suggestions)

    min_length = get_minimum_wordlength(path)
    suggestions = filter(lambda x: len(x) > min_length, suggestions)

    return suggestions

if __name__ == '__main__':
    test_cases = ['heqerqllo',                   # hello
        'qwertyuihgfcvbnjk',                     # quick
        'wertyuioiuytrtghjklkjhgfd',             # world
        'dfghjioijhgvcftyuioiuytr',              # doctor
        'aserfcvghjiuytedcftyuytre',             # architecture
        'asdfgrtyuijhvcvghuiklkjuytyuytre',      # agriculture
        'mjuytfdsdftyuiuhgvc',                   # music
        'vghjioiuhgvcxsasdvbhuiklkjhgfdsaserty', # vocabulary 

    for test in test_cases:
        print get_suggestion(test)

The results for the same were pretty good.

 ['hello', 'hero', 'ho']
 ['wed', 'weird', 'weld', 'wild', 'wold', 'word', 'world', 'would']
 ['doctor', 'door', 'dour']
 ['adjure', 'agriculture', 'article', 'astute']
 ['music', 'mystic']

The basic version was working within an hour. I must say that the string split method in python is very well thought of. split( delimiter, 1) returns a the string before and after the first match.

Written by Felipe Portella

maio 23rd, 2013 at 11:53 am

Showing a vertical rule in Visual Studio

without comments

You can install this add on:

You may find interesting to install this one too. It’s a UI to configure the rules direct in the editor panel:

Written by Felipe Portella

março 26th, 2013 at 1:35 pm

Posted in Uncategorized

Fix windows offline files with “The process cannot access the file because it is being used by another process” errors

without comments

When encountering this error you can solve by changing the OPLOCKS flags in the Samba config file:


Add the following lines, at the bottom of the GLOBAL section, just before the ‘include’ line;

oplocks = yes 
level2 oplocks = yes 
kernel oplocks = no

Now reboot or restart samba

Written by Felipe Portella

dezembro 3rd, 2012 at 3:55 pm

Posted in Linux,Uncategorized

Boa ferramenta para cálculos de churrasco

without comments


Calcula quantidades de carnes, bebidas etc. levando em consideração se é homem, mulher , criança e a fome …

Written by Felipe Portella

novembro 20th, 2012 at 4:35 pm

Posted in Uncategorized

Firmware alternativo para o roteador ASUS RT-N56U

without comments

Firmware alternativo  (similar ao DD-WRT, mas desenvolvido especificamente para os roteadores da ASUS, baseado no código fonte do firmware original)

Written by Felipe Portella

fevereiro 27th, 2012 at 2:09 am

Posted in Uncategorized

String Format for Double [C#]

without comments

Many samples showing how to format float numbers to string in C#:


Written by Felipe Portella

agosto 23rd, 2011 at 10:45 pm

Changing Education Paradigms

without comments

Written by Felipe Portella

outubro 27th, 2010 at 10:11 pm

Posted in Uncategorized

Tagged with

Quitação Eleitoral

without comments

Recebi hoje a dica de um amigo que evita ter que guardar aquelas tirinhas de papel ridículas para comprovar que votou nas últimas eleições.

Basta emitir gratuitamente a Certidão de Quitação Eleitoral através do site:


Written by Felipe Portella

outubro 19th, 2009 at 6:46 pm

Posted in Uncategorized

Ilha do Governador – Nostalgia

without comments

Apresentação com fotos antigas da Ilha do Governador no Rio de Janeiro.

[gview file=”http://www.portella.com.br/wp-content/uploads/2009/10/Ilha-do-Governador-Nostalgia.ppt”]

Written by Felipe Portella

outubro 11th, 2009 at 1:27 pm

Posted in cool,Uncategorized

Tagged with