Thursday, November 27, 2008

Ruby on Rails : Get Next ActiveRecord Element?

Ok, file this one under "surely there's a way to do this that I'm just missing."

You're in a typical scaffold where you've gotten your list of Widgets, and now you're on /show/ for a particular Widget, say maybe #123. What I want to say on that page, with only the single Widget#123 for context, "go on to the next element." Or the previous one. You can't do it strictly by ID, because your IDs might not be continuous (i.e. the next one from 123 might be 125).

Anybody got the trick?

Thursday, November 20, 2008

Prototype This

Is anybody but me watching this Discovery Channel show? It's my new Mythbusters / Junkyard Wars, I absolutely love it.

The premise, set within the first 5 minutes, has a handful of engineers brainstorming a real physical world problem. Previous examples have included a "traffic busting car" that would actually rise up on stilts to drive over traffic jams, telepresence "boxing robots" for the videogame of the future, and right now I'm watching them build a robotic firefighter.

They then set about solving the problem. The engineers include a mechanical / robotics guy, an electrical engineer, a software guy, and somebody else who at the moment escapes me.

It is a fascinating look at what it means to prototype, particularly in the real world (as opposed to just a software prototype). They're trying to solve a real problem. They look at the constraints of physics, but not necessarily of cost. In other words, they focus on the variables that cannot be changed, knowing that the others can. They use whatever new technology they want. They typically have a fixed time window of 2 weeks to solve the problem, to keep them from just brainstorming it forever and never building anything.

The end result is always fascinating. It works. It's more than a cobble-together, but not the kind of thing you'd say "Oh yeah, I'll buy that." But what they do is prove a concept. They actually made a car get up on stilts (automatically), and drive over traffic. It even parked itself sideways, very impressive.

Right now I'm watching the robot firefighter episode and it's just all the more impressive. They train with firefighters to appreciate the problems, which include things like monitoring oxygen levels, finding victims in a dark room, and getting equipment up the stairs. They then go about trying to improve conditions for the fighters by creating some assistive devices, such as a heads-up display that shows oxygen levels and includes a thermal camera. If someone took half these ideas and made them real, it would make a serious improvement to a very real problem.

Tuesday, November 18, 2008

Being Unprepared Stinks

I'm having a weird week already. There's a technical conference here in town, and I registered and paid long ago. In a truly strange case of odd timing, I got laid off literally a week before the conference, while my reimbursement check is still pending in the system. Company was cool, though, and said that since it was approved by a manager while I was an employee that they would pay it.

So on the one hand, free conference. It's no longer my job, and I can skip if I want, but it is "my thing" and it's a nice excuse to get out of the house and hang with geeks. In theory it's a good networking opportunity.

But on the flip side I need a job. Staying away from my cellphone for 3 days is not exactly a great idea, either.

Long story short, I decide to go. I basically need to get there before 9am if I'm to register and get into the keynote.

I leave at 7am. Problem #1, there is a big accident on Rt93 that takes up an hour of my commute just to go three exits to the train station. I'm not kidding. Decision time -- do I take the 8:15 train, which guarantees to not get me to the conference until 9:30? Or do I assume that the traffic is now broken free, and I've got an hour to get into town? I choose to go for the drive.

Problem #2: Bad gamble. I end up driving for another hour, and literally do not get out of my car until 9:15 anyway. I have parked according to my original plan, which is to drive in and park in my former work neighborhood, where I'm familiar with the traffic patterns, planning to walk the less than 1 mile to the conference.

Problem #3: I basically end up getting to the conference at 9:45. I have completely missed breakfast, and catch the keynote sitting in a corner and trying not to draw attention to myself.

Problem #4: In my hurry to get out of the car and get going, I have forgotten my glasses. So I can't really see any of the presentations at all. Not a problem, as this is a programming conference and every single person including myself has a laptop.

Problem #5: This is my wife's laptop that I am using as backup, since I lost my old machine when I got laid off. The programming environment, that I have set up in a hurry in anticipation of exactly this moment, is not complete.

Problem #6: I cannot get on the net. My iTouch gets on just fine, so I can check email and Twitter, but I can't get the laptop connected. I believe it's because of the old wireless card in there, which is probably still doing 802.11b, and the hotel is not broadcasting B anymore.

So: I'm starving, I haven't met anybody to talk to (having missed the breakfast mingle time), I can't follow the presentations, and I can't do anything meaningful on my laptop. I ended up going home before lunch.

Tomorrow shall be different. I've updated my programming environment and put in a new wireless card. I'll make darned sure to pack a breakfast for myself, remember my glasses, and take the train instead of trying to beat the traffic. I expect it to be 100% better.

Wednesday, November 12, 2008

Oh to be unemployed, now that Christmas is here

Well, as of 9:45 this morning I'm officially unemployed.  It wasn't a complete surprise, the boss was nice enough to let me know a few weeks in advance and I was able to clean out my desk and get personal files off my computer with time to spare.  But, still, being unemployed is no fun.

Thursday, November 06, 2008

Blinking Numlock / Capslock

So I'm trying to bring the old laptop (a pre-1999 Thinkpad 600e) back to life for the kids to play with.  Having the weirdest problem.  No matter what Linux I try to apply (always booting from CD, as this bios does not allow booting from USB) hard crashes and leaves me in a state where the numlock and capslock keys are blinking.  Googling around tells me that this is a "kernel panic" crash, but what I can't figure out is what is crashing. 

I have tried Puppy, Ubuntu, Knoppix and Nimble, either installing to hard drive or just running from CD, whichever was appropriate, and every single one of them exhibits the same failure.

I have already swapped out the hard drive, but that did not fix the problem.  I have not yet run the memory test, but I'll do that next.  I suppose if that passes, and it's not the HD (I did the BIOS test of the HD and that works, so I'm presumbing that the controller works as well) I guess I'll have to chalk it up to something in the motherboard, give up and throw the whole thing away.  That'd be a shame, I've kept it this long :).

Absolutely last ditch effort would be to put the hard drive into my other, modern, working laptop.  Then use USB/CD to install Ubuntu or some other directly onto the hard drive, then put the hard drive back into the old machine and see what happens.

Monday, November 03, 2008

Hey Look, A Political Bug!

This is a new one on me.  The date widget we've been using (I don't have the exact library handy to blame), actually repeats a day the first weekend of November.  So this year for instance, Sunday and Monday both show up as Nov 2.  Every year it's always November, and it's always the first weekend.  We just found it so we haven't yet determined the cause, but guesses range from daylight savings time to leap year to rounding issues.

I like the theory that it's politically motivated, to make people think that November 4th (voting day!) is actually Wednesday.