Chaotic Rulers

November 28, 2017

I’m currently working with one of my students on a laser-based range finder. To assess the precision of the device, I needed a calibration piece. Because of the setup, the piece should look like a stair.

The piece should allow a wide range of different readings, say from 1 to 10 centimeters in known increments, say, 1cm. The naïve way of building such a piece is to build a stair with 10 steps. However, if you do it like this, the piece is wide, cumbersomely so. Is there a much better way to do so?

Read the rest of this entry »


ANSI Art

November 14, 2017

Since we now have minimal ANSI support, we can use it. Of course, for cute things such as changing text color (red for error, green for OK, etc.), but that’s not very amusing. Let’s make some ANSI ART!!1!

Read the rest of this entry »


Semigraphics Compression

November 7, 2017

ANSI art and poor resolution may appeal to the nostalgic, those in want of the time when BBS were still it and the IBM PC’s programmable character set was the nec plus ultra of semigraphics, but they’re not really useful. At best, we can use them to dispense ourselves from using ncurse and still getting some colors and effects

However, “semigraphics” may have their use in lossy data compression, were we allow some data to be lost to gain some more compression. That may be especially true when we have very little computing power or if we want to have many simple CPUs in parallel doing the decoding.

Read the rest of this entry »


ANSI soit-il.

October 24, 2017

There’s no easy way of getting a console-based color output with standard C++. Of course, you can use ncurse, which does pretty much everything, but that is also quite tedious to use. But if you need just a little bit of color, ncurse is pretty overkill. Fortunately, if you have an ANSI capable terminal, that’s much easier.

Read the rest of this entry »


Whatever sums your floats (Part II)

September 26, 2017

A while ago, Martin Capoušek drew my attention on Kahan’s summation algorithm and ask how it compared to the other methods I presented then.

Well, let’s find out.

Read the rest of this entry »


Undo that mess

September 12, 2017

During last marking season (at the end of the semester), I had, of course, to grade a lot of assignments. For some reason, every semester, I have a good number of students that write code like they just don’t care. I get code that looks like this:

int fonction              (int random_spacing)^M{           ^M
  int            niaiseuses;

  for (int i=0;i<random_spacing;         i++){
                    {
       {
        std::cout
         << bleh
         << std::endl;
    }}

  }
}

There’s a bit of everything. Random spacing. Traces of conversions from one OS to another, braces at the end of line. Of course, they lose points, but that doesn’t make the code any easier to read. In a previous installment, I proposed something to rebuild the whitespaces only. Now, let’s see how we can repair as many defects as possible with an Emacs function.

Read the rest of this entry »


Finding dependencies for Make

April 25, 2017

How hard is it to get dependencies for your project to use in a Makefile?

Well, it depends.

Read the rest of this entry »