Natural Code

Code, science and politics.

Let’s save this planet. It’ll be fun. Really.

From Bob Park’s What’s New :

UNCOOL: LOT OF HEAT FROM GLOBAL-WARMING DENIERS.
Suppose, I asked myself, that the deniers are right and the CO2 thing is a mistake? What will happen if the world takes the CO2 thing seriously, adopting common sense measures to counter anthropogenic warming and there never was any warming in the first place? 1) there will more non-renewable resources to leave to our progeny; 2) we will breath cleaner air and see the stars again, the way we saw them half a century ago; 3) we could stop paving over the planet, and 4) cut down on the number of billionaires. If we’re wrong we could have a party. We could have a party either way.

See, it’s not so bad, is it? Really, we’ll be OK if we get started on this right away, and we might even make money and invent some cool shit in the process.

Saving the environment is a reasonable, obvious thing to do, even if Stephen Harper thinks it’s a communist plot to destroy the economy of oil-producing nations.

July 31, 2008 Posted by naturalcode | Politics, Science, Technology | , , , , , , , , , , | No Comments Yet

The persecution of ‘Dr.’ Kent Hovind

From “The Fight To Save Dr. Kent Hovind” :

“But friends – there is one of Jesus’ flock that has been abandoned by America.  No – this is not a blood sucking Muslim – but a white Christian male.  Yes, this man should be at the very top of the Christian food chain – but instead he has been persecuted by the liberals in the Justice Department. This man is, of course, Dr. Kent Hovind – or as you probably know him – Dr. Dino.”

That’s silly, you know they don’t allow liberals in the Justice Department. They also don’t allow people who admire left-wing pro-choice nuts like Condoleeza Rice. Only good Republicans can properly deliver justice.

July 30, 2008 Posted by naturalcode | Law and Rights, Politics | , , , , , , , , , , , | No Comments Yet

Alaska : Lose The Clown

Sure, he thinks that the Internet is a series of tubes, and yet assumes himself knowledgeable enough to regulate said Internet, but at least he’s an honest, hardworking guy, right?

Not so much. It seems that corruption is never far behind incompetence : Senator Ted “An Internet Was Sent By My Staff” Stevens accepts bribes and lies about it, according to a federal grand jury that just indicted him on seven (7) felonies. He apparently accepted $250,000 in bribe money from an oil and contruction services company between 2001 and 2006.

Maybe the company in question paid him to issue his utterly ignorant statements about the tubular nature of the Internet in an effort to push their pro-pipeline oil agenda?

It would explain why the company in question is now out of business. The tube remarks didn’t go over so well, and we all got to see the proof of his ignorance thanks to one of the few Tubes that actually does make up part of the Internet.

Seriously though, Alaska. Lose the clown.

July 29, 2008 Posted by naturalcode | Politics, Technology | , , , , , , , | No Comments Yet

Why not talk to the police? It can never help you. Ever. Especially if you’re innocent.

The Innocence Project : In more than 25% of cases where people were convicted and later exonerated by DNA evidence, innocent defendants made incriminating statements, delivered outright confessions or pled guilty.

Innocent people admit guilt all the time. Don’t be one of them. Don’t talk to the police. If you really are guilty, sufficient evidence should be found in due time. There really is no need for you to provide the rope to hang yourself.

Cory Doctorow posted these two videos of a law professor and a cop explaining exactly why you shouldn’t ever talk to the police without a lawyer present. To sum it up briefly, everything you say can and will be held against you, and it will never help you. Ever.

I’ve only watched the first one so far, but this is a lesson I’ve learned from personal experience. You do not want to learn this lesson from personal experience. Learn it the easy way while these experts are offering to teach you.

July 29, 2008 Posted by naturalcode | Law and Rights | , , , , , , , , , | No Comments Yet

No secret software for public voting or security!

Another blogger has an article up about Christine Peterson’s talk at the O’Reilly Open Source Convention. She argues that privacy and security are compatible, and she’s right.

She predicts that Washington’s technologically clueless will use top-down, individual-surveillance methods when they have access to next-generation technology like high-precision chemical detectors, and that they will do it using secret procedures and secret software just as they have done with electronic voting.

Unlike what happened with electronic voting, she says, we need to see this coming, head it off, and make it clear that software secrecy and individual surveillance are bad security measures. It can’t be framed as a debate around open source software. It needs to be a security issue, and those of us who understand that the Internet isn’t a series of tubes need to explain it clearly.

Here’s my shot at it:

There is only one way of proving that a program is secure : getting as many people as possible to test it and examine the code. Anything short of this is a half-measure.

Any idiot can design a security system that he can’t figure out how to break. Diebold, the makers of the American electronic voting machines, may claim that their system is secure. All this means is that they haven’t spotted any flaws.

Their are a lot of smart hackers out there. Few, if any, work for Diebold. Many of them may be hostile to your country’s government or people.

Don’t assume you have the best hackers, or that secrecy will protect you. The Germans tried that in World War II, and their supposedly unbreakable Enigma cipher machine was defeated. Their secret communications were intercepted.

If we want to assure our physical security, we need to make our security systems open to inspection to make sure that they actually work.

We also need to use the tools we have to go after the threats that exist. As far as I know, there is no machine that detects terrorists. There are, or will be soon, machines that allow us to test for individual particles of specific substances. The obvious use that almost every politician will find for this? Drug testing. Cracking down a little bit more on what you get to do with your body. Taking away your freedom.

A sensible and effective security policy would be to use these detectors to find things like anthrax and plutonium. Something tells me that if you find the guys smuggling WMDs, you’ll find the terrorists.

Unless we do something about it, we will instead get a security policy based on wiretapping citizens and drug testing, using secret systems.

Telephone conversations are not a threat. Marijuana is not a threat. The real threats are natural and economic disasters, WMDs, private companies with exclusive control over the democratic process, and politicians who don’t understand security or technology.

July 28, 2008 Posted by naturalcode | Technology | , , , , , , , , , | 2 Comments

Randy Pausch on brick walls

Others have remembered him much more eloquently than I could have, so I’m going to keep this short and quote the Professor himself :

“So that was a bit of a setback. But remember, the brick walls are there for a reason. The brick walls are not there to keep us out. The brick walls are there to give us a chance to show how badly we want something. Because the brick walls are there to stop the people who don’t want it badly enough. They’re there to stop the other people.”

Whenever I need motivation to learn something new or accomplish something difficult, it helps to remember those words. There are no obstacles that can’t be overcome : there are only those which we put the necessary effort into overcoming, and those which we don’t want badly enough.

He will be missed, and his legacy will live on.

July 27, 2008 Posted by naturalcode | Technology | , | 1 Comment

Fire Katie Couric (hire a journalist instead)

Someone should lose their job over this, anyways. Here’s a brief timeline for those of us who are temporal-perception-impaired.

September 2006 : The Anbar Salvation Council is formed. This is known as the beginning of the Sunni Awakening, in which a majority of Anbari tribes aligned themselves with the American and Iraqi government forces and began fighting against Al-Quaeda.

January 2007 : Bush announces an increase in US troop levels in Iraq. This increase becomes known as the surge. Notice that this happens after the Awakening.

“So I’ve committed more than 20,000 additional American troops to Iraq,” says Bush, while US troop levels are slightly over 130,000.

March 2007 : US troop levels pass the 140,000 mark.

April 2007 : US troop levels pass the 150,000 mark. The surge troops Bush announced in January have mostly arrived.

July 21, 2008 : Barack Obama claims that the troop surge is not the only factor contributing to reduced violence in Iraq, saying it’s also because of “political factors inside Iraq that came right at the same time as terrific work by our troops.”

July 22, 2008 : Katie Couric interviews John McCain. She asks him for his response to Obama’s statement on the surge and reduced violence.

McCain claims (this is from the CBS transcript) that “Because of the surge we were able to go out and protect that sheik and others. And it began the Anbar awakening. I mean, that’s just a matter of history.” That’s right, he’s claiming that the 2007 troop surge caused a 2006 event.

Katie Couric, apparently as unaware as McCain that in this universe cause generally comes before effect, fails to call him on it. She follows up this complete fabrication, and the rest of his rambling Abe Simpson response, with the question “A commentary on what?”

You see, the last word in McCain’s answer was ‘commentary’, so she just asked him to explain that word. Hard-hitting journalism!

CBS news sensed that they were on to a big story about a presidential candidate’s lack of foreign policy knowledge and problems understanding how time works. They did the only thing they could as responsible journalists : they replaced McCain’s ridiculous answer with the answer to a completely different question.

McCain’s explanation of imaginary history was replaced by one of his canned slogans. And they aired it that way. CBS’s response?

“The report was edited under extreme time constraints and one piece of tape was put in the wrong order. Fortunately, this did not in any way distort what Senator McCain was saying.”

Bullshit. They didn’t just distort what he said, they replaced it with a fictional response that meant something completely different, in order to make him look better.

At best, it’s some incredibly lousy journalism.

July 24, 2008 Posted by naturalcode | Uncategorized | , , , , , , , , , | 2 Comments

Data streams, part 2

In a previous post I mentioned I was working on a program to test the data stream concepts from this article. I finished it and implemented the method for finding the most frequent element in a stream.

It keeps track of the most frequent element in a stream of letters or numbers using only two integer variables. It’s not guaranteed to be accurate, but it’s a constant-space algorithm that can work on a stream of indefinite length, and gives good results as long as the most frequent element makes up more than half of the total elements in the stream.

It’s more a small library than a program, actually. I just use it like this :

require 'stream_algorithm'

Which calls up this file. Next, I make a Stream Reader which I store in a variable…

reader = StreamReader.new.check :biggest_element,
:most_frequent
>Starting StreamReader...

…and tell it to check for the biggest element in the stream (takes only one integer variable to track), as well as the most frequent element in the stream (takes only two integer/string variables but isn’t always reliable).

NumberStream.new( reader, :length => 10,
:skew => {:toward => 2, :percent => 55} ).start

This creates a Number Stream, assigns it the Stream Reader, gives the stream a length of 10 numbers, and skews the odds so that 55% of the time, the stream will contain 2 instead of a random number. The stream is then started.

The output from this part of the program looks like this :

 >NumberStream running!
 >Reading : 3  3 x 1
 >Reading : 1  3 x 0
 >Reading : 2  2 x 1
 >Reading : 7  2 x 0
 >Reading : 2  2 x 1
 >Reading : 7  2 x 0
 >Reading : 2  2 x 1
 >Reading : 2  2 x 2
 >Reading : 2  2 x 3
 >Reading : 2  2 x 4
 >Stream stopped.
 >Biggest element : 7
 >Most frequent : 2
 

I can do the same with letters :

reader.check :total_amount, :most_frequent

stream = LetterStream.new( reader, :length => 10,
:skew => {:toward => 'i', :percent => 45} ).start

The Reader’s check method resets its instance variables, so it’s ready to be used on a new stream. I create a new Letter Stream, and it gives me something like this :

>LetterStream running!
>Reading : h  h x 1
>Reading : i  h x 0
>Reading : i  i x 1
>Reading : z  i x 0
>Reading : i  i x 1
>Reading : i  i x 2
>Reading : i  i x 3
>Reading : i  i x 4
>Reading : t  i x 3
>Reading : c  i x 2
>Stream stopped.
>Total amount : 10
>Most frequent : i

And finally, I can do something like…

10.times { stream.start }

…and it’ll make the stream run to its length ten times while conserving state between iterations.

I thought it was fun, anyways.

July 15, 2008 Posted by naturalcode | Technology | , , , | No Comments Yet

From the ShoesFest

Yesterday was the first installment of the ShoesFest, a day of testing / learning why the lucky stiff’s Shoes toolkit for making multi-platform windowed Ruby apps.

I was on the irc channel for most of the day. Someone on there asked if there would be regular events, and _why seemed open to the idea.

I finally read Nobody Knows Shoes, and I threw together this little program. It’s a fake login window that responds only to malformed SQL. I’ll make it better and more interesting.

Shoes.app :title => 'HTSL Login', :width => 400, :height => 300, :resizable => false do

  def login username, password
    if username == "' or 1=1; DROP TABLE users; --"
        alert 'Oh shit!'
      else
        alert 'Invalid username or password.'
    end
  end

  background gradient( rgb(150,150,255), rgb(255,255,255) )

  flow :width => '100%', :height => '70%' do
    stack :width => '60%', :margin => 50 do

      para "User name : \n\n", 'Password : '

      @username = edit_line :top => 3, :left => 105
      @password = edit_line :top => 46, :left => 105 

      button( 'Log in', :top => 100, :left => 110 ) { login @username.text, @password.text }

    end
  end

  flow :width => '100%', :height => '30%', :margin => 18 do
    para "Users currently logged in : #{logged_in = 1 + rand(2000)}\n",
    "Total users : #{logged_in + rand(1000)}"
  end

end

July 12, 2008 Posted by naturalcode | Technology | , , , , | No Comments Yet

Sixty-nine fascists : there’s still one place where the majority will defend Bush.

Tuesday night on Countdown, Rachel Maddow talked to Jonathan Turley, professor of constitutional law. The professor had this to say about the Democrats’ capitulation on the FISA bill :

“So, what the Democrats are doing here with the White House is they‘re trying to conceal a crime that is hiding in plain view, that everyone can see it.  And so, the argument for it is quite sill simple, nobody wants to have a confrontation over the fact that the president committed a felony, not once, but at least 30 times.  That‘s a very inconvenient fact right now in Washington.”

“I think that the founders would have found this incomprehensible.  The expanse of power to the point of including what is now defined as a federal crime.  And not only that, but the Democrats have learned well from Bush.

Because the telecoms are losing in court, because the administration is losing in court, they‘re just going to change the rules, so that these public interest organizations that have brought these cases will all lose by a vote to fiat by the Democrats.  It‘s otherworldly.”

MADDOW:  “Senator Obama says he does not like this bill, but he says he‘s supporting it as a compromise.  Is this a compromise?  Is that the right term for it?  Is he right?”

TURLEY:  “Yes.  I got to tell you, I am completely astonished by Senator Obama‘s position and obviously disappointed.  You know, all of these senators need to respect us enough, not to call it a compromise.  It‘s a cave-in.”

TURLEY:  “And, you know what‘s terrible is like one of those stories where someone is assaulted on a street and a hundred witnesses do nothing.  And in this case, the Fourth Amendment is going to be eviscerated tomorrow.  And 100 people are going to watch it happen because it‘s just not their problem.

But you talk about expanding the president‘s power, it‘s coming out of the marrow of the Fourth Amendment.  It‘s coming out of the bone.  And it‘s going to hurt.  And it‘s being done for political convenience.  There‘s not an ounce of principle, not an ounce of public interest in this legislation.

So, at least show us respect of not calling it a compromise.”

Amen. Calling it a compromise is an insult to Americans on top of the injury to the Constitution. Yesterday was a terrible day for freedom and justice, and the cowards that let this happen in a Democrat-controlled Senate need to be called out.

One more reason to use encryption wherever we can. If only Tor was faster.

July 10, 2008 Posted by naturalcode | Uncategorized | , , , , , , , , | 3 Comments