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 »
5 Comments |
hacks, Life, Mathematics, Zen | Tagged: cosine, Euler, hidari, mitsudomoe, mnemonics, Pi, Sine, sohcahtoa, tangent, trigonometry, unit circle |
Permalink
Posted by Steven Pigeon
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 »
5 Comments |
emacs, hacks, Inoffensive Rant, Life in the workplace | Tagged: brackets, CSI, emacs, parentheses, scope, syntax highlighting |
Permalink
Posted by Steven Pigeon
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.

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 »
Leave a Comment » |
Bash (Shell), hacks, Inoffensive Rant, Life in the workplace | Tagged: custom launcher, Evilution, Evolution, Firefox, Gnome, killall, launcher, microsoft exchange, npviewer.bin |
Permalink
Posted by Steven Pigeon
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.

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 »
7 Comments |
algorithms, C, C99, CPU Architecture, embedded programming, hacks, Portable Code, programming, Unit Testing | Tagged: C99, CISC, GNU Lib C, memfrob, memory, memory bandwidth, memory usage, movsb, movsw, Unit Testing |
Permalink
Posted by Steven Pigeon
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 »
2 Comments |
C, hacks, Life in the workplace, programming | Tagged: GNU, gnu C library, memfrob, strfry, stupid |
Permalink
Posted by Steven Pigeon
22/12/2009
The other day—well, a year ago or so—I was invited to visit CBC’s digital TV studios in Montréal by the SMPTE Montréal. We were shown around, even in the somewhat small control rooms. Amongst all the displays, dials, monitors, and misc. blinkenlights, I noticed a small LCD display showing an hexagonal projection of the current show’s color gamut in
(or maybe
?), probably for quality assessment purposes. I thought it was pretty cool, actually.

Let’s see how we can realize this projection with as little CPU time as possible.
Read the rest of this entry »
1 Comment |
algorithms, bit twiddling, C, embedded programming, hacks, Mathematics, programming | Tagged: animated gif, blinkenlights, camel, CBC, colorspace, digital tv, DTV, folding, folding function, gamut, gif, pairing, pairing function, real time, realtime, realtime rendering, rgb, studio, tuple, tv studio, ycrcb |
Permalink
Posted by Steven Pigeon
18/12/2009
A few days ago, I changed my machine and upgraded to Ubuntu 9.10 (Karmic Koala) and everything went fine, except for the screen-saver that would activate properly but not switch the screen into sleep mode after a while. I found a couple of fixes because despite being a documented bug, there’s not definitive fixes yet.

Read the rest of this entry »
Leave a Comment » |
Bash (Shell), hacks, Life in the workplace | Tagged: Annoyances, DPMS, Eclipse, Icons, Karmic Kaola, Koala, Moon, screen-saver, screensaver, X, X11 |
Permalink
Posted by Steven Pigeon
08/12/2009
Certain numbers keep showing up in nature. The Golden Ratio,

is one of them. It shows up in cats, sunflowers, and Egyptian pyramids.

Read the rest of this entry »
10 Comments |
hacks, Inoffensive Rant, Life, Mathematics | Tagged: Ancient Egypt, apophenia, archeology, Cat, Cats, Egypt, Giza, Gizeh, golden ratio, Golden Section, Great Pyramid, Kheops, numerology, Pet theory, Phi, Pyramids |
Permalink
Posted by Steven Pigeon
17/11/2009
The C (and C++) preprocessor is a powerful but dangerous tool. For sure, it helps with a number of problems, from conditional code inclusion to explicit code generation, but it has a few problems. In fact, more than a few. It is evil.

The C preprocessor (hereafter CPP) should be used with extreme care. For one thing, the CPP doesn’t know about the language it is applied on, it merely proceeds to the translation of the input using very simple rules, and this can leads to tons of hard to detect—and to fix—problems.
Read the rest of this entry »
10 Comments |
C, C99, hacks, programming | Tagged: #define, #ifdef, #undef, bug, C, C Preprocessor, C99, cpp, eviiiiiiil, eviiiil, evil, macro, operator precedence, sequence point, translation unit |
Permalink
Posted by Steven Pigeon
10/11/2009
Python is a programming language that I learnt somewhat recently (something like 2, 3 years ago) and that I like very much. It is simple, to the point, and has several functional-like constructs that I am already familiar with. But Python is slow compared to other programming languages. But it was unclear to me just how slow Python was compared to other languages. It just felt slow.

So I have decided to investigate by comparing the implementation of a simple, compute-bound problem, the eight queens puzzle generalized to any board dimensions. This puzzle is most easily solved using, as Dijkstra did, a depth-first backtracking program, using bitmaps to test rapidly whether or not a square is free of attack1. I implemented the same program in C++, Python, and Bash, and got help from friends for the C# and Java versions2. I then compared the resulting speeds.
Read the rest of this entry »
88 Comments |
algorithms, Artificial Intelligence, Bash (Shell), bit twiddling, C, data structures, hacks, programming, Python | Tagged: Artificial Intelligence, backtracking, bash, C, Chess, chess problem, chess puzzle, constant propagation, constant-folding, eight queens, eight queens problem, eight queens puzzle, g++, gcj, gmcs, java, puzzle, pygame, Python, python 2.6, recursion, recursive algorithm |
Permalink
Posted by Steven Pigeon