March 2010 Archives

Boise Code Camp 2010

This last weekend marked the third year I’ve been able to attend the Boise Code Camp, an excellent developer-focused, community run event help each spring in Boise, ID. This has, in the past, been the largest code-camp event of the year in our region, but it’s numbers were down this year, probably in part because of the Utah Code Camp (link is to their HTML version, the Silverlight Version hangs my machine. Unsure if that’s an issue with moonlight, or my box) was held on day one of the event, which prevented some people who may have come up to Boise before from coming up this year.

We’ve noticed that this year is really heavy with Code Camp events in the Spring, with Boise’s having just finished, Seattle’s the weekend after next, and Portland about five weeks after that. For this reason, our own Palouse Code Camp, won’t be held until September, though we’ll need to work with Utah to ensure we don’t schedule for the same weekend.

Despite the lower turnout than in years past, it was still a fantastic event. With some fantastic sessions. As usual, if I have any complaint with Code Camp, it’s simply that they do tend to focus on Microsoft technologies (though they don’t have to), and Microsoft stack developers tend to be really focused on what exists within that stack. Or, at least, they mostly only know much about what’s in that stack. Of course, I didn’t put together my YUI3 talk, so I can’t complain about all the jQuery talks too loudly, but I will have such a presentation for the Palouse event in September.

Some of the sessions I went to, I didn’t get as much out of as I would have liked. I began my first day, hoping to learn about using CouchDB in C#. Unfortunately for me, the talk was more an intro to CouchDB in general, but I did learn a bit, and was able to contribute to some discussion about the benefits of NoSQL (though we didn’t touch on the possible harm). Then, I went to a talk live-demoing web application vulnerabilities, which keyed me in to a few tools, but ended up being more basic than I had hoped. Also on the first day were a few talks on Progressive JavaScript by a person who didn’t seem as keyed into the topic as I had hoped, even going so far as to claim that ‘there are no JavaScript-only developers’. Admittedly, most developers don’t get to focus solely on the JavaScript side of front-end engineering, but there are plenty who do, and they spend a lot of time working to promote professional-grade JavaScript practices. I do think others got stuff out of the talk, but for me, it was two sessions almost entirely wasted.

The best talk I attended on Saturday, was, by far, Chris Billson’s “Powershell for Production Programmers” presentation. Powershell is basically a UNIX-like shell for Windows, where commands (and commandlets) can return .NET objects instead of just strings. Imagine a shell where you can pipe the output of ls to another program to easily filter out things based on file attributes, while being able to access those attributes as object properties instead of parsing strings by hand. I really want a python-based UNIX shell that can pipe around python objects instead of just strings now.

Powershell has some warts, which I’ll expound upon at a later time, but for the most part, it’s an awesome technology.

Sunday, I learned about Django, and some of what’s been added since 1.0, and about the south module, which provides truly awesome schema migration. South alone was enough reason to attend this presentation, and I really need to find something to with Django soon.

Finally, the last session I attended was from Microsoft MVP Craig Berntson, on what to do now that you’ve got Continuous Integration up and running. Namely, he wanted to discuss setting up StyleCop and FxCop, both of which I’ve looked at to integrate into our own CI build process (though I’m likely to use Gendarme instead of FxCop).

Automating things in your build to tell you about potential code ‘smells’ is possibly even more important that running automated unit tests, but most people just stop about the unit tests. Admittedly, StyleCop and Gendarme have a lot to complain about in our codebase right now, but that’s largely because we haven’t identified which rules we want to ignore. By integrating this into our build, we’ll be forced to start taking action (whether to ignore or fix), and then we can make these issues actual errors, instead of being too afraid to apply these tools.

I’ve got some posts coming on some of this tech that we covered, and how we’re integrating it into our environment. And there were some awesome sessions I wasn’t able to go to, like on the new version of Entity Framework, which might actually get us off of LINQ-to-SQL.

Our next code camp will most likely be the one in Portland, but Seattle is a possibility as well (it’s just so soon…). If you’re in a region that has a code camp within a few hours, I absolutely suggest going. There is a lot to be learned.

Great eBook Deals

One of the things we’ve talked about recently in a local group where we meet to discuss developer-related issues on campus (frankly, one of the only professional developer groups in the area), is the issue of continued learning. And of the things that came out of the discussion was that of buying books. The problems with many technical books is that they are very expensive, and oftentimes out of date by the time they’re published. Technology just moves too quickly.

For me, that’s part of what I like about eBooks. They can be cheaper, updated over time (though major revisions still warrant new editions), and time to market can be a lot faster. Like Manning and their Early Access Program, where you can buy an unpublished book, and recieve updates as they arrive at Manning, only to get the final copy of the book once it’s completed. Plus, with Manning, and this is the only tech publisher I know who does this, if you buy the book, you get the eBook for free. Amazing. The only downside to shopping Manning, is that their download system is archaic. Your download links are only good for a short period of time, so when a new version is released, you need to grab it quickly. Or go through the Customer Service desk, which takes time and is hassle enough you put it off until you flat forget. Not that the Manning people make it difficult, but more effort generally means a lower likelyhood of it getting done. Plus, Manning has been doing a lot of deals lately.

Enter O’Reilly, who are absolutely the elephant in the room when it comes to technology books. O’Reilly doesn’t throw in eBooks with their paper books, but they do have the #EBook Deal of the Day program, where every day they offer a different eBook for $9.99, which has sometimes been as much as $30.00 off the list price. I’m fairly sure Tim O’Reilly has done this in an effort to bankrupt me, because the deal is usually way too enticing. What I love most about buying through O’Reilly, is their management interface is great. I can view a list of all the books I’ve bought, see which once have updates, and most of their books offer ePub in addition to the PDF version.

I love books, but I’m really wanting eBooks badly now. I have two bookshelves full of books, and still more in boxes. I’m overrun, and I keep wanting to read. Now, if I can just find an eBook reader with solid annotation and ePub support (I wasn’t impressed with the Nook’s annotation, in the brief time I spent playing with one), I’m golden.

Bill Marler Speaks to WSU on Food Safety and the Law

Last Wednesday, Bill Marler, a Personal Injury Lawyer focusing on Food Safety issues gave his Common Reading lecture at Washington State University. The talk was entitled “Chasing the Ambulance Away: Reshaping the Role of the Personal Injury Lawyer in Society and the Law”, which I couldn’t help but chuckle at since the first time I was exposed to Mr. Marler, I went on to accuse him of being an ambulance chaser.

That was, as I’ve said since, a grossly unfair characterization, as Bill’s history, which I’ll be discussing some later, has tended toward cases where the injury sustained by the people he’s represented has typically involved enormous consequences, typically requiring lifelong medical treatment. More importantly, from my perspective, is that in far too many of the cases Bill’s worked on, compelling evidence has been found that the defendants either knowingly disregarded the potential health risks, or willfully remained ignorant of the potential for damage existing within their own facilities.

At the heart of the matter is the fact that in the State of Washington, since 1913, after the Mazetti v. Armour & Co. case (75 Wash. 622) (for which I can find several references online, but no transcript or anything), there has been a legally binding implication that anyone manufacturing food (which includes growing or processing) is providing a warranty that the food product is safe. So, for Food Safety, there isn’t even a question of guilt. If you can prove a food product is responsible for sickening someone (or rather, many someones, since usually you need that to find a pattern), they are unquestionably at fault. Their intent has nothing to do with the fact that they’re responsible, though certainly damages can be modified by the reasonableness of their efforts to do the right thing.

The good part about this system is that it protects retailers (grocers, not always restaurateurs), who often are unable to know a product might be contain an infection, though of course, visible signs of problems that a grocer does nothing about are still their liability, and a restaurant that handles their food properly might not be liable if a shipment they get in is infected, provided their handling practices don’t make the problem worse (more on that later).

I could do a recap of Bill’s cases, but I’ll just touch on the big ones and some of what i found interesting about the sort of repeating links of them. First, was the Jack in the Box case from 1993, which sort of made Bill famous. A case where there was proof that Jack in the Box’s executives were more concerned about hitting a two minute preparation time, instead of cooking their meat all the way through. Saving thirty seconds per burger killed 4 people.

In 1996, Odwalla, after being told by the US Army that their plants were too filthy for the Army to buy their Juice for sale to Army personnel and families, continued to ship Apple juice that they knew was possibly bad, all because they were trying to pad their profit margins to look good to Wall Street. E-mails from inside the company showed that they considered doing more stringent testing, but chose not to so that they could claim ignorance of the extent of the problem (and possibly even it’s existence).

Or a 2003 case where a restaurant was storing their scallion’s in the same container for months at a time, which eventually became described as a ‘Hepatitis Soup’. In this case, it happened to be an import product, but nearly all cases Bill has tried over the last 17 years have been from domestic products.

Food Poisoning is a difficult thing to prove. Many food-borne illnesses take days, if not weeks, to incubate. So tracking down the cause of the illness is very difficult. The food production industry does virtually no self-policing. Bill described a peanut-butter plant in Georgia as being so filthy that you’d think twice about taking your car to an auto repair garage that was that messy. And that plant hadn’t been inspected in seven years, because the FDA doesn’t have the resources necessary to enforce it’s own standards.

Things are certainly bad. But are they any worse than they’ve ever been? Or are we simply better at tracking and identifying the problems such that they just seem worse? I think it’s a combination. Surely we’re better at tracing problems, but unlike Bill, I think a strong claim can be made that overuse of low-levels of antibiotics will apply an artificial selection force for strains of the bacteria that are more resistant to a given antibiotic, the so-called ‘superbug’. I feel the biggest change, and the most damaging issue, is the centralization of the food system. Even fifty years ago, the thought of a farm in California producing contaminated spinach that was going to sicken people in New York was practically laughable. The idea that a state like California would grow the majority of the nation’s tomato crop, which are shipped nationwide, was also laughable. The attractiveness of this system from an industrial standpoint is obvious, but it is likely the reason our food is less safe.

When asked what he eats, Bill replied that he tries to eat local food as much as he can. Shorter distance between field to plate means fewer handlers, which means fewer opportunities for mishandling. But also, it tends to have a shorter time to consumption, which can prevent an infection from taking hold. For instance, a Spinach-caused outbreak of Salmonella in 2007 would likely have been a non-issue, if the spinach had been picked and sold at a Farmer’s Market instead of bagged and shipped clear across the country.

Solving this is a major problem. The Free Market is weakened by the fact that most consumers never hear about the causes of these problems, or that they can be convinced via advertising or familiarity that the product is trustworthy. Hell, I don’t know how many people I know who’ve blamed Taco Bell for some kind of food-related distress, only to continue eating there. What about Regulation? We live in a time right now where the general public doesn’t trust Congress to do something that doesn’t in some way benefit corporate interest more than the general public, and then the issue with the current house-passed bill languishing for attention in the Senate because the senators are too busy with health-care reform.

Litigation isn’t really helping because it’s reactive, and a lot of companies just view litigation as a cost of doing business. Something they just have to put up with. What’s worst in my mind, is that fact that there is no criminal liability, even in cases where executives force the shipment of goods that they are almost (or even absolutely) certain are contaminated. In China, these people have been known to be drug out into the street and shot. While that’s not an answer appropriate here, Bill says he’s only seen a very small handful actually go to jail.

Bill provided a top eleven list, of things he wants to see done to improve food safety, which I’ll repeat below. Before I do however, I wanted to just boil things down to the basics of what I think he was indicating needed to happen. We, as American’s, need to start spending more on food. We can’t expect the regulation or devotion to quality that we expect unless we’re willing to pay for it. Instead, we now have a system where food producers are forced to cut corners because retailers will squeeze them and threaten to pull their business unless they drop wholesale rates, a major problem when you’re in a business that already operates at razor-thin margins.

Bill’s Top 11 Food Safety Changes:

  1. Improve Surveillance - Track food from farm to plate
  2. Better cooperation by government
  3. Train, Certify and Vaccinate food handlers
  4. Stiffen license requirements (but please do it in a way that is still fair to small producers)
  5. Increase food inspections
  6. Reform agencies to be proactive, not reactive
  7. Criminalize knowingly shipping tainted product
  8. Use technology to make food more traceable
  9. Promote research (particularly research not funded by Industry)
  10. Provide tax breaks to improve producer profitability
  11. Improve Customer Understanding

I’ve added a bit of commentary to the above points (anything in parentheses) on where I see potential problems with the regulation that would be approved by a Department of Agriculture whose policy has led to the centralized agricultural system which is at least partially responsible for the problems we have today.

What I felt was the most important takeaways from the talk were that we need to find a way to make the food industry more accountable, hopefully from within, since as it stands they can willfully ship infected goods and not face much in the way of consequences. For now, the best way to be safe seems to be eating locally grown food, which has received a minimal amount of handling. It may not be fool-proof, but it’s the best we have, and with luck, we’ll all be able to eat this way in the near future.

Working Around IE Bugs: Rebuilding Select Boxes in JavaScript

Recently I was building a simple web application form where one of select boxes was driven by the value of a different box. The original code for this seemed pretty straightforward, but while the code worked perfectly in Firefox and Chrome, it was producing amazingly strange behaviour in Internet Explorer. Namely, when I’d rebuild the select box, IE would not position the text correctly inside of it, the dropdown wouldn’t appear reliably, and when it would, it wouldn’t necessarily show the correct text for the selections. In one case it was actually displaying four selections, when there were in fact only two. You could use the keyboard to select the values correctly, but this was still absolutely unacceptable behaviour.

I’ll do a write up on the behaviour later this week, but I decided to jump the gun and present the solution I developed first, since I don’t have good simple examples just yet. I ended up trying several ways of creating the options before appending them to the select element, but eventually, I had to completely recycle the selectbox in order to make it behave correctly. I’ve had other pages that didn’t misbehave in quite this way, so I’m trying to figure out the minimum case to recreate the problem before I send it to Microsoft.

Luckily, JavaScript makes it pretty easy to branch code based on browser in a way that doesn’t require doing the browser check all the time. Below is a generic version of the function to do the replacement, which includes calling a ‘change’ event handler, which unfortunately can’t be anonymous (at least in YUI3) since ‘change’ events can’t be simulated. Actually, having to rebind the changeeventhandler every time you change the contents of the select box is the only possible ‘challenge’ in the problem.

var rebuildSelectBoxOptions = > 0 ? function(box, options, change_event_handler) {
    var newOption, newSelector;
    newSelector = Y.Node.create(box.set('innerHTML', '').get('outerHTML'));
    for (var i = 0; i < options.length; i += 1) {
        newSelector.append('<option value="' + options[i].value + '">' + options[i].text + '</option>');
    newSelector.set('selectedIndex', 0);
    if (Y.Lang.isFunction(change_event_handler)) {
        change_event_handler({target: newSelector});
        newSelector.on('change', change_event_handler);
} : function(box, options, change_event_handler) {
    box.set('innerHTML', '');
  for (var i = 0; i < options.length; i += 1) {
        box.append('<option value="' + options[i].value + '">' + options[i].text + '</option>');
    box.set('selectedIndex', 0);
    if (Y.Lang.isFunction(change_event_handler)) {
        change_event_handler({target: box});

The non-IE version is a couple of hundred bytes lighter, and should be faster (though for most use cases, the difference is likely negligible). I’m not sure yet what the increased garbage collection load of this will do to IE, but in my case, that’s not likely to be a problem.

Compact Fluorescent Lights and the Environment

1 Comment

I’m highly interested in the ‘Green’ movement and the things that we are supposed to be doing that will help mitigate humanities continued impact on the ecosystem. However, I question a lot of the things that the green movement pushes, which sometimes seem like they might cause more damage over the long term than less. For instance ‘compostable’ plastics, which tend to be made from soy. I suspect these plastics require a lot of water in the processing, which very likely negates any benefit to them being able to avoid the landfill (though most almost certainly end up in landfills).

I’ve felt similarly about Compact Fluorescent (CFL) Light Bulbs for a while, knowing that the cost of production was going to be dramatically higher than for traditional incandescents, but being unsure that the energy savings in use would be enough to make up for it. Then, I saw one of the best written contributory articles to our local co-op newsletter, which for those who download the newsletter at the previous link, can find on page 36 of the PDF.

The article in question looks at this issue in a pretty complete way, presenting several interesting statistics:

  1. Making a CFL takes 5 times the energy of an incandescent, but you’ll need 6-10 incandescents for each CFL.
  2. The energy output of incandescents over a single CFL would require generating 200 pounds of carbon over the life of the CFL.
  3. A CFL contains ~5mg of mercury, and powering that bulb with coal (over it’s life) generates another 2.4mg of mercury into the environment, however, Incandescents would require 10mg of mercury output from a coal-fired plant. This is further mitigated by the relative ease of recycling CFLs.

Now, here in the Pacific Northwest, mots of our energy needs are met by hydroelectric, not coal, but still the proven energy savings of the bulbs have kept them an attractive option, but it’s nice that the statistics show that this is actually a real improvement we can make, that’s not only ‘green’, but saves money as well.

In many ways, I’m more interested in LED lighting, though it’s hard to find in the stores. LED bulbs have the potential to be even better over the long term than CFLs, Currently, LED bulbs last 5 times longer than CFLs, use less than half the energy, but cost about 10 times more. However, what I don’t know is how that translates into their production impact. Still, it’s an interesting technology I plan to watch.

Introducing gallery-slideshow for YUI3


Recently, at work, we had a desire to update an instance of a flash-based slideshow widget on our commencement website. This widget did absolutely nothing special, but the real problem we had was that, we didn’t actually have a license for Flash, and the way the slideshow had been built, we needed to be able to build the SWF file from scratch in order to update the order. Since our users rarely come to us with anything that isn’t some sort of emergency, we had to take the flash files to another department to make our quick change and compile a new SWF.

Of course, I knew there was no reason to continue to use unconfigurable Flash for this, but YUI didn’t have a slideshow widget. So, I decided to start writing one. Due to the excellent widget framework, I had a quick-and-dirty example written in a mere couple of hours. Of course, that was not something I was really going to release, though I did push it up to my github.

It was about a week before I was able to return to the project, but I have now submitted a very basic, but functional widget to the Y! CDN.

The javascript to run the above slideshow is simple, for the user:

The CSS that it requires is straightforward, and is part of the widget’s assets:

The widget will automatically take care of placing the images in the upper-left hand corner of the widget’s content box, as well as cycling through all the images using the transition sent in via the animation configuration option.

The core of slideshow is mostly done at this point. I plan to add support for the an image to transition in, instead of only having the top image transition out. Most functionality will likely be added via the plugin framework. And I have several plugins planned.

  • Titles - Adds the widget header which will be populated with the ‘title’ value from the images array.
  • Descriptions - Like Titles, but in the footers. I’m thinking this will take either a string or a function to generate the content of the footer div.
  • Image Centering - This will center all the images in the content box, allowing the slideshow to consist of images of different sizes.
  • Image Navigation - Buttons (probably images with click events, but you get the idea) which will allow the user to force transition between images.

The plugin framework is great because it allows you to customize a widget with exactly the kind of features you need. There are a lot of other kinds of plugins that would be appropriate, and I’m certainly open to feature requests, or pull requests would be better!

Integrated Circuit Design as a Game

Saw this on the Make Magazine Blog today, but it’s a little game called KOHCTPYKTOP, which is Russian, and loosely pronounced ‘Constructor’. It’s centered around the idea of creating simple integrated circuits by laying metal and silicon down on a design surface and running them against expected voltage readouts.

This is a great little puzzle game, and I know that if you’ve any interest in electronics, you’ll probably enjoy it. When you’re not pulling your hair out in frustration that is…

Genetically Modified Organisms to Destroy Organics?

The USDA is currently accepting public comments on the issue of allowing a Genetically Modified Alfalfa plant developed by Monsanto, which could, by the USDA’s own research, infect organic alfalfa farms, potentially causing them to lose their ‘organic’ labeling. Needless to say, many people are upset about it, not the least of which are the people at Food Democracy NOW!, who want your comments. Now, this product has made it past USDA environmental review, that, in theory, shows that the environmental impact of this GMO crop will fall within acceptable levels, however those are defined.

FDN is calling this something that ‘threatens the very fabric of the organic industry.’ Now, I think that battle was lost years ago, when Organic was defined in such a way that the biggest players in Organic are companies like Kraft and Heinz, but the real issue here, in my opinion, is the danger of these GMO crops. Not that they’ll cause health issues with those who consume them, but rather the danger to the ecosystem, particularly when you look at the docket and realize that this GMO is only meant to be herbicide-resistant. A so-called ‘Roundup Ready’ crop.

It is the nature of agriculture to support the cultivation of certain plants at the cost of others, however, with these ‘roundup ready’ crops, it encourages wholesale dumping of these chemical plant-killers in manners that don’t necessarily control the application of the chemical very well, which can kill plenty of plant life that is found in areas external of the GMO crop, further reducing plant diversity (and most likely insect/animal diversity by extension) in those areas. Plus, since the plant has been modified to be difficult to kill, when it does spread to non-GMO versions, it becomes impossible to separate the GMO version from the non-GMO version, further reducing biodiversity. It is this cross-breeding between GMO and non-GMO life, and the fact that the non-GMO life is almost guaranteed to be the dominant form over time, that worries many ecologists.

The monoculture present in modern agriculture is already worrying, but has, until recently, still been based on traditional selection, with change in an organism happening slowly over many generations, based solely on selecting traits based on what was most desirable in the current generation. With GMOs, we can greatly change very fundamental things about an organism in a single generation, and the question that hasn’t been answered in a manner that is acceptable to macro-ecologists is if it’s even possible to do that in a way that doesn’t have potentially expensive ripples. I suspect that the answer to that question is that no, we can’t have GMOs that don’t have a severe impact on the ecosystem around them, and I don’t think we’re ready to be exercising those changes.