My Weird Nook

Thursday, December 6, 2007

What annoys me about Web 2.0?

You don't need to be a technology expert to notice that the web has swiftly changed over the last 2-3 years. The changes are both technological and "social".

As for the technological aspect, I am really praised. For more than a decade we were struggling to overcome the numerous limitations imposed by misdesigned standards like HTML and HTTP. Now we have standard, widely-adopted tools to create stateful, desktop-like web applications. Flex and Silverlight are here to remind us that the traditional approach to web applications we were using until now was wrong from its roots. These changes impact the backend, too. We are finally moving towards a Service Oriented Architecture - the idea to have autonomous and independent building blocks forming the business logic of the application. All that opens a door to great possibilities. In a few years there will be no clear distinction between desktop and web applications.

Here comes my discontent. It is about the influence of this Web 2.0 "social idea" over the people. Don't you feel that we are entering a new age where Sergey Brin and Larry Page rule the web much like Lenin and Stalin ruled their country, and Mark Zuckerberg defines the social ideology of the web much like Karl Marx? All these Google services that are popping out every day do nothing but concentrate the web in the hands of a single company. Much like communism killed enterpreneurship Google is now buying out every successful online company thus stealing every promising idea. Mark Zuckerberg defines our social values and the ways we should communicate. For the sake of their bank accounts, these think-tanks come up with absurd slogans like "creating communities", "share content", "humans are social creatures", "give the media back in people's hands", the list goes on and on. Can you guess what is the consequence of this global web communism?

Cultural flattening. In an environment where everyone is an author, audience disappears, culture and arts become flat. Everyone can write, everyone can upload his videos on YouTube. It is getting harder and harder for gifted artists to be spotted among this mediocre mass. We are going to watch stupid home-made videos rather than great movies made by passionate producers. We will be "cool" persons if we visit social bookmarking sites rather than trying to create something. You will be as worthy as your friends' list is long on MySpace or Facebook, rather than keeping real life relationships.

Absolute power of a chosen few. If tomorrow Google decides to change their ranking algorithm, the whole world will have to follow their new dogmas. If Facebook introduces a new stupid API the whole world will begin to develop stupid applications based on it.

Overall recession. The bright future of the web seems at question.

Tuesday, September 25, 2007

Apostol Apostolov (Apostol Apostoloff, Апостол Апостолов, mamboto) - The Bulgarian King of SCAM & SPAM

If I say that I certainly dislike this unpleasant man I won't be straight with you. In fact he gives me something - he raises my mood by making me laugh everytime I read his "precious thoughts" posted on a loosely moderated Bulgarian forum. Or even more, I fall from my chair going right under my desk laughing like a drunken bastard after a short glance at what he pridefully calls "my four commercial sites" - ludipari[dot]com, superastro[dot]net, otslabni[dot]net and pisaneto[dot]com. Only having a first look at these ridiculous single-paged sites is enough for a normal person to conclude that in the year 2007 this badly aged "guru of eCommerce" is vehemently applying best practices for a well-known kind of scam that was trendy ten years ago.

In his site superastro[dot]net he presents himself as the greatest Bulgarian astrologer! He is under your command to produce your personal horoscope! This will be a gift for a lifetime and it will make you richer! But of course you have to pay for that, otherwise you will remain being the most miserable person and you will never get rich without his horoscope. So, the ultimate guru of astrology is already here for us to produce our horoscopes and take us away from misery!

Let's go into otslabni[dot]net :-) Wow! What a coincidence! The guru of astrology is here to give us the ultimate weight-losing recipes! You wanna look well? You wanna drop 30 kilos? Don't hesitate to order his recipes.

Without seeing the next two sites you may think that this aged bastard is just trying to fool silly people and make some money. But after you see ludipari[dot]com and pisaneto[dot]com, you will be literally smashed. On top of all, he proclaims himself as the greatest guru of eCommerce and persuasive text writing! Just because he is the most successful online businessman he is attempting to enlighten people on how to make money from the Internet! He reveals the magic of his business! If you don't order his book with tips on eCommerce, you will never start a successful online business and you will die in misery! You can only trust his experience as an online businessman - resembling him you have to let your customers pay you through regular mail or a bank account transfer. Pretty strange for an online business in 2007, huh? No, that is what the guru says, you have to listen.

For Apostol - you are now being officially proclaimed as his majesty the "Bulgarian King Of Scam And Spam"! We really respect you Apostol! You are the father of astrology, weight-losing and eCommerce!

Being serious, I would say that this man shall be overlooked with absolute disrespect. Not only because he personally insults people when replying in forums, but just because such a kind of openness in demonstrating abuse is disruptive for the society.

Tuesday, August 28, 2007

Asido vs. Sorcerer

What a coincidence! More than a year has passed since I stopped working on my image processing component PHP Image Sorcerer, and I found out randomly browsing the web that a guy from the same city where I live has recently started a similar project - Asido! Let the battle begin :-)

Basically Sorcerer can do most of the things Asido can, but the architecture of the latter is quite different. While Sorcerer tends to be more lightweight and performance-biased, Asido offers full-blown modularity by enabling the programmer to choose from various image processing drivers controllable from a unified interface. Providing a level of abstraction between the interface and the image processing implementation, Asido currently supports both GD2 and ImageMagick (the shell tools as well as the library) seamlessly.

However, the intelligent caching mechanism of Sorcerer is still unbeaten :-)

After all I am very happy to see a project like Asido growing. Not to mention my initial fascination that the guy behind it is my fellow-citizen. Most of all I value its modular architecture. The idea to plug-and-play different image processing drivers through a unified interface will probably keep it going for long and promises a very extensible system.

Long live Asido!

Splitting memory into bytes and bytes into bits...

It's time for a new fresh & tricky snippet on my blog to keep you tuned :-)

This simple function takes a generic void pointer to iterate over each individual byte in a memory block till a given length. Then it tests each byte's bits consequently against a shifting bitmask.
#include <stdio.h>
#include <sys/types.h>

typedef unsigned char ubyte;

void printbin (void *buf, size_t len)
{
ubyte *p = buf;
size_t i = 0;
ubyte mask;

while (i++ < len) {
for (mask = 1 << 7; mask; mask >>= 1) {
printf(*p & mask ? "1" : "0");
}

p++;
printf(" ");
}
}
The outcome is that you see the memory dumped as octets of 1's and 0's. Cool, huh?

No more socket trouble in PHP!

Having tried to reliably transfer large amounts of binary data over a latent network, I found out that fread()/fwrite() should never be trusted to read/write the whole block with the exact length specified, even in blocking mode, even for small block lengths.

I came up with these two functions, fully-replaceable and reliable alternatives of fread()/fwrite() in a socket context:
function fullread ($sd, $len) {
$ret = '';
$read = 0;

while ($read < $len && ($buf = fread($sd, $len - $read))) {
$read += strlen($buf);
$ret .= $buf;
}

return $ret;
}


function fullwrite ($sd, $buf) {
$total = 0;
$len = strlen($buf);

while ($total < $len && ($written = fwrite($sd, $buf))) {
$total += $written;
$buf = substr($buf, $written);
}

return $total;
}
The functions are "greedy", i.e. trying to read/write as much data as possible at once. If the inside call to fread()/fwrite() reads/writes less than expected, then the next iteration eats up the remainder. Very smart as only the largest possible chunks are read/written.

Only in case of a broken pipe (dropped connection during execution) the functions return less than the specified length. Otherwise it is guaranteed that upon termination
strlen(fullread($sd, $len)) == $len
and
fullwrite($sd, $buf) == strlen($buf)
Works perfectly with a socket descriptor returned from stream_socket_client(), and I hope it will do so with fsockopen() as well.

Yay! Caused me two weeks of fuss how unreliable are fread()/fwrite() to suddenly come up with this simple, smart and elegant solution.

Thursday, August 23, 2007

"Human Knowledge Belongs To The World!"

In order to fulfil my belief in the phrase "Human Knowledge Belongs To The World!", I wrote a tutorial about bitwise manipulations in C. You'll see what I'm talking about when you read the whole article here :-) Sorry again for non-Bulgarian readers. It covers essential topics about the use of bitmasks and gives a lot of illustrative examples. However, it requires some basic knowledge of bitwise operators and bitwise operations fundamentals.

Society and cops in Bulgaria...

I am very annoyed of what happened to me today. I was just crossing a street in the centre of the city where I live (Rousse) and a cop car was about to hit me! It had no intention to decrease its speed no matter that it was approaching the crossing area and I as a pedestrian was there. Only 20-30 centimetres helped me so that the car didn't hit me and I'm not in hospital now. Moreover, the car didn't have its light signals on, and most probably the cops were just demonstrating how negligible are citizens to them. Idiots. Just to expose them in public and to emphasize that it's a real story, the license plate of the car was "P 0003 PA".

In fact most of the cops in Bulgaria are foolish bastards. Yes, I said it right, with no exaggeration. They are the ones that encourage corruption and bad citizen habits. How is a citizen supposed to behave in a country where cops don't admit rules and feel godlike? Everyday I watch TV and see TV hosts urging people to drive consciously, and what happens when I go out? I see the cops f***ing up the rules. Somebody has to enlighten them that innocent citizens should not be the target of their ego and their authority should not be the reason to show off their power here and there.

And now let's see how the cops treat you if you own a Lamborghini Murcielago. This little movie shows how a Lamborghini is being parked provocatively by its owner right on the crossing area of a big street. People have to go round the shiny car in order to cross the street! A citizen is shocked by this act of arrogant impudence and calls the cop in the vicinity. The cop replies "I can't do anything about it". Yes, in such cases cops behave like scared schoolgirls because they feel themselves inferior to a guy driving a car that costs half a million. And the ridiculous end of this story is that the police couldn't find the law breaker to punish him. Even after the story has become public. Even that not every second car in Sofia is an orange Murcielago. Even that the license plate is clearly visible from the picture. Forced by his internal sense for justice, the guy with the Lambo decided to surrender because the police is so "polite" that it doesn't mess in such people's life. A truly disgusting story.

If I was the minister of interior affairs I would immediately fire these bastards, but in fact it turns out that the minister should be fired when such things happen everyday. Apparently things are complicated. Corruption is spread on all levels.

It all makes me think that one day I will play the cop when I buy such a car. My bravest dream will be to own a Lamborghini and see how a cop doesn't decrease his speed at the crossing area where pedestrians walk. Then I get into the Lambo, turn on the lights, chase the cop car, stop it, and then see the cops getting out scared like schoolgirls. Such a pity that we have this kind of society.

Saturday, August 18, 2007

New article on void pointers

Having nothing to do these days, I decided to write an article about void pointers in C. It's already online here, and is worth reading if you know Bulgarian :-) The first part covers the very important concepts of pointers as a whole, the second part explains what is a void pointer and the third part gives some practical examples on the matter.

My sister's wedding

Finally, after living together for 3 years, my sister and her chosen man decided to marry each other. The wedding ceremony went quite well and every detail was marvellous. I was amazed to see her in a wedding dress.

First they said "Yes" to each other in a special hall intended for weddings. Next we went to the church and the priest blessed them. About 100 relatives from all over the country attended the event.

The most funny part (at least for me) was in the restaurant where I wasn't aware that the rakia they serve will be 60% alcohol :-) That's why I don't remember the whole part :-)

I'm an extremely bad dancer of horo (a national dance in Bulgaria) and I can't imagine how people were looking at me when I was doing that after some 0.4 litres of rakia :-) Two days had to pass before I got completely sober after that.

My godfather was the centre of attention smoking havana cigars all the time. He was the man to encourage me to drink so much!

It was actually the first time for me to attend a wedding. The whole thing was a great fun and all I can wish my sister and her husband is to have a happy living together for long.

Yay! My new "Cirrus Image Mirroring Server" is born!

Finally, I am so contented to see my new project up and running! After two months of hard work on what I called "Cirrus Image Mirroring Server", I carried out the final tests and remained so satisfied because it just WORKS!

What this server application basically does is accept JPEG, GIF or PNG images through a custom TCP based protocol called CRCP (CiRrus Communication Protocol). Along with the image being transfered through CRCP, it accepts image instructions as well. The server then applies these instructions over the image (resizing, cropping, watermarks, etc.), and spits out the resulting image. The reason why I named it a "mirroring server" is because the resulting image is being cached, and in case requested for a second time, the server reads it from the cache, rather than applying the same manipulations over the same input image.

Entirely written in C, it operates freakingly fast. It uses the GD library to apply the image manipulations. Currently I am on the way of writing a PHP class that implements the CRCP protocol through a standard socket interface. That will allow for the server being reachable via PHP.

During development I was performing intermediate tests entirely in Cygwin under Windows XP, but I am quite happy to see that it behaves in exactly the same way under my Slackware box. And one thing is for sure - C will remain being my favourite language. I am astonished of the power that such a simple language can deliver. But coding discipline is very important if you want to unleash it.