Sunday, June 05, 2011
BYBS: Stupid JavaScript Tricks
Rather than trying to explain this in some way that makes sense, I'm going to use the short version. This will not confuse any readers because a) I don't have any and b) anyone who stumbles upon this blog must already be a JavaScript gawd.
OK, so suppose you are using Ajax to grab a list of people and you want to shove them in a table, along with a button that initiates some action that annoys said person. Well, one way that might seem plausible is to use the following:
var button = document.createElement("input");
button.type = "button";
button.value="Annoy";
button.onclick = "annoyPerson(person.id)";
Unfortunately, this does not work, since JavaScript really wants to get a function for Christmas when you pass it the value for onclick. OK, how about this:
button.onclick = function (id) {
annoyPerson(id);
};
This doesn't work either because onclick will not pass any parameters to the function it calls. So how about:
button.onclick = function() {
annoyPerson(person.id);
};
This sort of works, in that it will call annoyPerson with an ID that is taken from the list that you are iterating over, but it will be the same value for all the buttons. This means that you might click the button to annoy Fred only to annoy Mary instead. Very embarrassing.
OK, so how do you pass in the correct ID? There are two ways that I found out about. Probably the preferred way is to use the following:
button.setAttribute("data-person-id", person.id);
button.onclick = function() {
annoyPerson(this.getAttribute("data-person-id"));
};
The way that I thought was especially kewl, however, was the following:
button.onclick = function(id) {
return function() {
annoyPerson(id);
}
}(person.id);
This wonky mess of JavaScript defines an "anonymous" function that returns another function. The outer anonymous function is then immediately called (via the (person.id) bit at the end). This binds the current value for person.id to the id parameter, ensuring that the inner anonymous function gets a different value for each iteration of the loop, rather than the last value the iterator held.
If this seems long-winded and impossible to follow, it's because it is actually long-winded and impossible to follow. JavaScript is a strange and annoying language in my not-so humble opinion, and it often times feels like voodoo when you get something to actually work.
Nevertheless, getting this to work was a nice point in my week. Which just gives people another indication of how pathetic my life is.
Wednesday, May 18, 2011
BYBS: TWIV HIV Episode
Well, at least one word in this week's title isn't an acronym or abbreviation.
At any rate, this posting is about a very cool episode of This Week in Virology (TWIV); in particular it is about HIV and some recent discoveries. From what I could gather from this episode...
- HIV is a retrovirus, meaning that it becomes part of the host's DNA when it infects them.
- Highly Active Anti-Retroviral Therapy (HAART) can essentially halt the spread of HIV.
- It appears that HIV can infect bone marrow cells that are stem cell like in that they divide to replenish blood related cell types.
- When a patient goes off HAART, the progenitor cells may be able to start up the infection again as they continually regenerate the host's blood cells.
Sunday, April 17, 2011
BYBS: Bacteriophages
![]() |
| The structure of a typical tailed bacteriophage. Image from Wikipedia. |
Bacteriophages, or just phages as their friends call them, are viruses that infect bacteria. As such, they can be used in place of antibiotics for infections that have become resistant to the antibio. Due to a fundamental difference in the way that human and bacterial cells work, the viruses do not infect human cells, and in any case our immune systems tend to clear most viruses (friendly or otherwise) from our systems.
Phages are naturally occurring - for example one being used to counter E. Coli was found in a river outside of Washington DC. This does not guarantee that it is safe, after all nature gave us the Polio and Smallpox viruses, but it does mean that if it is a problem, then at least it's not a new one.
Monday, April 11, 2011
BYBS: Fresh Air at Sea

The NPR story on the wild and slimy life of undersea critters can be found via this link, while the story on Moby-Duck can be found to via this link.
The pictures lead to links where the books can be obtained on Amazon.
The title and subject matter are reasons enough to create a blog entry for the book, but another reason is that she used to be the chief science officer/whatever of the Aquarius underwater habitat. Aquarius is a habitat that sits off the Florida keys under around 60 feet of water.
Apart from anything else that various free-living underwater critters might be doing down there having what amounts to an underwater base sounds like the coolest job one could ask for.
Now mind you, after 4 weeks of the same knock-knock jokes and losing yet another thumb wrestling match to your fellow diver could begin to get on your nerves, this could explain my interest in the second book: Moby-Duck.
Some people might hear about a bunch of rubber (plastic?) ducks being thrown overboard and conclude that the ducks had done something to merit walking the plank.
Other people might spend a fairly long period of time tracking down where the ducks came from, how they got from the Pacific to the Atlantic ocean and generally make any of my own time-wasting activities seem trivial by comparison.
In addition to shoring up the self-esteem of anyone with a strange obsession, the book also talks about the problems with plastic sea junk that is accumulating in the Earth's various oceans. This adds an instant air of seriousness that one cannot get from a book that goes into the mechanics of, say, lobster sex.
I haven't read either book --- we'll see if I get around to it, but in the mean time I can relax with the notion that if I met either of these people, I'd no longer be the strangest person in the room.
Sunday, April 03, 2011
Microbe Power Grids
I recently found this article from the cool, super cool, way cool geobactor web site. It details about how microorganisms work together to transmit electricity from the bottom of a pile of mud to the top of the pile.
Yes, mud.
Why are you looking at me that way?
At any rate, I think this is uber-cool because it shows again how those little fellers can surprise us by doing stuff that one would normally associate with bigger critters; but also how microbes could be harnessed to generate power from things like sludge. Or mud.
There you go again with that look.
Another truly cool article goes on about how two species of microbe can work together to break down ethanol. Yeah, as Dr. Derek Lovely puts it "They're the ultimate drinking buddies, collaborating to consume ethanol." It has a sort of poetic justice to it: microbes create alcohol, here are a couple of species that collaborate in drinking it.
Silliness aside, being able to make a cheap, efficient fuel cell using ethanol has been a goal of scientists for quite some time. The idea is that you could make a "battery" for a lap top that could last for 10 hours at full power or perhaps store the power from a solar cell for periods when the sun isn't shining.
And yes, the idea of microbes boozing it up has a certain appeal.
Monday, October 12, 2009
BYBS: Viral Gene Therapy
Science News, October 10, 2009
Now that we are heading into the flu season I thought it was appropriate to talk about how wonderful viruses are.
Maybe they're not, but I thought it would be nice to talk about how wonderful some viruses are. Specifically, using the power of the little buggers to help monkeys and, one hopes, people with various problems.
One area I find particularly fascinating is the area of viral gene therapy. The idea is to use a virus as way of sending genes to cells of an animal after they are mature. While some genes are only important for the structure and growth of an organisms, other genes affect the way that an organism functions after it is grown. In the case described in the Science News article, the genes enable the eyes of a grown monkey to detect frequencies of light that they could not previously see.
This particular study has all kinds of implications. The article is mostly about how neurologists were surprised that a full grown monkey's visual system could accommodate the new colors. The thing I find really cool is the almost offhand way that using a virus is being used in this experiment.
During my lifetime, I have seen the concept of using viruses for this sort of thing go from the realm of theory to the point where it barely raises an eyebrow.
Then there is the whole meddling with the human genome business, but I think I can stretch that out into a whole other posting.
At any rate, I like this sort of news. I find the ability of humanity to turn something that is often times an agent of destruction (think disease causing viruses) into an agent of help.
Monday, September 28, 2009
BYBS: Brain Science Podcast
So I was, as usual, trying to find a topic to blog about. It being Monday morning at 6am, and therefore just a wee bit past Sunday (though the whole BYBS thing is as much of an excuse to get me to do something as anything else, but that's another story) and I was debating whether to blog about a kick-butt Podcastle episode or a kick-butt episode of Brain Science Podcast.
I finally settled on Brain Science Podcast, specifically episode number 59: Interview with Guy Caldwell. This is mostly because Dr. Caldwell brings a certain enthusiasm to what others might consider to be a boring topic: worms.
In particular, he talks about a worm called caenorhabditis elegans, or C. elegans as this critter goes by at cocktail parties. C. elegans has a number of distinctions which make it useful to scientists like the fact that the complete cell lineage for the critter has been determined.
Can you imagine the people who had to do that job?!
Cell number 2,643...check...2644...check...2645...check.
I would gasp with disbelief at the mind-numbing nature of that job if it were not for a) the unbelievably boring nature of many jobs that people do and b) I'm not sure that this critter actually has that many cells.
Anyhow, one of the cool things this guy managed to do with C. elegans is to paste some jellyfish genes that give off light into the neurons of the worm so that one could, for example, see if some combination of conditions was causing said neurons to die off. That, in turn, came in handy for helping to tease out some aspects of Parkinson's disease.
Put another way, you could take a look at a worm and ask a simple question like: "Hey is the thing glowing? No? Then all the dopamine producing neurons are dead." This is much simpler than getting a worm analyst to talk to the thing.
It's stuff like this that wins the "aint it cool?" category for extreme cleverness, but then there's the whole issue of Dr. Caldwell's enthusiasm for the subject. I mean it sounds like he actually enjoys this work.
As someone who at times feels like a burn-out, chewed up, dehydrated husk of a human being, listening to someone with that sort of vigor brings back fond memories. He speaks with admiration for the guys who sat there and catalog cell lineages. He talks about how his research could be used to create therapies for Parkinson's disease.
That's the kind of energy and optimism, the looking forward to tomorrow that I find inspiring.
Thursday, April 16, 2009
Erm...you're sure about this, right doc?
I recently heard about a rather...unexpected medical therapy being used: using organisms that are commonly considered parasites to help treat certain conditions.
I'd like to ask those of you who are easily grossed out to stop reading now.
OK, I expect that most people, easily upset or not, are still reading, but just remember that I warned you!
I am talking about the medicinal use of maggots and leeches. Now aren't you glad that I didn't put up a picture at the start of this article!
Much to my surprise these approaches are actually being used today, and for very good reasons. In the case of leeches, the critter is very good at getting rid of blood that can accumulate in a reattached limb, such as a finger.
When something like a thumb is reattached, the artery (a very small one I guess) that carries blood to the digit is reattached, but the veins that carry blood away from the finger take a bit of time to reattach on their own.
Enter the leech! Rather than draining the reattached thumb of excess blood several times a day using a syringe, one can use a leech instead. The advantage here is that you don't end up with multiple syringe wounds, that are more likely to become infected.
The leech is very good at keeping blood from coagulating, which is the reason why you would have to create multiple syringe wounds to accomplish the same thing.
The maggots (yes, fly larvae) are used in some conditions where you have dead tissue that needs to be removed from a patient. One problem with such tissue is that it can be infected by bacteria that are resistant to antibiotics.
Such situations are becoming more common because more people are finding themselves with diabetes. Apparently, people with that disease can end up with limbs that have dead tissue, hence the problem with infections.
Maggots were used more commonly in the past, but were abandoned in favor of antibiotics when such chemicals became available. Because strains of resistant bacteria are becoming more common, doctors are turning to novel therapies that do not rely on anti-bios.
Regardless of the benefits of such approaches, I find the idea of partnerships between species --- symbiosis --- to be an interesting one. Furthermore, it's something that seems to pop up again and again in biology. Finally, I'm a lazy person and I realized that my topic for the coming BYBS might need some more lead-in; hence the value of this posting :-)
P.S. Since we're at the end of the article, I can now show pictures. Actually, I don't think this one has a lot of "gross me out" value, but your mileage may vary.
P.P.S. This was taken from a very interesting article from Wikipedia.
A wound cleaned by maggots





