prototype form serializer gotcha

In learning JavaScript / AJAX, I’ve been using the Prototype library, and I’ve been really happy with it.  It’s quickly gotten me able to wrap my head around what the possibilities are, as well as providing some good docs with great examples.

I hit a snag with the Form.serialize function today that took me a while to figure out what was going on.  Blame it on a confusing doc, because this certainly could have been explained with more clarity.

The Prototype doc (the old one, the new one is hard to navigate and has less information) says that if you pass true to the getHash parameter, it will return “an object hash.”  A careful reading of that should be implied, because it returns a JavaScript hash, not a Prototype Hash object.  Big difference.

I hit upon the problem because I would serialize my form, then try to add more keys to it, using the set function.  That would throw errors, and I couldn’t figure out why.

So, there’s a couple of ways around it.  The simplest one I like is to immediately create it as a Prototype Hash, so you can do what you would normally do.

var h = $H($(‘form’).serialize(true));


learning javascript

At work, I’m starting on a new Intranet site for the company, and one thing I am really wanting to do is ramp up my JavaScript skills in the process so I can make a large part of it AJAX driven.  I’ve played with it a bit in the past, and with the awesome Prototype class as well, but up until now it hasn’t been anything more glamorous than hiding and displaying pockets of information.

I’ve been doing some reading up the past few days, and stumbled upon some great resources.  One really cool thing I found, that I’ll write about later since I’ve got some ebuilds in the works, is GNOME Seed.  Seed is, basically, JavaScript bindings for GTK+.  In other words, you can build GUI applications in JavaScript.  How freaking cool is that?  (For the curious, read this, this and this.)

Anyway, one part of doing my research about JavaScript is building a little toolkit of common functions that I can use as a fallback when I need to understand what’s going on.  I’m really familiar with PHP, so I’ve been using that as  a sort of inspiration.

I’ve got a little function I wrote, called var_dump(), which basically does the same thing as the PHP function, and with similar syntax output.  The code is here.  If any JavaScript gurus wants to look at it and give me some pointers, let me know.  I’d appreciate it. :)  Mine is making a call to Seed, but obviously it’d be easy enough to put into a browser.

learning c++

I have finally gotten off my butt and started working on a goal that I have had for a very long time: learn some C++.

I’ve got two great books (Sams, Deitel) on the subject and between them both they are easy and explanative enough for me.

I’ve just gotten over the boring stuff, like functions and expressions. I remember I actually took an Into to OOP at UVSC about 4 years ago, and I couldn’t even wrap my brain around the concept of a function.  That and the class moved so fast for me I had to drop it.  It scarred me for life and I went on to learn ASP next.  Fortunately I didn’t get too far with that, and I’ve been coding in PHP since then.  Thank goodness the C++ syntax is really similar.  That’s gonna help.

I’m actually really excited to finally learn a really powerful programming language.  I’ve wanted to for a long time, and hopefully before too long I’ll be able to help out on some bugs on more packages.  That’d be awesome.

It’s like President Faust said at General Conference one year, “the difference between wanting to help people and being able to is education.”

do you ever get the feeling …

… that no matter how much stuff you know, there is still a ton of stuff you don’t know?

Case in point, I’ve been working on writing ebuilds tonight, and it can be some incredibly difficult stuff.

First I started working on an ebuild for the wis-go7007 kernel drivers. Talk about biting off more than you can chew. I have to use the kernel eclasses, and I was looking at nvidia-kernel as a reference, but I couldn’t figure out why it was using eerror to get the output of linux_chkconfig_module.

The next one that I worked on (dev-libs/libebml) was changing something in the Makefile for Mac OS, and I had no flipping clue what it was changing or why. I’ll have to ping flameeyes on that one when he gets back.

Another one (media-video/oxine) has a lot of stuff to check for to make sure the deps were built correctly, and I couldn’t think of a good way to exit out if it was missing some without setting a bash variable.

On a good note, the one for mkvtoolnix came together great. That, and I fixed my alsa settings so my speakers don’t clip anymore.

I’m still bummed, though. I really need to learn more bash, it seems. I’ve been putting off learning other languages for a very long time now, since I’ve been so proficient in PHP, and now it’s really starting to bite me in the butt for not branching out.


I’m gonna go get on my laptop, sit on my couch, crack open my awesome C++ book, and get learning. I figure if I could learn both extremes (C++ pretty hard, PHP pretty easy) then the stuff in the middle should make a lot more sense, right?

random passwords

I needed to write a random password generator today, and instead of bothering to search for some code that I could copy and paste, I just whipped up my own real quick.

Then I got thinking about how all those Perl monks brag about how they can cram all this code into as few lines as possible, so I crammed mine into just one line. :)

Here it is:

for($x = 0, $password = ”, $password_len = rand(8,24), $alphabet_range = range(‘A’, ‘z’); $x < $password_len; $x++) { $password .= $alphabet_range[rand(1, count($alphabet_range) – 1)]; }

The great thing is it spits out cool passwords like this:

  • luhRDKyMDX\oey
  • rbKGTt`dLHWkHQZ
  • LJyeO_UwTpQzIni
  • ltonXGkho[e\JWbBl^uyEL

Fun stuff. :D


I wrote my first real (more than 3 lines) bash script at work today. It isn’t that complex, but I wanted to write it in bash instead of PHP, because I really need to learn it.

So far, color me impressed. I’m amazed at how easy it is to do stuff like string manipulation. I want to get good at it since ebuilds are written in bash, and I need the practice. My big goal is to write “dvd2mkv” in bash as well. The bonus is that it will remove one major dependency: PHP 5.1. That, and it will be hard as crap. Trial by fire, says me.

another update

I only worked on ‘bend’ a little bit today. The main new feature is that ripping works 100% now, and I’ve cleaned up a lot of old bugs. Encoding is the last thing left, and then I can finish up dvd2mkv.

One interesting little feature I added is that now you can rip the same disc in one or more session at the same time. Something I don’t recommend in the least, since it increases the disc readtime quite a bit. However, sooner or later, I’ll have it so you can pass bend --rip in one shell, and bend --rip --dvd_device /dev/dvd1 in the other. That can come in handy if you have more than one DVD drive and want to rip more stuff at once.