Sunday, November 16, 2008

A Programmer's (Over)View On Microsoft's PDC 2008

It has been two week that Microsoft's annual Professional Developers' Conference for 2008 came to an end.By all testaments I could find on the web, it has been a tremendous hit and the online sessions I have watched so far are really, really good.

Microsoft made a great deal of announcements: Windows 7 and Windows Azure were the most popular on the list. Apart from fancy high-tech jargon, if we were to decode in computer science terms where Microsoft places the big bets, we should mention:

  • Parallel Computing
  • Cloud computing
  • Managed Memory Framework (.NET)
Clearly, we have reached the limits of nature with these giga-capable processors on our ordinary laptops. And if we can't build better processors we can still build more of them. This is the rise of multi-core computers, and managing all these cores on the same machine is a great engineering task. Microsoft is, naturally, deeply faced with these engineering challenges that are at the heart of Windows 7 design. Windows 7 is the next desktop operating system from Microsoft, after the heavily criticized Windows Vista and its highly-advertised failure (actually Vista with Service Pack 1 has become much stable). Among other things, Windows 7, is claimed to be a much more scalable system, even up to 256 processors! Having this kind of scalability, is of course not targeted to low-end users like me and if it was, I wouldn't be able to notice it. However, if this is true, we could experience a sharp boom in high-end computational power. This interview with Mark Russinovich, a famous Windows Expert, will give you a much more technical view into the challenges of Windows 7.

In his keynote speech, Ray Ozzie (photo), Chief Software Architect at Microsoft, began with introducing Windows Azure, baptising it "Windows OS on the cloud". You can read my thoughts on cloud computing on a post I wrote some months ago. In summary, I am not the perfect fan of the idea but Microsoft on the other hand has no choice than competing directly with Amazon, Google and Yahoo! who are already into this area. Bundled with Microsoft's unbeatable developer support, it could rapidly gain much interest.

Finally, one cannot but take notice of the volume of sessions and talks about the .NET Framework which has already a prominent place in Windows developers. Microsoft is working hard on making it even more complete and adding all kinds of cool stuff in it. Microsoft announced .NET version 4.0 (current is 3.5) which will have a great deal of interesting goodies like parallel processing extensions, design-by-contract classes which lets build a kind of SLAs inside the code of your methods, a new functional programming language F#, and many more.

It is really to hard to have everything all included here. I made a quick overview, on Microsoft's take on the future and as time goes by I will try to research deeper on some things (functional programming is going to be our next topic). I highly recommend you to go over the PDC sessions which are available online. Even if you are not into Windows programming, they are very interesting and funny (especially the F# presentation)

So, to recap, Microsoft is moving, and when it does so, by the law of nature and given its big mass, it moves anything that surrounds it, and this is a fact either you hate or love Microsoft.

Wednesday, October 29, 2008

Using Perl Against Facebook - Part II: Status Updates

This post continues from Part I - Login to Facebook

By now, we are able to login to our Facebook account, so it is time to do more things with it. Facebook lets you publish your status, a short text descsribing what you are doing any time. It has a 160-char limit, just like the Twitter thing.

To get or set the status, we only need the homepage html page. To retrieve our status we just match it against a pattern and to set the status we send a POST request with the appropriate arguments. Here is the code:

#go to the homepage
$response = $browser->get('http://www.facebook.com/home.php',@header);

#Let's now post a new status
my $newStatus = "Testing DOL Code..";
$response->content =~ /id="post_form_id" name="post_form_id" value="(.+?)"/;

my $postformid = $1;
my %post_data = ("status"=>$newStatus,"post_form_id"=>$postformid);

$response = $browser->post('http://www.facebook.com/updatestatus.php',\%post_data,@header);

##Ok! The status was posted...
##Let's now see what we have done...


$response = $browser->get('http://www.facebook.com/home.php',@header);
if($response->content =~ /<span id="chat_su_text">(.+?)<\/span>/)
{
#Here is the new status
print "My status: ",$1;
}
else
{
print "Could retrieve status...";
}


This piece of code should be used in conjuction with the previous post. It assumes we have already setup the brower and the response object and that we have already logged in to Facebook. The code first posts a new status ('Testing DOL code...') and then tests if everything was setup ok.

Sunday, October 26, 2008

Using Perl Against Facebook - Part I: Login

After a small intervention about the economic crisis, it is time we get back to some hacking. This time we shall use Perl against Facebook, to do anything that Fb will not let us do. In this post I will just show how to login to Facebook. In the next post, I will dump the code on how to update your status.

For the history, Fb has indeed an API for developers that wish to build their application on the Facebook platform. You can start here, but this is not the place for me. The API does give you some choice but it was built with a different view in mind: 3rd party developers accessing peoples' accounts. This is why the API is very restrictive and it makes sense not letting an application do much with your data. There is also a plethora of the so-called Facebook clients, which in the majority are just a wrapper for the Facebook API (like this google code project). In most cases also you get redirected to Facebook pages. Shame..

So long for the Facebook API, let's get down on how to login to Facebook. Of course, language of choice is...what else, Perl (because simple things should be easy, and complex not impossible) In order to login to Facebook we have to follow these steps:

1. Go to 'http://www.facebook.com/login.php', and rest our virtual browser there to collect the cookies (GET request)
2. Visit 'https://login.facebook.com/login.php' with the proper parameters (POST request)
3. If we succeed then we can safely browse to 'http://www.facebook.com/home.php' to get our profile.

To do this we will need the LWP::UserAgent class (de facto in latest Perl distros) that will be our virtual browser. If we want to store the cookies we can use Http::Cookies. We will also need Crypt::SSLeay package so that our agent supports HTTPS. Ok. Let's do this.

Here is the complete code. Explanation follows.

my $email; #stores our mail
my $password; #stores our password
my $user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6';


$email = <>; #read the login e-mail

$password=<>; #read the password

chomp($email); #remove last line
chomp($password);

my %postLoginData; #necessary post data for login
$postLoginData{'email')=$email;
$postLoginData{'pass'}=$password;
$postLoginData{'persistent'}=1;
$postLoginData{'login'}='Login';

our $response; #holds the response the HTTP requests
#set the headers, let's make this a Firefox browser!
our @header = ('Referer'=>'http://www.facebook.com', 'User-Agent'=>$user_agent);

our $cookie_jar = HTTP::Cookies->new(file=>'fbkCookies.dat',autosave=>1, ignore_discard=>1);

our $browser = LWP::UserAgent->new; #init browser
$browser->cookie_jar($cookie_jar);

$browser->get('http://www.facebook.com/login.php',@header);

#here we actually login!
$browser->post('https://login.facebook.com/login.php',\%postLoginData,@header);

#was login successful?
if($response->content =~ /Incorrect Email/)
{
print "Login Failed...Quitting..\n";
}
else {
print "..and we are in!";
#let's go to the homepage
$response = $browser->get('http://www.facebook.com/home.php',@header);
}

Upon execution of the script we either get a Login Failure error or a message of success. In the subsequent article we will move on to how to get and set the Facebook status. Stay around because this will get more interesting. The final Perl script has about 500 lines of code and can send messages, retrieve inbox and chat among others!

Tuesday, October 14, 2008

Nouriel Roubini: The Prophet Of The Global Economic Crisis

In a recent article, Mr Richard Posner, tries to understand the most disturbing with this global economic crisis: "How come we didn't see it coming?" It is still disturbing but since it happened, Mr Posner argues we should be better prepared next time, perhaps with a CIA-type financial institution which will gather information from disperse places and shield markets against such kind of disasters.

However, Mr Posner is fair. Not all of us didn't see it coming. There were many warnings, the most notable coming from a teacher in the University of New York, Mr Nouriel Roubini (photo), who has been predicting for years and with 'uncanny accuracy' what has already happened: housing bubble burst, oil shock, consumer confidence decline and recession..And this is where our story begins.

Mr Roubini got his PhD from the Harvard University studying international markets and concentrated on recessions of emerging economies, which were typical in 90's. His methodology is distinguished for taking history and cultural evidence into account. Along the way, Mr Roubini defined the fundamental and common characteristics of these economies at the peak of the recession: huge deficits (spending more than production), borrowing, exposed banking system, and government corruption. These were the clues he was looking for in the next economy to suffer a crisis. And guess what: it was US' turn!

Still in 2006, Roubini predicted the abandonment of the dollar and its decline, the burst of the housing bubble, the meltdown of hedge funds and ...well all what we are seeing now. When the first bailouts for Federal Reserve were announced in Spring of this year, there was no doubt for Mr Roubini: crisis was upon and the worst were yet to come. The days of dismissive comments towards Roubini, like perma-bear (always predicting the worst), or pessimist have gone, and people are listening sharp of what he has to say.

So what really happened? Mr Roubini talks about the biggest asset bubble and credit bubble in the history of humanity, not only on the US but in many other countries as well, and not only in one sector (mortgage) but across many different sectors. So, in fact, we can talk about a housing bubble, a mortgage bubble, an equity bubble, a credit bubble,etc, all breaking at once!

What is Roubini's view of the bailout plans? He is really making a point I can really understand. Before pouring money into these companies, you first have to wipe out corrupt managers and shareholders. Just throw them out. Otherwise it is just a scandalous way to waste taxpayers' money buying for gold the very (toxic) trash that these guys invented.

This was as far as I could go. For your further information just follow the articles linked here. I am also embedding a highly interesting interview of Mr Roubini on Bloomberg TV, talking about the coming recession, shot on July 2008.



Roubini's blog - Roubini Global Economic Monitor: http://www.rgemonitor.com/blog/
Article in NY Times - Dr. Doom: http://www.nytimes.com/2008/08/17/magazine/17pessimist-t.html

Tuesday, September 30, 2008

CSRF Attack vs. Google's PageRank

Recently SlashDot had a very important story on a major security risk that all modern web sites face: The Cross Site Request Forgery is a malicious technique that can be used to exploit the trust that web sites have on their legitimate users (e.g. cookie)

A very simple example is provided in Wikipedia: http://bank.example/withdraw?account=bob&amount=1000000&for=mallory could be a URL that would withdraw 1M $ from Bob's account and put it into Mallory's. Bob may well have a cookie on his computer from his bank, still active, that would automatically authenticate him. Bob will only then see something like "Your transfer was completed succesfully!".

While exaggerating, this example shows well the fact that many modern web applications are heavily dependent on somewhat simplified authentication techniques (such as cookies). Properly crafted query sections of the URI(see here about URI structure), or script code, could then be used to enable requests from malicious entities. A slashdot user puts it well: "Repeat after me boys and girls "GET requests shouldn't change anything on the server"." 

The most scary thing is that this problem is everywhere. Major websites are vulnerable, and recently YouTube and NYTimes included! Any link we click on, any image or file, could be harmful. While there are some serious preconditions that have to be met so that it evolves into a big threat, security experts believe we have just seen the tip of the iceberg. From our side, we could keep track of what we click on, but how careful can we be? (like this phishing example)

One major implication could arise if CSRF attacks escalate: It could hit on Google's PageRank algorithm. PageRank is over-dependent on hyperlink text section, because it weighs it on what the target page is all about. Perfect example: This Google search for the term "recapitasse" will bring Developer On Line on the top 10 results. This is an Italian word, never-ever mentioned here, but this blog was linked once(for the Gmail scam) with this text, and until now "recapitasse" is supposed to describe the content of that blog post.

Anyway, if quality a-tag text is essential for PageRank and if CSRF undermines it, this is a problem. It could lead to much more extensive Google bombs than we have ever experienced. Overloaded social networks(like Facebook) can also be a great place for this 'web disease'. The threat is much greater than before, because CSRF attacks do not come from malicious sites that we can keep track of. Users just do 'semi-subconscious' actions (image-button clicks) on trusted sites as they usually do. The question remains as to whether the Internet itself can keep its content clean and scam-free. 

Further reading see here.

Thursday, September 25, 2008

Donald Knuth And The Complexity Of Songs

Donald Knuth is a living legend among computer scientists. His monumental work-of-life "The Art Of Computer Programming" (I was never able to fully follow it) is a standard reference/textbook/work of art for computer science. Mr. Knuth took a new, immature geek-only hobby and transformed it into a solid and complete scientific discipline.

Among his contributions, the systematic analysis of the complexity of algorithms, really stands out. As a concept complexity is very familiar to developers. It refers to how a specific algorithm or algorithmic solution to a problem scale to the 'problem size'.

If his work is a reason to admire him, his humor is a reason to love him. Recently, I had the most splendid time reading his hilarious paper titled "The Complexity Of Songs" ! Here is the story.

A song has some lyrics which we have to remember in order to sing it. Humans are trying to learn lyrics of length (space complexity) to sing a song of length n. You would expect mathematically that s ~ n, but Knuth investigates all human 'inventions' to reduce the song space complexity!!

After a series of 'theorems', Knuth proves the existence of songs with s= a.n, a<1, s="O(sqrt(n))," s="O(logn)">and finally.....s=O(1)!! Yes, you read well. 

Knuth argues the first step was the invention of the refrain, the repeated part of a song. If the song has m verses of length and the refrain has length R, then the song length is roughly n = V.m+R.m and the complexity s = m.V+R. Hence we have a reduction of V/V+R in song complexity. So, a refrain is also a tool to save some memory space to remember the song!

Remember the old song "Old Mc'Donald had a farm, Ei-gh,Ei-gh,Oh!" ? Well this has a complexity s = O(sqrt(n)). It is much like the Greek song "Οταν θα πας κυρα μου στο παζαρι...". In this pattern, each verse includes all previous verses. For verses n = o(m^2) and s = O(m), so s = O(sqrt(n)). This means that it is much easier to remember! That's why they are most suitable for children! A same pattern can yield a log complexity.

Now to the best part, Theorem 2 is the real killer! The introductory text goes as follows:"However, the advent of modern drugs has led to demands for still less memory, and the ultimate improvement of Theorem 1 has consequently just been announced:

Theorem 2 (Donald Knuth)
There exist arbitrarily long song of complexity O(1)

PROOF. Define U = 'uh huh','uh huh' and the k-th verse Vk = 'That's the way', U, 'I like it', U . This is a constant V. Then the song V^k, completes our proof!! Oh dear!

This last one really cracked me up!!!   :)

Tuesday, September 9, 2008

Greece Enters the Dark Ages

I thought there were 2-3 jobs that meant a lot of money: being a footballer player, a singer or a politician. But being a priest or yet better a monk means a 6-figure salary in Greece too. In all seriousness Greece is officially (re)entering Dark Ages after the huge scandal of illegal real-estate transactions among politicians, monasteries and offshore companies, came out to public. Along with a taste of disgust over recent cover ups of tax evasion tactics from prominent ministers of the Greek government, the public is haunted by a strange feeling of anger and despair.

In our new quest to plot the "grid of corruption" (remember Zachopoulos and Tsekou?), let's get down to the facts.

The players in this 'wild' scandal game are:

  • The Vatopedi Monastery of Agion Oros
  • Petros Doukas, vice minister
  • Aggelos Basiakos, former minister
  • Theodoros Roussopoulos, goverment press representative
  • Mara Zacharea, journalist
  • Giorgos Voulgarakis, minister
  • Aikaterini Kelpeki, lawyer
  • and finally...Kostas Karamanlis, Prime Minister
The Scandal:

Briefly to present the facts:
  • In 2002, the National Council of Public Estate, admits the Monastery of Vatopedi to be the legal owner of 25,000,000 square metres (!) on the lake of Vistonida
  • In August of 2002, Vice Minister of Economy, accepts the former decision
  • During the same year, the same Council decides that the Monastery is the legal owner of any land on the lake of Vistonida
  • In 2003, Vice Minister of Economy signs the decision
  • In 2005, the Legal Council of Greece, decides that the Minister of Rural Development is able to order the National Estate Company to exchange estate properties
  • In 2005, the Minister of Rural Development applies his right and commands the National Estate Company to exchange properties with the Monastery in the area of Rodopi and Xanthi
  • In 2006, the Minister of Rural Development and the Vice Minister of Economy, instruct the National Estate Company to exchange with the Monastery of Vatopedi, national properties (real estate built during Athens Olympics) for the lake of Vistonida
  • The national properties get highly undervalued while the lake of Vistonida receives an outstanding overvalue
  • In 2007, the exchanges take place
  • The monastery sells Olympic properties to off-shores from Cyprus
Let's see connect the bullets with the actual players:

The Vatopedi Monastery

This monastery (photo) is among the many monasteries and churches to be found on the Athos Mount, in the same peninsula. Mount Athos is independent from Greece and is a very famous visiting place, although only for men. The Vatopedi Monastery during the last years gathered around many Cypriots and is ruled by Εφραιμ(Efrem), a monk with distinct social connections. Efrem 'pioneered' a new type of religious activities. He used to transfer important sacred religious objects to highly powerful people (businessmen, prime ministers etc). This allegedly helped him create a very powerful social network (facebook is a joke).

The Vatopedi Monastery around 1998 started a crusade against the off
icial state claiming ownership of numerous real estates and land. In the most infamous legal battles, the monastery backed up its allegations based on decisions from Byzantine Emperors, dating back to 1900!

In 2002, the National Council for Real Estate, recognized the monastery as the owner of 25,000,000 square metres, around the lake of Vistonida. However, to ac
tually own it, the signature of a minister was needed.

Petros Doukas- Former Vice Minister of Economy

Petros Doukas (photo), now Vice Minister of External Affairs, was a Vice Minister
of Economy, during the "hot" period. As a public figure, I think people like him. Calm and reasonable as a person, he didn't do anything to cause any trouble, despite his heavy political duties.

Mr Doukas is accused of having signed the infamous decision to hand the lake of Vistonida over to the monastery. From his side, he has denied all accusations. In his blog one can read: "I found out that from 1999 to 2003, the case was closed, and the lake of Vistonida belonged to the monastery of Vatopedi. The Council for Real Estate is under the Minister of Economy, but acts independetly, which means I do not influence a single member of it...The Minister of Rural Development decided to exhange properties with the monastery due to public pressure."

Aggelos Basiakos - Former Minister of Rural Development

Mr Basiakos(photo) was among the "legion" of the Prime Minister, a faithful and close partner. Mr Basiakos is accused of taking the action to exchange properties with the monastery. It should be noted that this right to give such orders was decided the same year by the Legal Council. At speed light, Mr Basiakos applied his 'legal' rights. At first, Mr Basiakos ordered for exchanges of appartments and houses and in 2006 co-decided with the Minister of Economy to exchange the Lake of Vistonida.

Mr Basiakos, of course , has denied all accusations. A very interesting fact is that the Vice Minister of Rural Development at that time, had resigned, and the reason was, as he now says, great political pressure to sign these decisions, to which he was strongly opposed against.

Theodoros Roussopoulos

Former-journalist, Mr Roussopoulos(photo) is the invisible force that really governs Greek media today. He is very close to Prime Minister and enjoys complete support for whatever he does. Inside the government party, Mr Roussopoulos is considered an 'outlander', a man who immediately climbed up the party's stairs, but no serious objections were raised (until now) since he is a major factor of the party's resurrection. Among his many duties, Mr Roussopoulos distributes the multi-million national advertisement funds to TV and radio stations.

Mr Roussopoulos appears to have very strong relations with Efraim and the monastery of Vatopedi and also to be the owner of several luxury estates (that
arose during his government duties), while in the annual report for politicians' wealth, he claims his wife as the prime income source...

Mara Zacharea

A prominent journalist in Greece, having worked in many media. Recently, Mrs Zacharea left the Alpha TV stationa after long fights and joined several newspaper and radio media, not only as a journalist but also as a shareholder. It should be noted that Alpha TV was the one that researched for the monastery scandal and brought it to the public.

Mrs Zacharea is supposed to have good relationships wi
th Efrem and the monastery of Vatopedi. In the photo you can see an interview she had with Efrem in 2006.


Giorgos Voulgarakis

This man was brought up to be a politician. He recently faced heavy cr
iticism for establishing private companies, transferring funds from Cyprus off-shore companies to avoid taxations. Mr Voulgarakis, now Minister of Mercantile Marine, has also served as a Minister of Interior. At the times when the deal was in full development, he was a Minister of Culture. Yes, this man is all-around..

Mr Voulgarakis is a misfortune. While Minister of Interior, the huge scandal of mobile phone interceptions broke out in 2007. Many high-level officials and even the Prime Minister, were tapped by an elaborate scam involving Vodafone and Ericsson Hellas. The tragedy escalated when a high-profile engineer of Vodafone, Costas Tsalikidis, commited "suicide" at the time interrogation was in progress. His family firmly and still insists it was a murder, but the case closed after a big fine on Vodafone Hellas.


At the time of the real estate scandal, Mr Voulgarakis was a Minister of Culture. His obscure role involves signing decisions of declaring land near Vistonida as non-archaeological sites. This allegedly made possible the exchange of this land with other state properties.

Now, Mr Voulgarakis has raised significant public discontent, after his tricks with offshore companies and Ltds, for tax evasion purposes, were revealed. He is now among the most wealthy Greek politicians(check out his watch in the photo), a state he reached only after he became one. Mr Voulgarakis was fairly insignificant as a professional and climbed up socially through his powerful connections and in-party activity. It is rumored that he will be soon removed from his government position.


Aikaterini Kelpeki

Mrs Kelpeki was the lawyer representing the Greek state in the disgraceful estate exchanges. On the other side of the deal, Mr Kelpekis, brother of Mrs Kelpeki, represented the Vatopedi monastery! Even more, Mr Kelpekis, father of this great family, is the lawyer of the Greek Orthodox Metropolis!!

In a recent unprecented attack to...everybody, Mr Kelpekis (the ..godfather), threatened that he will fight back any attempt to bring town Mr Voulgarakis. In his words : "Many, many others have strong relations with the Monastery of Vatopedi, but not Mr Voulgarakis. Stay away from him because I know too much!". Wow.

Kostas Karamanlis

What can we say...This man inherited a country at the age of 40. Being an insignificant member of the Parliament, from the day he was born, descending from the
powerful political family in Greece, he didn't have to prove anything to become a Prime Minister. During his years, the country has faced one disaster after another: economy decadence, unemployment, poverty, huge fires, political unstability, and many, many scandals.

Mr Karamanlis appears to have strong relationships with the Mount of Athos. He has visited the Vatopedi Monastery several times and has personal relationships with Efrem. In summer of 2006 he spent 2 nights there, during his visit to Athos, which by protocol is off-schedule.


Now Solve the Puzzle

I tried to give a complete picture of the huge scandal that is unfolding right now in Greece. Now it is the time for you to solve the puzzle! It is tough but I will give some hints:
  • Aggelos Basiakos was very close to the Mr Karamanlis, but he is now vanished from public affairs
  • Mr Roussopoulos is married to Mrs Zacharea
  • Mr Voulgarakis is married to Mrs Kelpeki
Surprised?? Welcome to Greece. Γεια σας!

More information: