Saturday, May 24, 2008

Programming is pain (sometimes)

Last night I went to bed completely frustrated. I had spent probably 6 hours staring and poking at a piece of code and thinking what on earth could be wrong with it. It seemed functionally identical to the code I had been using as a guide, yet it didn't work. It didn't do anything - generate error messages, any messages at all - it just got silently ignored by the framework. Why, why, why, is all I could think about before going to bed.

But what I've learned and seen reinforced over and over again is - if you get completely stuck, step away from the problem for a while. Take a nap or a shower or watch a movie or do something to take your conscious mind away from it. Sure enough, when I woke up and went back at it, less than 1 hour in I spotted the discrepancy. I had a function included in a class definition, while my example code had the function outside the class. So I took it outside and hey presto it worked perfectly.

It still sucked though to have to go through all that frustration.

projectM - Finally audio visualizations for Amarok

The one area where my trusty WinAmp had Amarok licked was visualizations (although Amarok outshines it and nearly everything else I've tried in most every audio library category.)

Enter projectM :

projectM is an LGPL'ed reimplementation of Milkdrop under OpenGL. All projectM requires is a video card with 3D acceleration and your favorite music.

FINALLY I could get trippy fullscreen milkdrop visualizations. I talked about how I pulled libvisual-projectm from Debian lenny here. The two gotchas I had with getting the libvisual-projectm plugin to work with Amarok are:

  1. The config.inp file projectM drops in your home points to fonts from ttf-bitstream-vera - Vera.ttf and VeraMono.ttf. If you don't have these fonts installed then all you will see when enabling the plugin under Amarok is a brief projectM window flash and then disappear. You can get these fonts in debian by installing the ttf-bitstream-vera package. In theory you should be able to modify config.inp to point to whatever fonts you want but this runs into the second issue:
  2. Currently libvisual-projectm appears to ignore some parts of config.inp I got it to set directives for Preset Duration but it ignores other directives like Window Width and Fullscreen and FPS.
No biggie, but it is kind of irritating to have to resize the vis window to 640x480 and then right click in, whenever I want fullscreen visualizations. But milkdrop is so worth it. Maybe these issues will be resolved with the 1.1 release of projectM which I'm soon to build and install.

Friday, May 23, 2008

Great moments in Views 2 coding history

After scrabbling through source files and scrutinizing tantalizing yet incomplete docs, I finally got Views 2 to disdainfully acknowledge that yes, I was in fact a views style plugin.


Wednesday, May 21, 2008

MAN U 6 - CHELSEA 5 PK

To quote Vincent Vega, now if you'll excuse me I'm going to go home and have a heart attack.

Saturday, May 10, 2008

Getting fresh meat for Debian Etch (and solving the Dynamic MMap ran out of room problem)

Oddly enough the I don't recall ever installing anything from the Debian testing repository so far, but an opportunity presented itself when I discovered projectM. Getting projectM to work in Amarok is another story but for now, just the details of the pull from the testing repository:

1. SOP - Just add deb http://ftp.debian.org/debian/ testing main non-free contrib to sources.list in /etc/apt. I also added deb-src http://ftp.debian.org/debian/ testing main non-free contrib which probably contributed to the problems I had later.

2. Run apt-get update. Processed and downloaded the repository packages' metadata fine, until it ran into:

E: Dynamic MMap ran out of room
E: Error occured while processing sqlrelay-sqlite (NewPackage)
E: Problem with MergeList /var/lib/apt/lists/ftp.us.d.........contrib_binary-i386_Packages
E: The package lists or status file could not be parsed or opened.

So I googled the error and found a partial solution at the cached version of http://jaqque.sbih.org/kplug/apt-pinning.html:

You may find that you receive an error like the following:


E: Dynamic MMap ran out of room
E: Error occured while processing sqlrelay-sqlite (NewPackage)
E: Problem with MergeList /var/lib/apt/lists/ftp.us.debian.org_debian_dists_woody_contrib_binary-i386_Packages
E: The package lists or status file could not be parsed or opened.

This is caused because apt's cache is too small to handle all of the packages that are included with stable, testing, and unstable. This is also very easy to fix. Add the following line to /etc/apt/apt.conf

APT::Cache-Limit "8388608";

Thanks to R (Chandra) Chandras for pointing out this problem

Now it turns out in my Etch there is no apt.conf...there is an apt.conf.d directory with two conf files containing directives. So I followed the pattern, named mine 80aptcache.conf and added the CacheLimit directive above. However I had to set it to some insane high value - 200000000 (I suspect because of including the src packages) to finally get apt-get update working. But it did work and I got a the 1.01 version of libvisual-projectm. How I got that to work with Amarok is another post for another day.

Thursday, May 08, 2008

Setting up sudo

su and sudo don't come setup out of the box with Debian Etch (for good reasons I guess) so I had to set it up myself. The way I want su and sudo to work is:

Let me run any command as root, but only when I supply the root password
Always prompt me to supply the root password. This is different from the default sudo behaviour.

The example sudoers files I dug up on the net were complex, but didn't really answer my query about how to run it as described above so after some digging and head-scratching this is the sudoers file I came up with (you only edit sudoers with the visudo command):

Defaults env_reset,runaspw,timestamp_timeout=0

# User privilege specification
root ALL=(ALL) ALL
myuser ALL=(root) ALL

The syntax for each line in sudoers is:
initialuser network = (targetuser) commands
The initialuser is the logged-in user who will be sudo'ing to the targetuser. In this case it's a user called myuser so replace that with the user you login as. By specifying ALL you're allowing the user to sudo on any network interface currently active. (root) means you want to run as the root user and ALL means you can run any command as root.

Thre are two important additions to the Defaults entry. runaspw indicates that you want to be prompted for the targetuser's password, not your own. timestamp_timeout=0 means that everytime you sudo you will have to provide the password; otherwise you will be allowed for a certain time to perform su without requiring the password prompt.

For a single machine with mostly a single user this is a useful sudoers setup. If I feel the need to add anything more useful I'll post it.

Links:
http://www.gratisoft.us/sudo/man/sudoers.html man page for sudoers
http://www.sudo.ws/sudo/sample.sudoers Example sudoers file

Saturday, May 03, 2008

Happiness is DIY computing



Finally exams are over...what an ordeal. I'll have to do over Combinatorics in the summer or next year. It's a really interesting course but I didn't put nearly enough work into in this semester to pass.

So, de-stressing now, I got to tinkering with X-MAME. I finally got it up to it's proper performance by using the OpenGL mode of the xmame-x11 build, instead of the xmame-SDL I was using. I was getting horrible framerates even though the box I'm running on is powerful enough (1 GHz + nvidia GeForce 440MX) to run most everything full throttle.

This experience is one of many that reinforces for me the difference between open-source computing vs. Windows or Apple. It's pure DIY fun. Setting up the Linux box will eventually become my multimedia/retro-gaming machine took a lot of head-scratching and researching on the web and experimenting, but I have got it tweaked perfectly to the point where it's a lot better that it would be under Windows. Every time I look for an open-source alternative to a piece of Windows software, like a video player - I've rediscovered the same principle - it takes more time to tweak and setup properly FOSS software, but in the end it will have way more technical capability than the Windows variants.

So if you just love fiddling and digging into computers, FOSS is the only way to go.