Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Wednesday, July 29, 2009

Multi-Parameter Firefox Keywords and Chrome Search Engines

By far, my most popular post is my guide on Firefox Keywords and Chrome Search Engines. I recommend reading that one to get caught up if you don't know what Firefox Keywords and/or Chrome Search Engines are.

Shortly after I wrote that, I found this post on Lifehacker explaining how to combine bookmarklets and keywords for some very clever and useful tricks, but it didn't work on Chrome as written, and I never got around to figuring it out. Tonight I finally took the time to figure it out.

The problem (besides the Lifehacker example being overly complicated) is that Chrome doesn't like {}'s in keywords. Those aren't really necessary unless your keywords are very complicated, though, so I got it to work. This is the code we'll be working with:

javascript:
var s='%s';
url='YOUR URL, WITH %s's FOR EACH TERM';
query='';
urlchunks=url.split('%s');
schunks=s.split(';');
for(i=0; i<schunks.length; i++)query+=urlchunks[i]+schunks[i];
location.replace(query);

As it says in the code, all you need to do is insert the url you want to use, with the usual %s's anywhere you want to insert a search term. You then set it up like any other keyword or search engine (see the other post for how to do that; note: you can just copy/paste the multi-line code into Chrome or Firefox, they don't require that you condense it down to one line first). To use it, just separate your search terms with ;'s.

This fairly simple code can let you do some very cool things. Here's an example for mapping between any two points in Google Maps:

javascript:
var s='%s';
url='http://maps.google.com/maps?saddr=%s&daddr=%s';
query='';
urlchunks=url.split('%s');
schunks=s.split(';');
for(i=0; i<schunks.length; i++)query+=urlchunks[i]+schunks[i];
location.replace(query);

I set this up as a Chrome search engine with keyword "mapp" (although something like "directions" might be easier to remember). If I type "mapp NYC; DC", I get a google map between New York City and Washington, DC.

A warning: if you include a space after the ; like I did in that example, you technically get a space before your second search term. I could probably over-complicate the code and clean that out, but it works fine for Google, and I can learn to avoid it once I set up ones that don't tolerate it. Oh, and if you include more ;'s than the keyword has %s's, the extra stuff will just be tacked onto the end (for example, "mapp NYC;DC;Other" tries to generate a map between "NYC" and "DC Other"

If you use this, please let me know in the comments if you come up with any clever ones. Remember: this works for any url that you want to insert something into, not just searches, so there are definitely some interesting possibilities out there waiting to be discovered.

Monday, June 29, 2009

Mad Science Monday, 6/29/2009

I'm a little late today (which is to say, I didn't write this over the weekend and schedule it to release at a seemingly random time during the day), so, to make up for it, I'm offering a twofer; one experiment that tested two hypotheses. They even threw in a little mad engineering to spice things up even more.

I first mentioned this story back in April, but it deserves a closer look. I really think it's going to end up being the biggest science story of the year.

Mad Observations: With things like the Human Genome Project and the other genome projects that preceded and followed it, we are gathering reams of data, more than we'll be able to fully investigate any time soon. At least, more than we can investigate by hand. But hey, computers are pretty advanced these days...

Mad Reference: "The automation of science." King RD, Rowland J, Oliver SG, Young M, Aubrey W, Byrne E, Liakata M, Markham M, Pir P, Soldatova LN, Sparkes A, Whelan KE, Clare A. Science. 2009 Apr 3; 324(5923): 85-9. I also recommend the excellent write-up on the research in Wired.

Mad Hypotheses: The first hypothesis was chosen by the researchers (who were bordering a bit on mad engineering, so the hypothesis is pretty close to "Let's see if we can do this"). It's along the lines of "It is possible for a properly programmed robot to investigate data, make a hypothesis, and test that hypothesis."

But then we get into the first experiment, and get the cooler hypothesis. The researchers programmed a robot, named Adam, to perform science. Without help, just looking at the data from the Saccharomyces cerevisiae (brewer's yeast) genome project and other genetic databases (plus a model of S. cerevisiae metabolism), Adam hypothesized that certain genes in the yeast genome coded for an enzyme that had a certain function in metabolism. These genes were there in the data, but had not yet been characterized. So Adam set out to characterize those genes, hypothesizing that they would produce an enzyme that would catalyze a certain reaction in yeast metabolism.

Mad Experiment: Unfortunately, I don't have full access to the article, and both the abstract and the Wired article are sketchy on the details here. I'll lay out a couple possibilities, though, for people interested in how a researcher (including a robotic researcher) might figure something like this out.

Put simply (but close enough to give the idea), Adam knew that yeast used an enzyme to turn compound A into compound B, and another to turn B into C, and yet another to turn C into D, etc. He just didn't know for sure what those enzymes were. Let's say he was hypothesizing that the enzyme he was looking at turns A into B.

One way to figure out if he's right would be to create a yeast cell that lacked the genes he was looking at (likely one at a time plus all three); the yeast cell would be exactly like a normal yeast cell, just missing the one gene he was looking at. If he fed normal yeast cells A, they'd grow and produce B, C, D, etc. If he fed his modified yeast cells A, if he was right, they wouldn't produce B, C, D, etc. He could then feed his modified cells B, and they'd then be able to produce C, D, etc. If any step of that didn't work as expected, his hypothesis would be false.

The other possibility would be that he directly characterized the genes, creating copies of the genes he was looking at in a test tube, supplying them with the components necessary to translate those genes into proteins, and seeing what happened when he put A into those test tubes. That sort of research is less reliable, though (if it doesn't work, it could be because you're missing some factor necessary to make the protein, not because the proteins are important in what you're looking at), so I think it's more likely that he used the first approach.

All this time, all the researchers did was supplied him with the chemicals he needed, and emptied out wastes. He did all the rest, designing and performing over a thousand new experiments a day.

They all laughed, but: Since I'm writing about it here, you've probably already figured out that it worked. He was able to identify that three previously uncharacterized genes in the yeast genome code for an enzyme that catalyzes a certain step in yeast metabolism.

The particular discovery made by Adam wasn't particularly Earth-shattering; he found something that would have otherwise have been assumed to be true, but he verified it. The next step is the cool part. Robots like Adam can now dig through the genomes that we've sequenced, making similar hypotheses and performing similar experiments. Now that we know that they work, the interesting part comes when they fail to verify what they're looking at. On top of verifying and adding to the body of science, they would then find something for us to look at more closely.

Mad Engineering Applications: Since this all started with a dose of mad engineering—specifically, making robots to analyze data, make hypotheses, perform experiments, and analyze their results—there isn't much left in this particular area for mad engineers to do. For a while now, this one's pure mad science. Hopefully they'll make us some more robots capable of performing other experiments, but, once they give us our army, it's scientists that will utilize that army. And hopefully more scientists (mad or not) will come up with more ways to apply this research, potentially dramatically increasing the rate of increase of the sum of human knowledge. "What we know" already increases dramatically every year, as does the rate of discovery of new information (so if it doubled last year, it's likely to more than double this year). If robot science catches on, the rate of increase is likely to go way, way up.

Have any ideas for what tasks we should set our army of robot scientists on? Let me know in the comments.

Sunday, March 08, 2009

Shared Google Reader Items, 3/8/2009

Here are my shared items from Google Reader. Enjoy!

Entertainment:
Geek Culture:
  • My friend Jon sent me an interesting site, listing "What's Special About This Number" for most numbers from 0 to 9999 (well, at least many of them, I didn't check whether it's more than 50%).
Technology:
  • A team at Arizona State University, working with E-Ink (the company that makes the digital ink for the Kindle and Sony Reader), have developed bendable, touch-screen e-paper. This is very, very, very interesting to me. Imagine having a reader you can roll up and put in a backpack or briefcase, but then fold out to read that day's newspaper or a new book. Neat.
  • A bionic eye has given a blind man weak sight. It's a big step in an awesome direction.
  • The Kepler space telescope, which will search for Earth-like extra-solar planets, launched successfully Friday night. I thought that was awesome enough, but then I found out (by crossposting my Google Reader links on Facebook) that a childhood friend-of-the-family worked on the launch as a NASA engineer. I'm so jealous.
Programming:
Science:
The Interwebs:
  • PDFVue lets you edit PDF documents online. Convenient.
  • Dropbox is a cool way to synchronize files between computers (for example, I use it to transfer docs from my office computer to home, and vice versa). If you sign up through that link, I get extra storage. It's win-win!
  • Stephen Wolfram claims that he has a site that can answer questions (ie, when you search for "How many bones are in the human body?", it will return an answer, rather than a list of pages that might have the answer). That will be very interesting if it actually works (come May, when the site says it will be available).
Politics:
As always, leave your comments on these or anything else below.

Tuesday, December 09, 2008

Today's Shared Google Reader Items, 12/9

Holy crap, I haven't done this since last Thursday. These are my favorite Google Reader shared items in that timespan.

Zombies:
Politics:
Science:
  • This article was entitled "Scientists Achive Mental Body-Swapping," but it's about getting people to essentially think as if they're in another body. It's not nearly as sci-fi cool as I thought it must not possibly be.
Technology:
  • The summary of this article about Hawaii's plan for a state-wide electric car network on Slashdot annoyed me. An electric car grid encourages/allows more efficient power generation; it takes the power generation step out of the car, so you can do whatever it takes to make the power generation clean on a statewide basis. It doesn't rule out wind and solar, it just puts that step in a centralized place.
  • I'm very annoyed that I didn't hear about/see the 3D NFL broadcast.
Biology:
  • There's some evidence that the herpes simplex virus (the virus that causes cold sores, among other things) causes Alzheimer's. It would be awesome if this pans out and leads to treatment and/or a cure.
Atheism:
  • Techskeptic (via Pharyngula) has a list of Atheist/secular charities. I've often wanted something like this myself, so it's nice that someone else compiled it for me.
The Internets and other Computeriness:
Programming (but the first one is awesome, Libby):
  • This evolutionary algorithm to create the Mona Lisa is stunningly amazingly awesome. It dovetails with something I've wanted to do, and might inspire me to finally get that project moving.
  • Google has announced Google native client, which promises to put code written for x86 processors onto the web. That's very, very cool, and opens up all kinds of possibilities.
Finally, uncategorized, I shared this old video of "Keeping the Dream Alive" by Munchener Freiheit (huh, I always thought the band was just "Freiheit"), because I missed it and randomly searched to see if it was on YouTube... and it was. Enjoy. Or, ya know, don't, if you don't like cheesy music. In any case, comment below.