Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Thursday, December 16, 2010

Revving Chrome for a Cause

Google's launched this great initiative/Chrome extension called "Chrome for a Cause," where for every tab opened (up to 250 tabs/day) Google will contribute towards charity. You can download the extension here:

http://www.google.com/chrome/intl/en/p/cause/

Now let's say you're in the mood to speedily log 250 tabs open, but your Ctrl+T muscles are sore. Several code solutions have popped up, including a full-on Chrome extension which automates the process.

My question: why can't this run in Javascript?

My response: Chrome for a Cause Fastest bookmarklet

Here's the code:
javascript:i=260;function addTab(){if(--i==0){clearInterval(j)}x=window.open('');x.close()}j=setInterval('addTab()',1000);void(0);

Just let it run for ~5 minutes, and you're done. You've helped provide a year's supply of clean drinking water for someone on earth.

Friday, February 26, 2010

An Open Suggestion to Wolfram|Alpha

It's just a suggestion, really: nested queries. This feature is partially implemented currently, as you can search things like "weather Chicago the day Barack Obama was born", but there's no reserved character system to input queries in queries and use the sub-queries results as arguments in the main query.

Example of possible use: "max({{life expectancy USA {{USA median age male}} male}}, {{life expectancy USA {{USA median age female}} female}})", where {{query}} denotes a subquery.

That particular example finds the life expectancy of American men and women of the median American age for their gender and returns the larger of the two. Normally this would take five queries:

USA male median age --> 35.4 years
USA female median age --> 38.1 years
life expectancy USA male 35.4 years --> 77.35 years
life expectancy USA female 38.1 years --> 81.76 years
max(77.35, 81.76) --> 81.76

With subqueries, however, we get a single mega-query which returns our answer (81.76 years) without several queries and copy and paste.

Just my two cents.

Thursday, March 12, 2009

Colbert Bump Bot

I ended up building an Applescript which will vote for Colbert once every two seconds. Behold, the Colbert Bump Bot:

repeat
tell application "Safari"
activate
do JavaScript "window.location = 'http://comments-submit.nasa.gov/commenting1/Comment.do?location=http://polls.nasa.gov/voteform.html&siteID=245486071&username=guest&email=guest@dummy.com&comment=Colbert'" in document 1
delay 1
activate
do JavaScript "document.frmcomments.submit();" in document 1
delay 1
end tell
end repeat


Note that it will bring Safari into window focus every second, so don't plan on working while this is running.

[Disclaimer: THIS INFORMATION IS FOR EDUCATIONAL PURPOSES ONLY. Please don't actively try to ruin or tamper with the poll.]