Select orthographic mistake with the mouse pointer and press Ctrl+Enter. Let’s make our language cleaner!
Якщо помітите помилку на цій сторінці, будь ласка, виділіть її вказівником миші та натисніть Ctrl+Enter. Зробімо наше мовлення чистішим!
Показ дописів із міткою devel. Показати всі дописи
Показ дописів із міткою devel. Показати всі дописи

2007-11-07

Core dump

Where’re those known from the university times core dumps on Linux? How can I discover a really rear bug in the server daemon?

Well, it appeared that they’re just turned off for ordinary users in the /etc/profile:

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

Really, why a user should know about such a weird thing? Now I always reset the ulimit before starting an application being debugged.

2007-04-11

Base64 transformations in C++

There appeared a task to encode a binary data to base64 and then decode it back. There’re many solutions, but this one I liked very much.

#include "boost/archive/iterators/base64_from_binary.hpp"
#include "boost/archive/iterators/binary_from_base64.hpp"
#include "boost/archive/iterators/transform_width.hpp"
#include <string>
#include <iostream>

using namespace std;
using namespace boost::archive::iterators;

typedef
    base64_from_binary<
        transform_width<string::const_iterator, 6, 8>
        > base64_t;

typedef
    transform_width<
        binary_from_base64<string::const_iterator>, 8, 6
        > binary_t;

int main()
{
    string str("Hello, world!");
    cout << str << endl;
    string enc(base64_t(str.begin()), base64_t(str.end()));
    cout << enc << endl;
    string dec(binary_t(enc.begin()), binary_t(enc.end()));
    cout << dec << endl;
    return 0;
}

It’s simple enough, isn’t it? But the world is not ideal, and because of a bug decoding doesn’t work, as expected. Fortunately, the bug can be worked around with a little hack.

2007-03-03

Using DocBook XML from now

I always disliked HTML because of its oddities. To post previous table I tried three times to mark it up. Then I gave up, and switched to the thing I really know, that’s DocBook XML.

First, the posts have very clean logic structure, there’s no mixture of content and representation.

Second, all sources of my posts can be stored in my repository now. That has promising advantages for the future.

My next goal is to find an offline blogger client, probably a plugin for the vim, so that I could avoid using html forms and automate the process of posting.

Typing text is getting easier

It was always complicated to type some beautiful text characters, for instance quotation marks ‘’ or “”. Actually, I’ve never known how to do it efficiently enough. When I worked under windows, I pressed the alt key then typed four-digit code of the character, and finally released the alt. That was six–seven keys to press!

There was no such possibility under Linux at all. So I tried to use the OpenOffice.org writer first. After years of software development I decided that there’s no better editor than the Vim. So I started using it everywhere. To edit a text in a web input field, I use the ViewSourceWith add-on for Mozilla. To type an exotic sign ’, I pressed <c-v>u2019. That was another seven keys.

And finally I discovered so called digraphs. This beast can help to type almost any character by pressing only four keys. For example, the same apostroph ’ can be typed as <c-k>'9. Moreover, two-character abbreviation of a sign is very easy to remember:

'6, '9‘, ’Digits 6 and 9 are very like the sign itself.
"6, "9“, ”wThe same story as above.
-N, -M–, —En and em dashes respectively.
N0№Numero, number.

I haven’t found the ellipsis …, so I had to define it manually in my .vimrc: :digraph 3_ 8230.

2007-02-19

Dancing with tambourine

This little story tells, how I installed driver for ATI Radeon Xpress 1100 under Fedora Core 6. Well, everything worked just fine primarily with the generic open source driver called radeon. The universal linux test for OpenGL glxgears showed that my new laptop processes near 450 fps, that's to say there was no hardware acceleration at all. Offensively. So I went to the ati.com, downloaded their native driver. It doesn't matter that the 'radeon xpress 1100' doesn't even appear in the list of supported hardware, the driver is as generic that it can work with many others. It turned out also that there were the only driver suite for any configuration, and I had to download near 60 MB. So I became a happy owner of a copy of new ATI hardware driver with version number 8.33.6. Very well, we begin shortly. First I have to confess that I've just customized my linux kernel and installed the newest version available at that time, that was 2.6.20. Actually, this let me have spent MUCH MORE time getting the driver to work. 1) Launch $ ati-driver-installer-8.33.6-x86.x86_64.run --listpkg showed that my system distribution should be well supported. 2) But when I tried to build RPM packages, I got first surprise: ati-driver-installer-8.33.6-x86.x86_64.run --buildpkg Fedora/FC6 .... (lots of compilation errors go here) The short look at the messages revealed that the version 2.6.20 of the linux kernel isn't supported by the driver. Actually, there were no macros _syscallX() anywhere. But deep investigation in the web found out that that problem can easily be solved by defining missing macros either in the source file where they're used or in the kernel source. In my case the latter was more suitable. 3) I tried to build desired RPM packages again. The second problem prevented me from success, it appeared that my system lacks the fireglcontrolpanel application. The web helped me again: the source of the program can be extracted from the driver package and compiled manually. It appeared that to do so, one must solve some easy programming puzzles ;-) 4) At last, I succeeded building RPMs for my system: $ ls *.rpm ATI-fglrx-8.33.6-1.fc6.i386.rpm ATI-fglrx-control-panel-8.33.6-1.fc6.i386.rpm ATI-fglrx-devel-8.33.6-1.fc6.i386.rpm kernel-module-ATI-fglrx-2.6.20-19.02.2007-8.33.6-1.fc6.i386.rpm $ su # rpm -ivh *.rpm 5) At this point everything seemed to be ready to restart X Window system, so I pressed ctrl + shift + backspace. The X server started, but nothing interesting happened. The glxgears showed the same 450 fps, fgl_glxgears refused to start. That was the best time to look at /var/log/Xorg.0.log. There were errors! So I disabled the option AIGLX in the section "ServerLayout" of /etc/X11/xorg.conf. 6) And that was the turning point! The glxgears printed out that my system was able to produce 2000 fps, almost four time increase! Enough about computers. I spent for that process near 24 hours, two times I decided to give it all up. But every time I came back and tried again. This insistency made my success, so I can safely say: "Never give up!"

2006-10-25

Developing the `Universal machine'

Hi! I've tried to solve very interesting task from the icfp. They propose to implement an interpreter of the byte-code for the specified `universal machine'. Well, I thought, such a program is a very easy to solve in C++, and what if I try to do it in Haskell? Said is done. But the result doesn't promise as much as I expected. First, the code is simple and clean indeed. Second, it works indeed. When I ran the benchmark by it, only simple tests passed, the other consumed too much memory. I wonder if there's a person who could help me out to tune the program...