All posts by tim

Vegetarianism not good reaction to McDonalds


Image via Wikipedia

I’ve been encountering a lot more vegetarians lately. It’s probably not so much that I’m encountering more, as I’m not driving them off as quickly. In the past I was an asshole if you were a vegetarian. Something along the lines of, “But we are omnivores, you’re just depriving your body.” Also, “Plants have feelings too.”

But as part of my laziness new cooking regiment, I’ve been using epicurious.com’s weekly meal planners to plan my meals for the week. They pretty much always do a vegetarian meal or two. Something that at first I just left out. Or filled in with something meatier. Like hanger steaks and fries.

But recently I’ve started cooking them. And Julie and Stella have been enjoying them. Mostly. The meals are hit and miss. Often the things that sound horrible are quite good, and the things that sound good are completely horribly foul. We had a side dish composed almost entirely of zucchini and I liked it. I didn’t like it for zucchini. I really liked it.

I even cooked tofu last week. And last night. Which still gives me a bit of a weird feeling. Because I’d rather cook an animal, than an animal substitute. I actually like tofu. But I’d prefer to cook it as tofu. This really cool vegetable product. Rather than tofu, “I can’t believe it’s not chicken”!

I’ve noticed a trend. There are a lot of vegetarians I’ve encountered who don’t really eat vegetables. This is supposed to be a diet about health. Or politics. Or both. But I’m seeing a lot of people who just eat McDonalds fries. And Annie’s Mac and Cheese. And Mission cheese burritos. Which seems like it’s defeating the point. Vegetarianism has become big business. The business being providing calories without requiring the actual consumption of vegetables.

It’s the same bad diet that is making most of America obese, but without the benefit of getting second-hand vitamins and minerals from animals that have already predigested those noxious vegetables for us.

I’m still learning to love vegetables. But we’re working through this together.  Stella’s my mascot. She’ll eat pretty much anything raw, but once I cook it she becomes uninterested. Potatoes. Zucchini. Red peppers. Garlic. Ginger.

Julie would prefer that I not give her raw garlic.

Maybe I should join the raw foods movement.

Joking.

Sunstroke 5k #12

28:03, 9:03/mi. I really pushed myself. I’m hoping it was the heat, because that’s just a middle of the road score for me.

Well, I’m back to running every day, so there’s always next year. I’ll chalk up this year’s poor performance to having a newborn.

Ahh Genesis

I’m hooked on slowing down classics!

So I was listening to bob.fm’s top nine at nine this morning. They pick a year and play nine songs from it.

Javascript Performance

So at work I had to fix the performance of an AJAX call. It was using a java library called AjaxAnywhere to completely replace a table. When it did that with thousands of rows it got REALLY slow.

It was simply replacing the table with innerHTML, and I figured if I changed it to using dom methods it would be faster. It didn’t due to what I’ll discuss in the third bullet point. But I learned a few other lessons about performance along the way.

1) Copy your array length to a local variable:

This is much slower:

for(var i = 0; i < someArray.length; i++) {
  // do something
}

than this:

for(var i = 0, il = someArray.length; i < il; i++) {
  // do something
}

2) Don’t use prototypes object creation functions in loops (I think prototype object creation works great for the small stuff, and is very legible). They’re too slow. I started out with this:

var tr = new Element("tr", {
  'class': 'unselectable',
  'id': idValue
});

but it turns out that prototype adding attributes via a hash (what Element.writeAttribute does) looks up the dom node each time, which is a performance drain. I changed it to this:

var tr = document.createElement("tr");
tr.className = 'unselectable';
tr.id = idValue;
 

3) Create a render queue. It took me a long to find this, but you’ll probably run into it no matter how fast your javascript runs. Generally web browsers wait until your javascript function exits to update the dom. If you’re adding thousands of objects your page can blank for seconds redrawing. What’s the answer? A render queue, which looks something like this (posting as a nice class as I don’t think there are enough examples like this):

var lgt = lgt || {};

lgt.RepetitiveTaskManager = function() {
};

lgt.RepetitiveTaskManager.prototype.renderQueue = Array();
lgt.RepetitiveTaskManager.prototype.rendererRunning = false;

lgt.RepetitiveTaskManager.prototype.enqueue = function(methodRef) {
  var renderQueue = this.renderQueue;
  renderQueue.push(methodRef);
   
  if(this.rendererRunning == false) {
    this.rendererRunning = true;
    setTimeout(this.renderer.bind(this), 1);
  }
}

lgt.RepetitiveTaskManager.prototype.renderer = function() {
  var renderQueue = this.renderQueue;
  var length = (renderQueue.length > 5 ? 5 : renderQueue.length);
  for(var i = 0; i < length; i++) {
    var functionCall = renderQueue.shift();
    functionCall();
  }
    
  if(renderQueue.length > 0) {
    setTimeout(this._renderer.bind(this), 1);
    return;
  }
  this.rendererRunning = false;
}


// first declare our renderer function
var callback = function(table, cellContents) {

  var tr = document.createElement("TR");
  var td = document.createElement("TD");
  td.innerHTML = cellContents;
  tr.appendChild(td);
  table.appendChild(tr);
};


// now add 1000 rows to a table

var taskManager = new lgt.RepetitiveTaskManager();

var table = document.getElementById("myTableId");
for(var i = 0; i < 1000; i++) {
  taskManager.enqueue(callback.bind(table, i));
}

Don’t forget bind is your friend in this case. For those without much experience with it, bind let’s you pass a function call with the appropriate variables to call the method with, without calling the method at that exact moment.

By using this render queue it will render 5 rows at a time on the page, and the table will seem to expand down the page as the user watches. This isn’t desirable in all case, but it’s generally better than having the user’s browser get unresponsive.

Twittering Boredom

waiting for the meeting

So there’s this aquaintance I follow on Twitter. Actually I’m not completely sure I’ve ever met her. But that’s beside the point. She likes to tweet incredibly boring status updates. Like “waiting for meeting to start”, “meeting ended”, “driving to meeting”. And I’ve realized that it’s somewhat contagious.

Much like that good friend you have, whose stories of drunken debauchery makes you feel like your own life is somehow less boring. Reading these tweets makes me feel like my life is somehow more boring. Does anyone else have this problem?

Dance is good for kids

We went to Stella’s first dance recital on Tuesday. Thankfully it wasn’t actually a dance recital. It was simply a chance for parents to sit in and watch a somewhat typical class. I think a dance recital for three year olds is somewhat cruel. Kind of like a spelling bee for the mentally challenged.

I was amazed though by what Stella learned. I’d always wanted my kids to take dance, because I feel like it’s something that’s much harder to pick up later in life. At UT I did a few dance related pieces and auditions. From talking to fellow auditioners, even people who had just a couple of years of dance as kids could generally pick up choreography about 10 times faster than I could. Which I don’t think is completely the lack of dance training’s fault. I’m a large force of nature that can’t always change direction on a dime (or a ball-change).

So I wanted Stella to take dance.

But what I didn’t count on, and why I think everyone should put their kid in dance, is that beyond the above reason is the focus and discipline. This was not some sort of old-school ballet class where you get kicked for talking or not being good enough. But it was very much about focus and discipline. A lot of time was spent making sure the kids were all where they were supposed to be and focused on what they were going to do next. It was fascinating to me as compared to organized sports. Sports are like dance in that they get rid of excess energy and teach cooperation and coordination. But I don’t think they’re good at teaching focus. I was never given tools for when I needed to stay focused out there in left field, and when I could goof off (and thus I pretty much always goofed off).

All in all, I was very impressed. Get your kids in dance. You’ll be really happy you did.

Reblog this post [with Zemanta]

A Helpful Guide to Your Position on Healthcare Reform

1) Check your investments.
2) Do you have investments? (Yes – goto 3, No – goto 10)
3) Do you have health care investments? (Yes – goto 4, No – goto 10)
4) Store your annual rate of return in field A
5) Check your health care plan.
6) Do you have a health care plan? (Yes – goto 7, No – goto 10)
7) Store your annual rate increase in field B
8) Is field B less than field A (Yes – goto 9, No – goto 10)
9) You have made a good investment and should be against health care reform.
10) You are for health care reform.

It’s interesting to me that the anti-tax group seems to be the anti-health care reform group. So they’re unwilling to pay anything for government services, but if it is a private service they expect, nay demand, to pay through the nose for it!

2009 Sunstroke 5k – #10

28:42 – I’m getting slower. I think I need to run with my iPod to speed things up. That was a really nice comfortable run. It was 87 and raining gently. I guess I need the 100+ degree heat to push myself.

I had an awesome run at Mabel Davis yesterday in the heat. I really felt like I pushed myself. Go figure.

Headbands rock!


I don’t care what Julie says. Headbands rock. I bought some on a whim at Target a few weeks back. Sure they’re designed to emulate the late seventies for kids who weren’t born then, but whatever.

Up until recently I was reticent to wear sunscreen cause that stuff stings when it rolls down your face into your eyes. And yes, I do wear waterproof. See waterproof sunscreen means it will stay on you after you get wet. It doesn’t mean that any that hasn’t bonded with your skin won’t roll down your face and get in your eyes.

Running with the headband was a revelation. My forehead stayed cool and dry and sweat was channeled down the sides of my head.

I can’t explain that visor on Stella’s head though. Kids these days.

The News Doesn’t Like Plot Twists

So there was a double-homicide in west campus a few days back. A guy and his girlfriend. Apparently they were really cool. The media seized upon it as this random horrific act… THAT COULD HAPPEN TO YOU!

Well it could happen to you if you deal large amounts of pot and you start leaning on a person who owes you thousands of dollars. So that came out today, but the Statesman’s still going along with their “poor kids, random act of violence story”.

Remember. Stay in school. Don’t do drugs.