Tuesday, July 21, 2009

SpiderMonkey

The other day at work, I had a great idea come to me. For the longest time the hardware team at work has been wanting some way that they could write simple debug tests for our test boards, but they didn't want to keep a whole source tree with everything up to date, so I thought to myself "wouldn't it be great if I could write a simple little script parser for them?" Their needs are not great, generally just reading/writing registers on the processor and board, maybe some sort of logging and stuff like that; pretty simple really.

I started thinking I should brush up on my flex/yacc/bison/etc when it occurred to me that there had to be a simple script parser out there already that I could build into my embedded, bare metal, environment. So, I opened up google and typed in "C javascript engine" to see what I could find.

Lo, and behold, one of the first responses was for SpiderMonkey, the JS engine that is used by Firefox. Now, when I saw that, I thought there was no way that SpiderMonkey could possibly work for what I wanted, but I decided to take a look at it just to see what it looked like.

I had previously looked at the v8 scripting engine for another project and so I was expecting a rather large source tree, but SpiderMonkey 1.7 was only 1MB tar gzipped. So, I spent about 30 minutes hacking up the makefile a little bit so it would work for cross-compilation, got onto #jsapi on irc.mozilla.org and asked a couple questions about the custom implementation of dtoa and then got my first static library compiled.

Now, anyone who has ever ported something knows that compilation is a pretty big step, but just having something compiled doesn't mean that it will work, so I didn't have much hope.

I grabbed some simple embedding howto code that evaluated the JS code "22/7" to approximate PI and fired up my trusty compiler. Again, I had little to no hope that it would actually work, but to my surprise I got a nice print-out on my screen of the approximation of PI.

I spent another 30 minutes implementing some wrappers for some native functions (logging, etc) for JS and wrote some simple little test scripts.

I was very impressed by SpiderMonkey 1.7, it was easy to hack up a little to get it to cross-compile, it doesn't require a lot of external libraries (none really) and it runs very nice on my embedded target.

My next step will be to try with one of the releases that includes TraceMonkey and the speed improvements that come with JIT.

I have yet to show my idea to the hardware team at work, but I think they will like it. I will support a simple executable that takes a script on the command line and executes it. They just need to write the simple test vectors they need and don't have to worry about the whole code environment.

Thanks SpiderMonkey!

Wednesday, July 1, 2009

The Coming of the Quantum Cats, part deux

So, originally I was going to post on every chapter of this book. It was a really quick read (I finished it a couple weeks ago). I've been pondering what to write. I liked the book. I didn't love the book. It jumped around a lot between a couple different viewpoints. Basically, we get to know the same character from a couple different universes. I really liked how different the three versions of the same person were. Depending on the history of their world, they turned out remarkably different.

One of them was a low level mortgage broker, another was a high level scientist and the last was a US Senator. They didn't talk about where each one's history differed to get to the point they were at, but it was interesting to see.

I don't know if I would recommend this book to anyone, but if you want to borrow it I think I still have it.

Saturday, May 30, 2009

The Coming of the Quantum Cats

We have a great little used book store somewhat close to us called Pass the Book. I was able to find a couple books that I have been looking for to fill in my SciFi collection a little bit which is always nice. I was there the other day while waiting for my pizza to get done when I came across this book:



Yes, indeed. "The Coming of the Quantum Cats." How could I possibly resist buying this book? It was $2.00 to start with, and they were having a 25% off sale, so I paid a remarkable $1.50 for this gem. I've decided that I will do a post for each chapter. I will try to not give anything away because I am sure everyone will want to go out and purchase this exceptional literature achievement, but if I do, I'll mark it with "SPOILER ALERT" so you have ample warning. I go into reading this book with the expectation that it will be laughably horrible, but I could be pleasantly surprised and it could be fantasic. I am not holding my breath.

Chapter 1 review to follow shortly.

Wednesday, December 17, 2008

The Nameless One

My wife is into naming cars. Her first car was named Meridith; this is what Meridith looked like:

(Photo courtesy of Ford Motor Company)

That's a 1993 Ford Escort. The color was black. Stick shift. Nice little car. I taught her how to drive it (she hadn't driven stick before) and she was great.

When we got married, we had the Escort and a 1998 Chevy Cavalier that looked like this:


Apparently she didn't like this car very much because she named it Donkey Ass. I assume she was just using two synonymns for the beast of burden. She couldn't possibly mean anything else.

Then, I got into a car wreck in Donkey Ass and it got totaled, so we went and bought a 2004 Jeep Grand Cherokee, which she named The Rugged Gentleman, obviously she liked this car much better.


The Rugged Gentleman
was a great drive. It handled really smoothly and was by far the best car I had ever owned. We decided that the payments were too much for us and that we wanted to get out of debt, so we sold it to my mom (she still drives it now).

With the money we got from the sale of The Rugged Gentleman, we purchased two vehicles.
One, a 2001 Mazda Tribute for my wife to drive; she named it The Lasso.

I don't think we ever took ours anywhere quite this nice looking. Ours didn't have a sun/moon roof either. I liked the Mazda. It had some pep to it, nice engine for a smallish SUV and it fit our needs for car seats at the time. We drove it until the air conditioning started going out (a sure sign of death in Arizona!). We traded it in for our current vehicle, which I will get to in a minute. She named it The Lasso after her brother sent her a picture of his facial hair, which was side burns that wrapped into a lasso on his cheek. As a fan of facial hair, I was intrigued and liked it. I'll try and find the picture to post here.

The other vehicle we purchased was for me to drive; a 2002 Mitsubishi Lancer.


It's a stick (and definitely not as shiny as the one in the photo). I'm using it as a commuter car (~40 miles round trip per day, to and from work). One of the hubcaps is missing and the front left tire has some issue that I need to get looked at again (yes, I had it looked at a month or so ago).

I refuse to name this car. My wife may very well replace "Lancer" with "Judge Reinhold" or "Fritz McGovern" in her mind when we talk about the car. I just don't know. I don't know why I refuse to name my car, perhaps I just don't get attached to vehicles the way she does. I see a car as something to get me from point A to point B. As long as it has A/C (we do live in Arizona after all) I am ok with just about anything (except a New Beetle...don't like those).

Now, on to the car we got when the A/C started going out on The Lasso. It's a 2008 Honda Odyssey.
She named this one Dusty Miller; even my daughter calls it that. I really love this vehicle. It drives VERY well, the features are great (DVD, MP3, headphones for the screen, leather, back-up camera, etc). I even love the color of this car. It drives smooth...smoooooooth. It gets pretty good gas mileage, and fits our car seat space needs at this point. Lots more room for travel too.

I NEVER refer to these vehicles by the name that my has given them. I say "the van," "the Lancer," "the Mazda," "the Cavalier," etc. Again, I don't know what I have against it, perhaps if I were talking to a shrink they might suppose it's because I don't want to become too attached or something, but who knows. Maybe one day, I'll give in and name the Lancer, but I don't think so.

Sunday, December 14, 2008

Senor Cardgage owns Norton Furniture

If you aren't familiar with who Senor Cardgage is, please see the following Homestarrunner Wiki entry

The voice of Mark (you can count on that being his name) reminds me so much of Senor Cardgage.

Friday, November 21, 2008

One Hit Wonders

I often find a song from a band that I really, really like. The problem is, I think to myself, "Gee, if I like this song, I will probably like more of their songs." Most of the time I am sadly disappointed.

Let's look at a few examples:

1. The Redwalls - Summer Romance

Sadly, this is the best video I could find on YouTube...doesn't do the song justice.


I can listen to this song over and over. To me, it sounds like something that The Beatles would have put together. The slow build, rowdy interlude and back to the slow melodic verses. I really, really like this song. So, again, I thought to myself, "I have to check out the rest of their stuff, it's probably just as awesome!" WRONG. I couldn't find another song by them that I liked. Perhaps I didn't give them enough of a shot; perhaps I was asking for too much out of them, and maybe I'll check them out again. I put them on my list of one hit wonders; bands that I can only find one song I like.

2. Avenged Sevenfold - Seize the Day



The first thing I have to mention about this is the part of the video where the guy starts into his guitar solo on top of the coffin. CLASSY. I want someone to do a guitar solo on top of my coffin when I die. That would be awesome. Back to the song.

This song has a certain raw quality to it that I really like. The lead singer's voice is both melodic and raw at the same time. The guitar solo in the middle has a great sound to it and I like the speed change in the middle. Again, I went looking for other songs by Avenged Sevenfold, didn't find a single one that I could even listen to more than one time.

3. M.I.A - Paper Planes


Paper Planes Video

I have a buddy who HATES this song, which might be part of the reason I like it so much. Actually, I really, really like the beat on this song, and I like the usage of the gunshots and cash register as percussive "instruments." The lyrics are pretty much nonsense to me, but they are ok. It's a good song to relax to, as the beat is nice and slow and doesn't require a lot of thought. I listened to some of M.I.A.'s other stuff and thought it was crap, pure and utter crap.


I don't know what it is that catches my fancy on some of these songs, they just inch their way into my head and I dig them. I wish I could find another band that I liked more than 3 or 4 of their songs (I like a majority of the Beatles), but I haven't found a band like that yet.

Tuesday, October 28, 2008

Code looks terrible

Source code looks terrible on here...any tips to making it look nicer?

Update: adding a pre tag around the code makes it at least format somewhat correctly...