Dec
03
2009
0

Digital censorship in Europe

They are pushing and pushing laws and european directives to cut our fundamental freedoms, in particular freedoms related to Internet connectivity. Spanish govt wants to set up a special “comission”, gestapo style, without legal significance, and without being supervised by a judge, that would be able to shut down web pages and internet connections on any claims of copyright violation. For this reason we are demonstrating tomorrow friday 4-12-2009 at 20h in front of the ministery of culture in Madrid and in St. Jaume’s Place in Barcelona at the same time, and also in government delegations in other spanish cities. We can’t let a dying and obsolete music industry destroy our rights and freedoms.

Written by piotr in: computers, social | Tags:
Nov
29
2009
0

Bought a new keyboard

I’ve been looking for a decent keyboard to alleviate the problems of the currently flawed keyboard design that qwerty is. Specially for people that code many hours a day, which require constant key modifiers being pushed which may lead to RSI. From all the options I have seen in the web, I think the Data Hand is the most innovative design, but the price tag is scary, around 1K. Also they are manufactured in batches and not often, so meanwhile I found these keyboards http://www.typematrix.com/ and I decided to try a black one and also ordered qwerty and dvorak silicone covers. The price tag is ok, around $150. I see they have addressed some of the problems with the pinky finger but shift keys are still on the extremes. I’ll post my impression when I give it a try.

Written by piotr in: computers | Tags: , , ,
Sep
26
2009
0

Okuribito a worth a watch

Okuribito, a remarcable japanese movie that I’ve seen lately in OSV. I recommend not to look at the synopsys, even the imdb page and get surprised. Its imdb rating is above 8.

Written by piotr in: entertainment | Tags:
Jul
06
2009
0

oOo

Written by piotr in: Uncategorized |
Jun
11
2009
0

system in C++ like perl’s system

Small tricks, haven’t tested these yet, perhaps a bit of more error handling in fork or exec. I don’t like system (3) shell interpolation. In this case one can do system_exec(”ls”,”/tmp”,NULL) or special chars in args that won’t get interpolated by the shell.


    int system_exec(char* cmd, ...)
    {
        va_list ap;
        vector arglist;
        arglist.push_back(cmd);
        char* cur;
        va_start(ap,cmd);
        while( (cur=va_arg(ap,char*)) != NULL)
            arglist.push_back(strdup(cur));
        va_end(ap);
        arglist.push_back(NULL);
        int res;
        pid_t chld;
        if( (chld = fork()) ) {
            for(vector::iterator i = arglist.begin()+1; i != arglist.end(); ++i)
                free(*i);
            wait(&res);
        } else {
            execvp(cmd, &arglist[0]);
        }
        return res;
    }
#define W 1
#define R 0

    int stdout2stream_system_exec(std::ostream& os, char* cmd, …)
    {
        va_list ap;
        vector arglist;
        arglist.push_back(cmd);
        char* cur;
        va_start(ap,cmd);
        while( (cur=va_arg(ap,char*)) != NULL)
            arglist.push_back(strdup(cur));
        va_end(ap);
        arglist.push_back(NULL);

        int fd[2];
        pipe(fd);

        int res;
        pid_t chld;
        if( (chld = fork()) ) {
            for(vector::iterator i = arglist.begin()+1; i != arglist.end(); ++i)
                free(*i);
            close(fd[W]);
            char buf[1024];
            ssize_t nread;
            while( (nread=read(fd[R],buf,1024)) > 0 && os.good() ) {
                os.write(buf,nread);

            }
            // TODO errors
            close(fd[R]);
            wait(&res);
        } else {
            close(fd[R]);
            // no need according to manpage
            //close(STDOUT_FILENO);
            if( dup2(fd[W], STDOUT_FILENO) != STDOUT_FILENO) {
                perror(”dup2″);
                exit(EXIT_FAILURE);
            }
            close(fd[W]);
            execvp(cmd, &arglist[0]);
                perror(”execvp”);
        }
        return res;
    }


Written by piotr in: computers | Tags: , ,
Jun
03
2009
0
May
05
2009
0

Amazing Bach


Written by piotr in: art, computers, entertainment |
Apr
02
2009
0

1000% performance increase in flex parser

Or how an unexpected bug improved performance a lot.

I have a flex C++ parser that I was feeding an igzstream.
At some point I refactored some code and added io exceptions like:

is.exceptions(ios::eofbit | ios::failbit | ios::badbit);

Which caused the yylex() member function throwing a ios::clear exception at EOF, well, the parser checks the bits of the stream by itself, setting exceptions is not good with a flex parser. Looking at the generated parser and with the nice advice from DrNick of setting a breakpoint on __cxa_throw to backtrace the exception point, I saw accidentally that YY_INTERACTIVE was defined on my parser, which can be disabled by setting:

%option batch

in the .ll file. This caused a huge unexpected performance boost that is going to be appreciated given the cpu intensive task that parsing is.

The numbers are: from an average parsing of 2882ms to 290 ms

Written by piotr in: Uncategorized |
Mar
12
2009
0

El baño

Doblo mi cuerpo y me hago un ovillo
el líquido me rodea pero no soy el mismo
mi ser en el tiempo se disuelve
como el agua al polvo cuando llueve
a mi mismo me digo… ¡He venido!, !He venido!
mas ya nada me conmueve.

Written by piotr in: art |
Mar
12
2009
0

Two different ways to visualize hard disk usage

My two favorite programs to manage hard disk usage are based in two very different visualization techniques. One is gdmap which uses a treemap and the other is filelight which uses concentric circles which work like multiple piecharts.

Written by piotr in: computers | Tags: ,

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes