Drawing Blanks

Premature Optimization is a Prerequisite for Success

Archive for January 2010

Go see bananafish

leave a comment »

Salinger died. His books have been a great inspiration to many.

bananafish

Written by bbzippo

01/29/2010 at 5:24 am

Posted in Uncategorized

An interview question

leave a comment »

Next time when i interview a .Net developer I’ll ask what this command does:

tasklist /m "mscor*"  

Anybody should be able to guess.

Answer:

Read the rest of this entry »

Written by bbzippo

01/29/2010 at 2:53 am

Posted in programming

Hitchhiker’s guide to LINQ

leave a comment »

    class Question { }
    static class Earth
    {
        public static string Select(this int source, Action<Question> selector)
        {
            if (source != 42)
                throw new ArgumentException("Wrong answer");
            return "How many geeks does it take to screw in a light bulb?";
        }
    }
 
var q = from answer in 42 select new Question();
 

LINQ in C# is just syntax for calling the “query pattern” extension methods. At first glance, this is striking: the words “select”, “where”, etc. may mean anything. It’s the Enumerable extensions that define the “standard model” which assigns the query semantics to LINQ. But look at operator overloading: “==” can mean anything, “+” can mean anything, and life is not too bad.

Semantics = “antic mess”

Written by bbzippo

01/25/2010 at 6:03 am

Posted in fun, programming

MapReduce patented

leave a comment »

Google has been granted a patent on “System and method for efficient large-scale data processing” http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO1&Sect2=HITOFF&d=PALL&p=1&u=%2Fnetahtml%2FPTO%2Fsrchnum.htm&r=1&f=G&l=50&s1=7,650,331.PN.&OS=PN/7,650,331&RS=PN/7,650,331

I’m not going to discuss the fact of patenting itself. But when I read about it I started to click around and found a couple of amusing discussions which I hadn’t read before. A few years ago, when Google started to hype MapReduce, many bloggers (and non-bloggers) were spreading that hype without understanding what MapReduce really is. I argued with many folks and was trying to make the following simple points:

  • MapReduce is not used by Google as a distributed DBMS, or as any sort of data retrieval / query execution system.
  • It’s probably not a good idea to use MapReduce as a DBMS.
  • MapReduce is based on trivial ideas. It does not deserve the hype.

At that time I wasn’t aware of these heated discussions (that are now even documented in Wikipedia):

http://databasecolumn.vertica.com/database-innovation/mapreduce-a-major-step-backwards/
http://databasecolumn.vertica.com/database-innovation/mapreduce-ii/
http://typicalprogrammer.com/?p=16
http://www.networkworld.com/community/node/40882

Another interesting thing: Microsoft presents Dryad to Google . (11/01/07)

Dryad: http://research.microsoft.com/en-us/projects/dryad/default.aspx

MapReduce with Dryad is one line of code: .SelectMany(mapper).GroupBy(selector, reducer)

Anagram of the day: Peace Drum = MapReduce, via Xworder

Written by bbzippo

01/20/2010 at 5:09 am

Posted in Uncategorized

45 degrees optimum: geometric proof

with 2 comments

In a previous post https://bbzippo.wordpress.com/2010/01/14/45-degrees-proof/ we saw that the 45 degree launch angle results in the maximum distance, because out of all rectangles having the same diagonal, the square has the maximum area. We used some basic algebra and the Pythagorean theorem to prove this fact. Now I’d like to present a purely geometric proof.

pyth

Again, let a and b be the sides of our rectangle and d be the diagonal. Let’s cut the rectangle along the diagonal, and take one half of it, which is a right triangle. Let’s arrange 4 copies of this triangle as shown in the picture. (You may recall this picture from one of the proofs of Pythagoras theorem). It is readily seen that the area of the triangle cannot be greater than 1/4 of the area of the square built on the diagonal, and that the maximum is achieved when the central square disappears, i.e. when a=b.

Now you don’t have any excuse for not teaching this to your third-graders.

Written by bbzippo

01/19/2010 at 5:17 am

Posted in math

Quantum computer calculates spectrum of hydrogen

leave a comment »

I think this is pretty cool

http://arstechnica.com/science/news/2010/01/2-qubit-quantum-system-used-to-model-the-hydrogen-molecule.ars

I wonder if they can calculate the proton mass using qubits any time soon?

http://physicsworld.com/cws/article/news/36756

Written by bbzippo

01/14/2010 at 6:52 am

Posted in Uncategorized

45 degrees proof

with 2 comments

Everybody knows that you should launch things at a 45 degree angle in order to maximize the distance. For some reason all proofs of this fact that I see on the web require either the knowledge of trigonometric identities or differentiation, or even both. In fact, all that is needed for the proof is Pythagoras theorem and some kindergarten algebra.

First, we do the usual physics. We say that the velocity is the vector sum of the horizontal and vertical components: V = Vx + Vy. We say that Vx is constant because no forces act in the horizontal direction. So the distance traveled equals Vx times the time traveled. And Vy at first decreases at the constant rate g, and then increases at the same rate. So the time until the fall is 2*Vy/g. Hence the distance is 2*Vx*Vy/g.

We want to maximize Vx*Vy keeping in mind that V is fixed. If you draw a rectangle with the sides Vx and Vy, you readily see that V is its diagonal and Vx*Vy is its area. So out of all rectangles having the given diagonal, we want to find one with the largest area. Obviously, it is the square. But we want to prove this. There is a number of ways to do that without using cosines and derivatives. There are probably some nice geometric demonstrations, but I’ll resort to algebra.

45

Let a (=Vx) and b (=Vy) are the sides of our rectangle and d (=|V|) is the diagonal. Let e=a-b. Then a=b+e. So the area S=ab=b^2+be. The diagonal squared d^2 = a^2+b^2 = (b+e)^2 + b^2 = 2(b^2+be) + e^2. But b^2+be=S. So, S=(d^2-e^2)/2. S is maximal when e=0, or a=b.

Brought to you by Fret of Ivy (an anagram of Forty Five, via Xworder)

Written by bbzippo

01/14/2010 at 6:36 am

Posted in math