Polyfitting and Vector Reversal in Matlab

I’m currently taking a course in data mining and matrix methods, and we use matlabs for our lab assignments. We have probably spent half of our time figuring out how to do certain things in matlab, and the other half actually learning what we’re supposed to learn.

One problem we had was that we had a vector of coefficients for a polynomial, and we wanted to plot a graph of it, this gave us a few headaches.

First of all, how do you plot a polynomial? polyfit does that, as we figured out, and then one can use plot to plot the points given.

Using SVN with svn+ssh with multiple users while keeping appropriate file permissions.

If you’re using SVN and accessing the repository through ssh using svn+ssh it might be the case that one user creates a file with file permissions that disallow other users from checking out/committing. I managed to solve this problem by first creating a new user group (addgroup group) and then adding the users to that group (addgroup user group), finally i did chown -R oneuser:group /path/to/repository and chmod -R 2770 /path/to/repository. I’m actually not exactly sure how the “2” behaves, but it fiddles with the umask so no problems of this kind occurs.

Two useful bash settings

  1. bind "set completion-ignore-case on"
  2. bind "set mark-symlinked-directories on"

I’ve been using completion-ignore-case for a while, it auto completes without taking case into account. This is great most of the time, but one issue that comes up every now and then is that using wild cards will only match the specified case, that is c* will only match files starting with a lowercase c, so the command will have to be invoked with both c* and C*.

The key to lighty is proxying

If you’re using rails, you can proxy through mongrel to get your rails app up and running (typing mongrel_rails start is the only “configuration” you need apart from the proxy setting in lighty), and if using trac, tracd makes it a piece of cake. And here I’ve been trying to configure lighty itself to do the hard work. Judging by the information available, others try as well, and publish their somewhat working result, confusing everyone else. Oh well.

Null Values

Earlier I complained about the fact that function parameters are never constant by default. I do not know of any non-functional language that hasn’t made this mistake (this of course not being an issue in a functional language since everything is a value — immutable.)

Another common decision that I think is even worse, and might be the worst feature of these languages is null. null is treated as an object by the compilers/interpreters, but the programmer can not treat it as such.

This means that anywhere you can put an object, you may also put null.

Inconsistent implementation of the for ... in loop.

I ran into a hard-to-find bug today. After a while I figured out that IE cleared one of my hashes, for seemingly no good reason. This was my code:

  1. for (var p in hash) {
  2. hash["x_" + p] = hash[p];
  3. delete hash[p];
  4. }

I actually didn’t manage to reproduce this behavior outside of my original script, instead IE would go into an infinite loop and rapidly claim all available memory when the code ran.

Dynamic Binding - Confusion!

What's "dynamic binding"?

Mr. Martin Fowler & Objectivity

Martin Fowler has been one of my favorite authors for a while now, I started out by reading Refactoring (though I should probably have read it a year earlier to get the most out of it), and later moved on to Patterns of Enterprise Application Architecture. Right now I'm skimming through UML Distilled, I've mostly used class and sequence diagrams in the past, so I thought I'd check out what else UML has to offer.

Magic Conventions

What makes an awesome framework? A lot of things obviously, but one particular thing is how much magic it does.

I was amazed at the magic going on in Rails the first time I looked at it. ActiveRecord automatically knew which tables my classes mapped to! It automatically gave me handy functions, (ar.foo for regular attributes and ar.foo? for booleans, for instance). Specifying (basic) validations was a piece of cake. Adding relations to other tables was also super easy. It also automatically located the ID column of my tables.

Constant Arguments

I just started thinking, why do pretty much all languages define arguments as regular variables instead of constants? The way I see it, the most common feature should be the default behavior, and how often do you need to (or more importantly, “should you”!) change the value of an argument variable? I can’t think of a single time that I’ve done so with a good reason. With some languages (like the simple Scheme interpreter, %scheme, we’ve implemented reading our SICP-based course) it’s simply easier to omit the use of constants altogether. We did it

Syndicate content