Category Archives: Programming

Programming by Intent via Automatic Search and Function Binding

There’s a problem with Matlab. Even though it’s great for high-level programming, it just has too many functions, of which even the most seasoned developer is doomed to know only a small fraction. For example, the function pdist will return a matrix of pairwise distances, yet I’ve seen the same being done manually countless times.

Rather than cutting down the functionality provided by the language or forcing the user to “specialize” in studying certain Matlab functionality, I thought of an alternative approach:

The user knows what he wants to do. He wants to “compute the pairwise distance between observations in matrix A”. At this moment, his best bet is issuing the command “lookfor pairwise” and sifting through the results.

But wouldn’t it be nice if he could type “I want to compute the pairwise distance between observations in matrix A”, and, based on the documentation and some tagging of the functions, Matlab would automatically fill in “pdist(A)”?

This can apply to any language, of course. Java seems another good candidate, given the number of standard classes in J2SE.

Does the disk matter as much as the filesystem?

It seems, at least in the case of NTFS and ISO9660, that the filesystem is actually more of a bottleneck than the disk itself. Lots of small files can cut the transfer speed down by 2-3 orders of magnitude, even down to about 100 KB/sec. Linux filesystems seem to do much better on small files, but it makes me wonder what particular access strategy is causing the bottleneck.

The data should even be sequential on disk, making this all the more puzzling.

Solution: KDM launches an xterm at login

I just upgraded my old system and ran into an issue where KDM would launch an xterm rather than executing startkde when logging into a KDE session (and would perform similarly when any other session was selected).

I spent hours troubleshooting this problem and checking that all of the config files were correct. They were.

Finally, I realized that KDM may be reading kdmrc as root, but may be trying to execute the Xsession script as the user that is logging in.

The /usr/share/config directory was currently mode 700. I chmodded it to 705 and the problem was resolved.

Moral: if everything else seems right, check your permissions.

DigitalPersona Firefox Extension Prevents Clicking on Executable Links

When a company fails to disclose a location to which bugs in its products can be sent, I’ve made it a habit of posting them here instead. Somehow, this strategy tends to get a response. Also, this helps others avoid going through what I had to in order to debug the problem.

I recently purchased a new HP laptop with an embedded Validity fingerprint reader. Upon installing Firefox, I noticed that executable links were not working properly – they were not being followed. At first, I chalked this up to AVG 8, as it has some new (buggy and slow) “linkscan” feature, but uninstalling and reinstalling AVG and Firefox yielded no luck.

Finally, I looked on the list of add-ons to see whether there was something there that could be causing this problem. DigitalPersona’s add-on was the only one present.

I tried disabling it and suddenly the links were working again. Re-enabling it caused them to stop once more.

Thus, there is something in the DigitalPersona Firefox extension that is causing the browser to cease following executable links.

Fortunately, right clicking and selecting “save as…” still works, so I’ll use that as a workaround for the time being.

And to DigitalPersona: Provide a forum for users to submit bugs or those bugs will not only never reach you directly, but will be scattered all over the Internet for everyone to read. One way or another, people post them. Far better for you that they reach your ears first.

Dual-Locking Critical Sections

One potential way to avoid deadlocks would be to unlock critical sections if the main lock controlling the section was unlocked OR if another lock indicating the resource was unavailable was unlocked. The program could then deal with the case that the requested resource depends on another locked resource without locking up.

Learning Teaching

Seems almost like an oxymoron, doesn’t it? Of course, far from being antithetical, teaching and learning go hand in hand. I’ve learned quite a bit from teaching, not all of it related to the subject I was teaching. But I’ve come to a conclusion I’m a bit ashamed to admit: I’m not yet a very good lecturer.

On my good days, I can be excellent. I thought I did a great job on the hash table lecture. Other times I think my wording was very off but the students seemed to enjoy it nevertheless, such as with Huffman coding. And then there are just times when I know I’m doing a bad job of explaining something, yet all I can do is forge ahead and try to do my best. On paper, the presentations all look great. Verbally, however, I can talk too fast, I can select a poor choice of words, I can sound repetitious, I can sound like I’m emphasizing the wrong points, and so on…

I still have a really good excuse for this pattern: it’s my first semester teaching. I still don’t know how best to structure a lecture, how to present that lecture, what pace to set, etc., because I just don’t have enough student feedback to see what is working yet. There’s also the issue of my tight schedule occasionally interfering with my ability to prepare the lectures as long as I would like.

But I’m going to be teaching the course a second time in the Spring, and by then, I’d like to have this down a bit better.

I think the students like me, at least; partially on account of my age – I’m not much older than they are, so I innately understand them a bit better – but also due to my approachability and refusal to put people down. But though that is a necessary condition for student learning (students pay much more attention to you when they respect and admire you), it is far from sufficient. I need to work on my teaching skills more.

Using a cell phone as a modem.

This is probably obvious to some of you already. For the others, perhaps this is informative and/or neat.

I was tinkering with my cellphone’s Bluetooth connectivity today and found out that you can map serial ports to the phone. Curious, I opened up PuTTY and typed in “ATDT <my phone number>”…

And it began to dial.

Quite a bit of nostalgia… and it technically means you can make fax and data calls out with the phone too. Sort of like having a modem + phone all in one.

Unfortunately, this being 2008 and not 1995, there isn’t much use for that anymore 🙂

So much for that.

I think I’ve found a way to condense about twice the material normally presented into a CS class. Unfortunately, everyone just thinks I’m overestimating the students’ ability. Perhaps that’s true, perhaps not, but now there is no way to tell. Worse, there’s no way to pick out the students who would excel in such an environment.

How are new educational methods tested, if not in a classroom? How will the system ever improve?

Why am I the only one who cares?

*Shrug* No choice but to see how it works. Maybe the students really don’t have the potential I give them credit for. It is my first time teaching, after all.

Seeing possibilities is so incredibly frustrating. Anyone who thinks it’s a picnic doesn’t do it very often. My life isn’t easier for it. Quite the contrary: I’ve probably exhausted several typical lifetimes of mental anguish, and I haven’t even broken 25 yet.

Algorithmic complexity curves can be shifted.

It is theoretically possible to construct an algorithm with a complexity growth curve that is shifted on the x axis. In other words, you might get part of the left side of a parabola as well as the right for an O(n^2) algorithm if the algorithm happens to have a particular value of n that it performs best at were you to graph the algorithm’s runtime.

This is a fairly unimportant point, but it’s one that traditional algorithmic theory doesn’t really touch upon.