Archive for June, 2008

Thor’s Apocalypse

Posted on June 29th, 2008

Just over Grant’s Pass at 7:15pm and the sky turned black. Every mountain top was lit up with electricity and the rumbling of thunder was continuous. It’s not normal for it to be pitch dark so early. There are usually pauses between lightning strikes and the crash that announces their passage.Thundercloud (thanks NASA) I thought the apocalypse had arrived or, at the very least, I was under attack by Sauron’s minions or the Horde of Azeroth.

It was an apocalypse but it was Thor’s Apocalypse which is even worse than the other kind. I wanted to pray but I didn’t know any Norse prayers except the one you shout, sword in hand, before you give your life in battle.

There were no gaps between the lightning strikes now and finally the rains came. Just three big, lazy drops on my windscreen. Not enough for the wipers, but that was just a feint; cover for the ice storm which Thor cast down upon the citizens of Grants Pass and the weary travellers on I5.

The first one hit my windscreen so hard I thought it was a rock but I soon realized the real threat as the gods hit me with all the ice in Valhalla. I didn’t think my vessel would survive the attack so I pulled off the highway peering dimly through the hail to see the side of the road. My fellow travellers did the same and we cowered under the meagre shelter of a tree. I couldn’t bear to think of the damage that was happening to my car as the mini golf balls beat us into submission.

As quickly as it started, the deluge subsided and I u-turned back onto the now deserted highway. The on-ramp was already a torrent threatening to wash me away.

As I reached the highway, Odin pulled back Valhalla’s veil of darkness and showed me the bright, clear evening sky. A mirage of Shasta shone warmly in the dying sun, a beacon of hope after the madness and California whispered my name. Welcoming me home.

It’s not nice to make fun of people

Posted on June 24th, 2008

Especially when they are the most powerful person in the world.

Doonesbury

Mmmmmm Crabs…

Posted on June 24th, 2008

Problem 12

Posted on June 22nd, 2008

To save you going all the way to Project Euler to read it, I have copied problem 12 here for your puzzle solving convenience…

The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28.

The first ten terms would be:

1, 3, 6, 10, 15, 21, 28, 36, 45, 55, …

Let us list the factors of the first seven triangle numbers:

1: 1
3: 1,3
6: 1,2,3,6
10: 1,2,5,10
15: 1,3,5,15
21: 1,3,7,21
28: 1,2,4,7,14,28

We can see that 28 is the first triangle number to have over five divisors.

What is the value of the first triangle number to have over five hundred divisors?

In case you were wondering, the answer to problem 10 is


primes = Primes.new
puts primes.find_primes_less_than(2000000).inject{|s,n| s+n}

How come inject and collect haven’t caught on in other languages? They are awesome.

Look to the future

Posted on June 22nd, 2008

The Onion

Subtle muscular adjustments can show, from left, wistfulness, determination, and unbridled

Obama has been working on his looking-off-into-the-future pose.

“A nod is acceptable,” Hosking said. “The American people respond well to nods.”

Shouldn’t politicians know something about science?

Posted on June 22nd, 2008

The organization, Scientists and Engineers for America have put together a questionnaire that they are sending to all candidates for the congressional elections in November.

  1. Innovation. Science and technology have been responsible for half of the growth of the American economy since World War II. But several recent reports question America’s continued leadership in these vital areas. What policies would you support to ensure that America remains the world leader in innovation?
  2. Climate Change. The Earth’s climate is changing and there is concern about the potentially adverse effects of these changes on life on the planet. What is your position on the following measures that have been proposed to address global climate change—a cap-and-trade system, a carbon tax, increased fuel-economy standards, and research? Are there other policies you would support?
  3. Energy. Many scientists and policymakers say energy security and sustainability are major problems facing the United States this century. What policies would you support to meet the demand for energy while ensuring an economically and environmentally sustainable future?
  4. Education. A comparison of 15-year-olds in 30 wealthy nations found that average science scores among U.S. students ranked 17th, while average U.S. math scores ranked 24th. What role do you think the federal government should play in preparing K-12 students for the science and technology driven 21st Century?
  5. Water. Thirty-nine states expect some level of water shortage over the next decade, and scientific studies suggest that a majority of our water resources are at risk. What policies would you support to meet demand for water resources?
  6. Research. For many years, Congress has recognized the importance of science and engineering research to realizing our national goals. Given that the next Congress will likely face spending constraints, what priority would you give to investment in basic research in upcoming budgets?
  7. Health. Americans are increasingly concerned with the cost, quality, and availability of health care. How do you see science, research, and technology contributing to improved health and quality of life?

You can search by district to see the responses from your congresspeople and senators as well as their voting records on matters relating to science and technology.

Remember this password

Posted on June 21st, 2008

So far, the main new features in Firefox 3 seem to be

  1. We moved everything around so you won’t find it
  2. We broke all your plugins
  3. especially mouse gestures which you love
  4. and firebug

ok - the new drop down preview thingie in the address bar is quite useful but it’s not worth upgrading for. But, today, I found something worth having.

Ever gone to a site that needs your password and you go through a kafka-esque cycle of

  • Hmm, haven’t been here for a while, wonder what my password is
  • could it be this *****
  • DO YOU WANT ME TO REMEMBER YOUR PASSWORD!
  • ooh - that would be nice, then I’ll have it next time. OK
  • PASSWORD IS WRONG
  • maybe it’s this *******
  • DO YOU WANT ME TO REMEMBER YOUR PASSWORD!
  • well you weren’t very helpful last time firefox, were you? But, OK.
  • PASSWORD IS WRONG

The big feature in firefox 3.0 is that it only offers to remember your password after you typed in it correctly.

Forgetful me

Posted on June 21st, 2008

According to Kurzweil, the singularity (the moment when we will start to invent things instantaneously) will occur in 2045. According to me the singularity (the moment when I forget things fast than I can learn things) occurs in 2009.

Every time I start over with Ruby (or XSLT or …) I find that I have forgotten the most basic things (like how to construct an object).

Anyway, thanks to Project Euler (according to which, I am 4% genius), I had an excuse to go go back and learn Ruby all over again.

Here’s my prime number generator (which is about a third of the size of my Java version):


class Primes
  def initialize
    @primes = []
    @next_candidate = 2
  end

  def prime? number
    root = Math.sqrt number
    find_primes_less_than root

    @primes.each do |prime|
      return true if prime > root
      return false if number % prime == 0
    end
  end

  def find_primes_less_than limit
    until @next_candidate > limit
      @primes << @next_candidate if prime? @next_candidate
      @next_candidate += 1
    end
  end

  def [] index
    until @primes.size > index
      find_primes_less_than @next_candidate + 100
    end
    return @primes[index]
  end
end

The answer to problem #7 is @primes[10000], in case you were wondering.

Well said, Mark

Posted on June 20th, 2008

I have tried reading the bible about a dozen times but I always start with Matthew or Genesis but my eyes go all blurry at the all the begats in Matthew Ch1 and the bewildering number of people that appear and disappear in Genesis so I decided to skip Matthew altogether this time and go straight to Mark. What a fine idea that was.

I have been reading a little bit at bedtime  and I have actually been looking forward to it every night. It’s a good read. All the well known stories are there (the later ones anyway. Mark didn’t cover the nativity stuff.  Matthew and Luke made that stuff up to fulfill some earlier prophecy) and they are told in a very distinctive style. The stories are very precise in some details but he just glosses over big chunks of the rest of the story.

It’s odd which details get the precise treatment and which ones don’t. It’s almost as if he were just writing a story that would have been already familiar to his readers - or maybe he was jotting down the memories of an older companion who insisted that he get this bit just right.

Another odd facet of Mark is the way he has Jesus saying “but don’t tell anybody” after every good deed and, when he tells a parable, he explains it to the disciples in private so that no one else would understand. For someone who came for our salvation, the J-dude was pretty secretive with his advice. Or maybe Mark just wanted to show that he had some inside scoop that wasn’t available to the common Galilean Fanboy.

All the  books I have read on bible criticism seem to concur that Mark wrote after the destruction of the temple in AD 70. In other words, about forty years after the traditional date for Jesus’s death (that’s a bit like me writing about England winning the world cup “There are people on the pitch! They think it’s all over! ….It is now!” but Israel in 4BC had no mass communication. He also wrote in Greek in a country far away from the lands he talks about with such precision.

Maybe he was writing on behalf of a disciple (who was, presumably, illiterate)? That would explain all the obscure references - “make sure you tell them about the tax collector at Capernaum!…” - and big omissions and all the insider details.

Mark was supposedly the source for both Matthew and Luke which makes their accounts third hand at best. Let’s see if Luke does as good a job as Mark. The start looks promising…

Inasmuch as many have taken in hand to set in order a narrative of those things which have been fulfilled among us, just as those who from the beginning were eyewitnesses and ministers of the word delivered them to us, it seemed good to me also, having had perfect understanding of all things from the very first, to write to you an orderly account, most excellent Theophilus, that you may know the certainty of those things in which you were instructed.

Now, who was Theophilus, I wonder…

Wasting Time

Posted on June 15th, 2008

Project Euler. Wasting time with Maths.

My attempt at #3 is running now (which probably means it is wrong).