Thursday, November 29, 2007

ActiveRecord Columns

It can be hard to keep up on side projects, there are just so many other things around the house demanding attention. This week, I've been spending my time demolishing a brick BBQ/planter in the back yard. I've removed 3 cubic meters of dirt and brick! Last night I finished that, so I started to think about the side project I'm working on. As I did, I thought back to the WTF moment I wrote about a while ago, and I was afraid that I was wrong. Totally wrong. Idiotically wrong in a way that would demonstrate that I am a complete total and utter Ruby on Rails noob.

It's interesting about blog posts. I've added Feedburner so I have a bit better an idea of how many people are reading this. Before, I thought it was just a couple of friends and then only when I bugged them, "Hey, did you see my new post?". Now, it seems I have a readership (albeit minimal).

That means that any mistakes I make here are really, really public and enduring. Of course, for me that's part of the point of the blog. I want to be able to go back and see how my ideas change over the years.

Anyways, back to Rails. I was afraid that this code was wrong:

def update_my_status(user, status) if (a_party == user) self.a_party_status = status else self.b_party_status = status end end

I was sitting there thinking, "Wait a second, Ruby says that data members have an '@' in front of them!", quickly followed by, "Nuts, so, do I edit or delete the previous post?"

Just to be sure, I went and fired up the rails console. Very, handy, much recommended. I modified the code to look like this:

class Call < ActiveRecord::Base def my_status(user) if (@a_party == user) @a_party_status else @b_party_status end end ...

I then called it in the console:

>> call = Call.find(:first) => # >> call.my_status(2) => nil

Whew, off the hook. It seems that Ruby has "method missing" functionality, but not "member missing" functionality. So, when I put an '@' in front of it, ActiveRecord doesn't know to look up the value in @attributes. Interesting, and a bit more learned about the internals of ActiveRecord and Rails.

Wednesday, November 14, 2007

Lying, redux.

Happened to me today:

"The NFS mounts are all broken, what's changed on the server?"
"Nothing"
"Well, obviously something's changed, or else it would work. What's changed?"
"Nothing"
...
Several more times back and forth...
"Listen, it's pretty [bleeping] obvious that you have [bleeping] changed something. What the [bleep] have you changed so that I can fix my [bleeping] systems and get some [bleeping] work done!"
"Take a chill pill, and relax dude!"

Bull? Meet Mr. Red Flag.

The actual problem? They changed the directory layout of the NFS mount, so everything moved around. Amazingly, he was surprised when everything stopped working.

Lesson? I need to realise that although the guy is lying his ass off, I need to walk away instead of rubbing his nose in it. I'm not going to get a resolution. I need to follow my own advice, and give people back their monkeys.

So, in the future, I'll just send a polite email (CC'ing my supervisor, and their supervisor), explaining why no one in the entire support organisation is able to get any work done. Hopefully they'll get it resolved by the end of the day.

Oh wait, just yesterday I gave someone advice because they had a technical manager doing exactly that! What did I say? Oh yeah, "He's looking for a reason to slip his project and he's looking to blame you. He should know how to manage his own development systems."

So, either I look like a dick because I put the beat down on some poor overworked IT guy who seems to have been here late screwing it up in the first place (and then bald-faced lying about changing anything), or I look like a dick because I'm looking to blame someone for my schedule slippages.

Hmm. I think I'll walk away and talk to someone else in the team next time. That guy has managed to flip my idiot bit.

Monday, November 12, 2007

Google's Android

I was looking at the docs for the SDK today. I'm interested to see if I need to get an OpenMoko to play with this sucker. However, I haven't been able to find the OS itself, just references to the eclipse plugin.

Even worse is this quote from the FAQ:

Android does not currently support development of third party applications in native code (C/C++).

Not as open as we had all hoped. I'll keep looking, I hope it gets better.

Sunday, November 11, 2007

Recovering a corrupted Akregator feed list

Akregator has an annoying habit of losing your configured feeds when it shuts down abnormally (as in whenever it's "killed"). It's supposed to have a backup of the file, but it manages to truncate that file too.

However, I've found a second backup of the file, ~/.kde/share/apps/akregator/Archive/feedlistbackup.mk4 It contains some binary data at the top, and then appears to have a several different versions of the opml file.

To recover:

cd ~/.kde/share/apps/akregator/Archive/
cp feedlistbackup.mk4 ../data/protect_my_backup
[shut down akregator]
cp feedlistbackup.mk4 feeds.opml
vi feeds.opml
[remove the binary data at the top of the file, leaving the XML declaration tag and the <opml>...</opml> section. Remove everything from the first </opml> to the end of the file.]
[restart akregator]

Just remember, copy the file as soon as you see the problem, if you shut akgregator down, it will overwrite the backup file when it manages to exit properly.

If that "feedlistbackup.mk4" doesn't look right, you can always try to recover the opml file from the list of sites in the archive. However, it won't be organised into folders, and it will probably have all the feeds you have ever subscribed to.