Two months ago I was showing my friends a film called “The Great Global Warming Swindle.” As the title suggests, the topic of the movie is the global scale deceit about the man-made global warming. A number of important scientists argue that man has nothing to do with the rise of temperature and everything happens of natural causes.

Link: The Great Global Warming Swindle

After a hacker broke into the computers at the University of East Anglia’s Climate Research Unit, stole and published on the internet tens of megabytes of data and emails, it seems that the premises for the greatest scandal in modern science are set, and the truth will be finally revealed. These information show that top scientists have deliberately alter data to exaggerate global warming, destroyed embarrassing data, pushed for discrediting scientists that had other views on the topics, and others. This scandal is now referred to as Climate-gate.

I suggest that you watch the movie. It explains both what is causing the rise in temperature and why all the fuss around this phenomenon.

Now, the theory about man-driver temperature rise is based on two ideas: temperature variations depend on CO2 level variations, and man activity increases the CO2 in the atmosphere. Here are two charts from Wikipedia that show the variation of temperature in the last 150 years and last 1000 years.

Source: Wikipedia - Temperature record of the past 1000 years

Source: Wikipedia - Temperature record of the past 1000 years

Source: Wikipedia: 1000 Year Temperature Comparison

Source: Wikipedia: 1000 Year Temperature Comparison

You can find more charts here.

What these charts show is that in the last 150 years the temperature has risen and fallen. The greater rise occurred before 1940. And after 1940, when the world entered an economic boom, the temperature dropped for 3 decades. That doesn’t make any sense if the original hypothesis, that the more CO2 the greater the temperature, is true, because booming economies mean more CO2 being produced. In fact, the scientist were alarmed that a new ice age was coming. On April 28, 1975, Newsweek published an article about cooling and the effects on the planet. Here is a quote from the article:

There are ominous signs that the Earth’s weather patterns have begun to change dramatically and that these changes may portend a drastic decline in food production – with serious political implications for just about every nation on Earth. The drop in food output could begin quite soon, perhaps only 10 years from now. The regions destined to feel its impact are the great wheat-producing lands of Canada and the U.S.S.R. in the North, along with a number of marginally self-sufficient tropical areas – parts of India, Pakistan, Bangladesh, Indochina and Indonesia – where the growing season is dependent upon the rains brought by the monsoon.

Read the entire article here.

Then the question is, is there a link between CO2 and temperature? The answer is yes, but it’s mostly the other way around: the temperature is driving the CO2 level, with CO2 lagging 800-1000 years behind the temperature changes. Here are some charts of atmospheric CO2 concentration and temperature in lower atmosphere for the last 400,000 years.

Atmospheric CO2 Concetrations for last 400,000 years

Atmospheric CO2 Concetrations for last 400,000 years

Temperature of Lower Atmosphere for last 400,000 years

Temperature of Lower Atmosphere for last 400,000 years

Here are several articles on this topic:

The rise of temperature causes a rise of atmospheric CO2 because when the ocean warm the solubility of CO2 in the water falls, which leads to more CO2 being released into the atmosphere from the oceans. The amount of CO2 released in the atmosphere by man is much less than the one released from the oceans. Why is there a lag between the rise of temperature and CO2? Because the oceans act as a big buffer, but the exact dynamics are not yet well known. However, this doesn’t mean that the greenhouse effect doesn’t exist. It does. As more CO2 is released into the atmosphere, it absorbs more radiation reflected by the earth surface, heating the atmosphere.

So why is temperature rising? What is driving it? Well, the answer is the sun. The more solar activity, the more solar wind and cosmic dust hit the atmosphere which influences the formation of clouds and eventually the temperature. The next images shows the correlation between solar sunspots and global temperature variations.

Solar sunspot activity vs. Global temperatur variations

Solar sunspot activity vs. Global temperatur variations

400 years of Suspot Observations

400 years of Suspot Observations

Temperature, Co2 & Sunspots

Temperature, Co2 & Sunspots

You can read more about sunspots observations here:

Of course, not everybody agrees that Temperature, CO2 & sunspots correlate. For instance, you can read the following article that claims the opposite. It could be possible that this hypothesis is wrong, as many other theories were proved wrong over time.

Hopefully in the coming years (because this will take some time) the truth will be revealed. It would be silly to waste our efforts on the wrong direction. However, whatever the truth is, consuming the planet’s resource on a ever growing pace will prove catastrophic. We will never be able to kill the planet. But the planet can terminate us at any time.

Hits for this post: 8615 .

I have updated my Visual Studio addin that displays the status of a build/clean/deploy action. If you get the latest version, 1.2, and are running Visual Studio 2005, 2008 or 2010 (they are all supported) on Windows 7, the progress of the build is also displayed on the Taskbar, on the item corresponding to the Visual Studio instance.

The following images show no progress, different progress steps, and an error during the build/clean/deploy, both for Visual Studio 2008 and Visual Studio 2010 (Beta 2).

No progress

Build progress

Build progress

Error during build

Build progress

Error during build

This was possible by using the Windows 7 Taskbar interop library available on MSDN Code Gallery here.

You can get the latest version of the addin from the Visual Studio Gallery at this link.

, , , , , Hits for this post: 23055 .

I recently found a piece of code that can be summarized by the following sample:

interface I
{
   void F1();
   void F2();
}

class X
{
   public void F2() { Console.WriteLine("F2"); }
}

class A : X, I
{
   public void F1() { Console.WriteLine("F1"); }
}

As you can see there is an interface I that has two methods, F1 and F2. A is derived from X, that has a method F2, and also implements I, but only contains F1. I was puzzled at first, because I was expecting that A was explictitly implementing all the methods defined in the interface I. But F2 was implemented in X, its base class. After thinking a little bit it all become clear. This was a normal behavior of the compiler.

When a class A implements an interface I it guarantees that it supports (implements) the entire contract that the interface defines. But it does not assert that it will explicitly implement all the interface members within its explicit definition. I’m stressing on the explicit word here, because A extends (is derived from) X. That means A is an X. Everything that X exposes (i.e. what is visible to its derived classes) is part of A too.

In our case, F2, implemented in X, is also available to A, because A is an X. Since both F1 and F2 are members of A, then it means A fully implements I, which makes the code compile just fine.

How is this helpful? Suppose you have several interfaces that all define one ore several members with the same meaning.

interface I1
{
  void F1();
  void F2();
  int ErrorCode { get; }
}

interface I2
{
  void G1();
  void G2();
  int ErrorCode { get; }
}

interface I3
{
  void H1();
  int ErrorCode { get; }
}

Instead of providing the same implementation several times, like in the following code, you can have only one implementation for the common functionality.

class A : I1
{
  private int m_errorCode;

  public void F1() {}
  public void F2() {}
  public int ErrorCode { get {return m_errorCode;} }
}

class B : I2
{
  private int m_errorCode;

  public void G1() {}
  public void G2() {}
  public int ErrorCode { get {return m_errorCode;} }
}

class C : I3
{
  private int m_errorCode;

  public void H1() {}
  public int ErrorCode { get {return m_errorCode;} }
}

We can create one class that provides the implementation for ErrorCode and let the others extend it and implement the corresponding interface.

class X
{
  protected int m_errorCode;

  public int ErrorCode { get {return m_errorCode;} }
}

class A : X, I1
{
  public void F1() {}
  public void F2() {}
}

class B : X, I2
{
  public void G1() {}
  public void G2() {}
}

class C : X, I3
{
  public void H1() {}
}

, , , Hits for this post: 10809 .

In this post I want to show how you can implement common list operations: union, intersection, difference and concatenation.

Concatenation is the simplest of them all, because type List already has a function call append that does everything for you.

let concat left right =
    List.append left right

The union of two lists is a list containing all the distinct elements from the two original lists. We can implement this operation by concatenating the two lists firsts, and the filtering the distinct elements.

let union left right =
    List.append left right |> Seq.distinct |> List.ofSeq

The intersection of two lists is a list containing all the elements of the first list that also appear in the second list. We can implement this by interating through the elements of the first list and checking whether the element appears in the second list. To do this in the shortest possible time, with constant lookup time, we can use a HashSet collection. The result is an O(m+n) complexity instead of O(m*n) if you used brute force.

let intersection (left:list< 'a >) (right:list< 'a >) =
    let cache = HashSet< 'a >(right, HashIdentity.Structural)
    left |> List.filter (fun n -> cache.Contains n)

The difference of two lists is a list containing all the elements from the first list that are not part of the second list. The implementation of difference is very similar to the implementation of the intersection. All that differs is the lambda used for the filtering.

let difference (left:list< 'a >) (right:list< 'a >) =
    let cache = HashSet< 'a >(right, HashIdentity.Structural)
    left |> List.filter (fun n -> not (cache.Contains n))

Let’s see all these put to a use:

let main() =
    let c = concat [4;3;2;1] [2;3;5]
    printfn "%A" c

    let u = union [4;3;2;1] [2;3;5]
    printfn "%A" u

    let i = intersection [4;3;2;2;1] [2;3;5]
    printfn "%A" i

    let d = difference [4;3;2;1] [2;3;5]
    printfn "%A" d

main()

This program yields the following output:

[4; 3; 2; 1; 2; 3; 5]
[4; 3; 2; 1; 5]
[3; 2; 2]
[4; 1]

Notice that these operations work with unsorted lists. You don’t have to sort the lists first to apply them.

In order to use the HashSet, you need to add a reference to the FSharp.PowerPack.dll assembly. This sample was build with F# 1.9.7.8 for Visual Studio 2008.

UPDATE: You can read about similar implementations but using operators on this post by Jason Kikel. He also deals with repetitions, regular expression binding operator and null coalescing binding operator.

, Hits for this post: 10521 .

Am asistat astazi la evenimente similare celor din decembrie 1989: incercari de manipulare si denigrare la nivel national. Se intampla evenimente importante la Timisoara, Bucuresti, Brasov si alte orase si aproape nici o televiziune nu arata faptele. E probabil primul pas spre ce se va intampla de acum incolo daca Mircea Geoana, condus de grupurile de interese care il promoveaza, va ajunge presedinte. Se intampla ca in urma cu 20 de ani cand la Timisoara mureau oameni si Ceausescu anunta de la Bucruesti ca sunt doar grupuri de huligani ca sparg vitrine. Televiziunile grupurilor de interese nu arata nimic din ce se intampla la Timisoara, anuntand doar ca sute de manifestanti (probabil mult sub cifrele reale) sunt imprastiati cu spraiuri lacrimogene de jandarmi. Nu este adevarat, in centrul Timisorei nu au iesit huliganii care sparg vitrine ci oameni care nu acepta ca Geoana si Antonescu, cu binecuvantarea lui Ciuhandu incearca sa semneze “Pactul de la Timisoara”, aratand unei tari intregi cum Timisoara si Vestul au uitat de ce s-a intamplat inainte de ’89, ce s-a intamplat atunci si dupa, si si-au dat mana cu partidul lui Ion Iliescu. Ei bine domnilor, v-ati facu calcule gresite, pentru ca Timisoara nu acepta ca simbolurile revolutiei sa fie deturnate de pactul liberalo-comunist.

Tot ce se vede la unele televiziuni (a raror nume nici nu mai trebuie sa-l dau, pentru ca de 5 ani au acelasi program jenant in fiecare seara) sunt doar “violentele” de aici. Nu s-a intamplat nici o violenta, sunt doar cuvinte mari cu care unii incearca sa minimalizeze manifestarile anti-geoana-antonescu, anti-comuniste de la Timisoara. S-au imbrancit 2-3 oameni, jandarmii au intervenit sa-i desparta si acestea sunt marile violente care s-au desfasurat la Timisoara. Iata aici un video in care se vad aceste “violente”, aceste “acte de huliganism”. Domnul Geoana nu a avut curaj sa vorbeasca oamenilor direct, a preferat discursuri din incinta Operei.

Trebui sa spunem lucrurilor pe nume: Pactul de la Timisoara, prin care PNTCD ofera sprijin aliantei PNL-PSD nu inseamna nimic. De ce? Pentru ca Ciuhandu a distrus acest partid, astazi mai ramanand doar cel mult cateva mii de simpatizanti la nivel national. Si probabil cel mult cateva sute de votanti in Timisoara. Asa ca voturile PNTCD care ar putea veni de aici nu au nici o importanta. Ce are importanta insa e imaginea pe care Geoana spera sa o obtina pozand in Piata operei la Timisoara. Ei bine, dupa cum scria pe pancarte, Timisoara nu e a voastra. Timisoara e a noastra, si veti vedea asta duminica la vot.

Iar despre primarul Ciuhandu tot ce pot sa spun e ca prin gestul de astazi a murdarit imaginea si istoria partidului taranist. Cei prezenti la Timisoara pentru semnarea acestui pact au invocat numele si memoria lui Corneliu Coposu. Vazand ce se intampla, probabil Corneliu Coposu se zvarcoleste si urla in mormant.

In final, tot ce pot sa spun e: RUSINE domnilor Geoana si Antonescu pentru ca ati incercat sa deturnati simbolurile revolutiei din ’89 de la Timisoara chiar de ziua nationala a Romaniei in scopuri electorale. RUSINE domnule Ciuhandu pentru ca ai vandut partidul taranist lui Ion Iliescu facand de rusine memoria inaintasilor tai. RUSINE mass-mediei din Romania care manipuleaza pe fata populatia, dupa modele comuniste. Mi-e frica sa ma gandesc ce va urma daca tara va intra pe mainile acestor oameni.

Hits for this post: 3013 .