You can avoid Google doing a barrel roll by encapsulating your query in quotation marks: "do a barrel roll" will not, ironically enough, do a barrel roll.
This should work for all easter egg queries: quotation marks signal to Google that it should search for the literal string instead of interpreting it to mean something else.
Compare:
This of course doesn't work when Google Instant is turned on, as Google will submit the search query before you can finish encapsulating the query in quotation marks. Unfortunately, this is a limitation/"feature" of Google Instant: to prevent Google from submitting the query before you're finished typing it, you'd have to disable Google Instant.
Beyond this, it's possible to disable certain types of Easter eggs, provided you know the nature of the Easter egg beforehand. You could, for instance, prevent the do a barrel roll Easter egg by adding the following snippet to your browser's custom stylesheet:
body {
-webkit-animation-name: none;
-moz-animation-name: none;
}
But since this would affect every <body>
tag on every webpage, it's not ideal either.
You could get around this by using Stylish, which allows you to specify site-specific custom stylesheets ("userstyles"). Creating a userstyle with the following should work:
@-moz-document: domain("google.com")
@-webkit-document: domain("google.com")
@document: domain("google.com")
body {
-webkit-animation-name: none;
-moz-animation-name: none;
}
Of course, while this would allow you to disable this specific Easter egg, Google can and most likely will come up with new ones that do unexpected things in the name of being quirky. Without disabling JavaScript or Google Instant, it'd be nigh impossible to prevent them from happening at least once.
Best Answer
The first thing that you should have in mind is that Google terms of services doesn't allow to do automated search queries. If you really need to do automated searches, then you should use another service, specially if you are looking to this for a long time and "hassle" free.
The above because despite if the user repeatedly do searches automatically or manually, Google might block the user and others using the same network from web searching. A soft measure is to present a reCAPTCHA but on the old official Google Help Forum there were reports that Google goes a bit beyond that by presenting even to all the users of the same ISP a message like "we detected that your network is doing automated searches ask for help to you network administrator" and point the users to the related help article. I know this because I'm a Top Contributor (now we are called Product Experts) and had use to participate very frequently on on threads about this and have scaled several them for attention of the community manager and specialists.
Related
From Server Fault
From Stack Overflow