Adding Keywords in Emacs

02/03/2010

As you already know—if you read my blog before—I use Emacs as my primary editor, for C, C++, Python, LaTeX, etc., and I’ve grown fond of the clunky ol’ piece of software. Still, once in a while, I need an extra, potentially weird customization.

Read the rest of this entry »


Computing the Neutral Zone

23/02/2010

Have you ever add to decide, you and your colleagues, where to go for lunch? Each time, it ends up being a committee, of course. It gets even worse when not only you have many colleagues, but also two offices, or two groups, at different locations. Since we work in a rather large city, we want to walk to the chosen restaurant, rather than drive, but in a way that is fair to either group.

So to settle the argument about where are the restaurants midway of both locations, we need a map, and some math.

Read the rest of this entry »


Bad Laptop Colors: Why?

16/02/2010

In Calibrating your LCD for Better Results I presented a few techniques to adjust your LCD so that you get better colors, even though it’s not a perfect calibration.

I have a couple of laptops and their screens aren’t all equal. Not all all. The Vaio gives beautiful, vibrant colors. The Dell Mini 10 HD also gives rather cromulent colors. The E6500, on the other hand, is dreadful. Not the whole computer of course, because otherwise it’s a rather good machine. But the screen is just disappointing. And the thing is, you can’t adjust anything besides the brightness—which defaults to blinding bright. What would it take to make such a screen acceptable?

Read the rest of this entry »


Sohcahtoa!

09/02/2010

Mathematics can ask you to remember things that have no obvious connection to common sense. Either because it’s arbitrary (the name of a function in respect to what it computes) or because you haven’t quite figured all the details out. In either cases, a few mnemonics are always useful!

Read the rest of this entry »


Features I’d like to see in my Editor.

02/02/2010

Do you ever have pipe-dreams about what you should be able to do with your computer? Like those crazy virtual interfaces like they had in the movie Minority Report or like every CSI lab seems to have? (well, that’s at the movies, of course). What about just more down-to-earth matters such as making large, complex documents such as source code more legible? I have few ideas—maybe a bit wacky.

Read the rest of this entry »


Those Pesky Applications!

26/01/2010

Regardless of which operating you’re using, you’re bound to encounter applications that cause you problems. Some applications cause you problems so often that you eventually place a custom launcher or even a keyboard short-cut to a command that kills the applications. Firefox used to be one, but since version 3, it’s been much better. I still have problems, though now it’s always related to the Flash plug-in (which is rather troublesome in 64 bits mode). Another one that cause me problems regularly, is EvilEvolution, the Exchange client for Linux.

Young_Folks'_History_of_Rome_illus216

One essential *nix command you should know, is kill. The kill command dispatches a signal to a process, by default, SIGTERM. This message instructs the process to terminate. It can ignore the signal, but in general, it will close gracefully after freeing resources. If the program ignores the signal or is in an unstable state, you can kill it “harder” by using kill -9, which sends the process an unmaskable SIGKILL. The process terminates instantly under most circumstances.

Read the rest of this entry »


Bundling Memory Accesses (Part I)

19/01/2010

There’s always a question whether having “more bits” in a CPU will help. Is 64 bits better than 16? If so, how? Is it only that you have bigger integers to count further? Or maybe more accessible memory? Well, quite obviously, being able to address a larger memory or performing arithmetic on larger number is quite useful because, well, 640KB isn’t all that much, and counting on 16 bits doesn’t get your that far.

AMD Phenom

But there are other advantages to using the widest registers available for computation. Often, algorithms that scan the memory using only small chunks—like bytes or words—can be sped up quite a bit using bundled reads/writes. Let us see how.

Read the rest of this entry »


Why Validating Input so Hard in C?

12/01/2010

Validating input from file or keyboard is probably the most difficult thing to get right in C. Not only is it difficult to get right regardless of the programming language, C really doesn’t do much to help you. There’s the standard library, mostly accessible through the two headers <stdlib.h> and <stdio.h>. However, the facilities provided by the C library are rustic at best. They haven’t aged well, and they’re clunky.

Rusty_pincers-small

For this post, I will limit I/O validation to grabbing input from text files, whether through a redirection, pipe, file, or console input. I may discuss binary or highly structured formats like XML in a later post, but let us first limit ourselves to a few simple cases.

Read the rest of this entry »


Stir Fried Stupid

05/01/2010

A well structured library will contain functions that are grouped together in a same logical unit to help you perform a set of tasks more easily. This could be reading graphics files, or managing time and dates. Good libraries include just enough functions so that you have access to the complete functionality, but nothing superfluous.

Too often, libraries catch featuritis and grow large with less used functions that were added at some point to scratch a minor hitch. Worst, you discover functions hidden in a library that you’re not sure what to do with them, but sometimes, you find functions that are positively stupid. What is even more surprising is where you can find them. I found a couple in the GNU C Library.

Read the rest of this entry »


Channel Mixing and Pseudo-Inverses

29/12/2009

Let’s say we want to mix three channels onto two because the communication device has only two available channels but we still want to emulate a three channel link. If we can afford coding, then it’s not a problem because we can build our own protocol so add any number of channels using a structured data stream. But what if we cannot control the channel coding at all? In CDs, for example, there’s no coding: there are two channels encoded in PCM and a standard CD player wouldn’t understand the sound if it was encoded otherwise.

The solution is to mix the three channels in a quasi-reversible way, and in a way that the two channels can be listened to without much interference. One possible way is to mix the third channel is to use a phase-dependant encoding. Early “quadraphonic” audio systems did something quite similar. You can also use a plain time-domain “mixing matrix” to mix the three channels onto two. Quite expygeously, let us choose the matrix:

M=\left[~\begin{array}{ccc} \frac{2}{3} &0&\frac{1}{3}\\ 0 &\frac{2}{3}&\frac{1}{3}\end{array}~\right]

Read the rest of this entry »