Thursday, January 22, 2009

EU charges Microsoft with antitrust again

I was really pissed off when I read about the new antitrust charges Microsoft is facing from the EU. It was mentioned in the news article published under "EU: Microsoft 'shields' IE from competition" how EU looks at the case:

The evidence gathered during the investigation leads the commission to believe that the tying of Internet Explorer with Windows, which makes Internet Explorer available on 90% of the world's PCs, distorts competition on the merits between competing Web browsers insofar as it provides Internet Explorer with an artificial distribution advantage which other Web browsers are unable to match.
So, if they think that IE is available on 90% of the world's PCs, why didn't they consider FireFox, Opera, Safari or Chrome to be available on 100% of the world's PCs that has internet access? Any of these browsers can be downloaded and installed in about 10 minutes. If IE wasn't bundled with Windows, it would've been really difficult to use the PC whatsoever. A web browser is an essential part of any usable OS. Actually, IE provides instant web access to Windows user so they can do whatever they like, including navigating to/searching for competing browsers to download and install. Microsoft didn't prevent Windows users to do what they want with the software on their machines.

Microsoft should make a secure and standards-compliant browser, but separating IE from windows is another thing. We all know how bad IE can be, for instance, it used to crash anytime I closed a tab loaded with Facebook. Also, as a web developer, I can tell you that IE is not fun to work with as it doesn't follow the standards, which makes it harder to produce something that can be viewed by any user given that most users indeed use IE.

Opera claimed back in December that Microsoft abuses its dominant position on the desktop by tying IE browser to Windows and asked the EU's Competition Commission to force Microsoft into separating IE from Windows. Why don't we hear similar claims for Safari that is bundled with OSX or FireFox that comes with almost all open source OS distributions like Ubuntu, OpenSUSE and Fedora?

Maybe PC users are not interested enough to change IE, or maybe IE is good enough for their common needs. However, this is the current state of the browser market. It doesn't only happen in the software world, the first move guarantees an advantage in any market as well as in chess. In addition, untying IE from Windows is not going to change this any soon. Windows is already sold and used on so many machines worldwide.

I think competing browsers should focus on the quality of their products instead of blaming Microsoft for their first-hand advantage, after Browser War I. They should also think of innovative ways to advertise their products and expand their user base. Each product has its pros and cons, say, IE comes with Windows and Safari with OSX, FireFox has lots of add-ons and comes with Ubuntu and finally, Chrome is made by Google. Opera should work on marketing and add more features instead of just being jealous of IE, because the new Google browser is already doing better in terms of market share according to the W3C browser statistics. On the other hand, IE should follow the standards and work on its security and stability issues.

Wednesday, January 14, 2009

Indoor RF Propagation Simulation Software

I was looking for a free program to help me simulate Wi-Fi signal propagation for indoor environments. I wanted a program that could take a floor map and do some ray tracing or apply some known propagation model. I was disappointed when I couldn't find any open source software in that area. All the free programs I found were very naive and targeted radio hobbyists. On the other hand, I found a number of high quality commercial programs, fortunately, one of which had a free student edition. I compiled this list with the information I got:

1) RF-vu from iBwave with the RF-Propagation add-on.
2) PropMan from AWE Communications.
3) InterpretAir from Fluke Networks.
4) SignalPro from EDX with the Microcell/Indoor add-on (free evaluation version)
5) Radioplan from Actix. (student edition free to download)

I'd also like to mention these free tools, none of them support indoor propagation and I didn't try them myself, anyway they seemed good to me so I decided to include them here for completion.

1) Radio Mobile: the screen shots available at the website are interesting and it seems to have an active user base. They've created a Yahoo Group that currently has 5382 members. The group description points to that tutorial that looked good too.

2) SPLAT!: an open source RF Signal Propagation, Loss, And Terrain analysis tool for the spectrum between 20 MHz and 20 GHz. It may be redistributed and/or modified under the terms of GPLv2. It looks well made and documented. The website mentions interesting projects that used this tool.

Wednesday, January 7, 2009

Netbeans modified web.xml when it shouldn't

A couple of days ago, I was working on a J2EE project using EJB 3.0 and plain JSP/Servlets. I used Netbeans 6.0.1 with GlassFish 9.1 on my XP Professional PC. For some reason, the project build kept on failing, without any changes in the configuration files which I barely touched. After digging through the stack traces and log files I got, I found this message "The ResourceConfig instance does not contain any root resource classes". I googled for that and found that others got the same problem. I followed this thread on java.net forums, and was really angry to find that Netbeans added stuff to my web.xml, which of course couldn't be resolved by the deployment script. This is the extra parts the guys mentioned on the forum and I found in my web.xml:

<servlet>
<servlet-name>ServletAdaptor</servlet-name>
<servlet-class>com.sun.ws.rest.impl.container.servlet.ServletAdaptor</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
and:
<servlet-mapping>
<servlet-name>ServletAdaptor</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>

It seemed like it had to do with the RESTful webservices plug-ins which I didn't even reference in that project. I removed the extra parts from my web.xml and also removed the RESTful plug-ins to make sure it doesn't happen again and everything went fine.

Friday, October 31, 2008

C/C++ __gnu_cxx hash_set

In this post, we go about __gnu_cxx::hash_set. As we saw before, we need to define our own HashFcn. We'll also need to define EqualKey if we're using custom data types. Another workaround is to overload the == operator inside the std namespace, then you don't have to provide your own EqualKey. It should look like:

namespace std {
bool operator==(const dnsRecord& rec1, const dnsRecord& rec2) {
return rec1.ip == rec2.ip;
}
}
However, I prefer the first solution, and we'll use it in the code below. We also define our own hasher and pass it to the hash_set declaration instead of specializing the hash template inside the __gnu_cxx namespace as we did in the previous post.
#include <iostream>
#include <ext/hash_set>

using namespace std;
using namespace __gnu_cxx;

class dnsRecord {
public:
unsigned long ip;
string domainName;
};

class MyHasher {
public:
size_t operator()(const dnsRecord &r) const
{
return h(r.domainName.c_str());
};

private:
__gnu_cxx::hash<char*> h;
};

class MyComparator
{
public:
bool operator()(const dnsRecord& rec1, const dnsRecord& rec2) const {
return rec1.ip == rec2.ip;
}
};

int main(int argc, char *argv[])
{
hash_set<dnsRecord, MyHasher, MyComparator> hset;
dnsRecord rec1;
dnsRecord rec2;
dnsRecord rec3;
rec1.ip = 989798l; rec1.domainName = "dname1";
rec2.ip = 112334l; rec2.domainName = "dname2";
rec2.ip = 808323l; rec3.domainName = "dname3";
hset.insert(rec1);
hset.insert(rec2);
hset.insert(rec3);

dnsRecord rec4;
rec4.ip = 0;
rec4.domainName = "dname1";

hash_set<dnsRecord, MyHasher, MyComparator>::iterator it;
for(it = hset.begin(); it != hset.end(); it++)
cout << (*it).ip << ", " << (*it).domainName << endl;

rec4.domainName = "dname3";
hset.erase(rec4);

rec4.domainName = "dname3";
if(hset.find(rec4) == hset.end())
cout << "Successfully removed dname3" << endl;
else
cout << "Error!" << endl;

return EXIT_SUCCESS;
}

Tuesday, October 28, 2008

C/C++ __gnu_cxx hash_map

I had some trouble getting this to work, so I decided to post a quick tutorial...

We start with a simple hash_map with int keys and string values:

#include <iostream>
#include <ext/hash_map>

using namespace std;
using namespace __gnu_cxx;

int main(int argc, char *argv[])
{
//declaration
hash_map<int, string> hmap;

//insertion
int ints[] = {213, 432, 45, 10};
string strings[] = {"s1", "s2", "s3", "s4"};

for(int i = 0; i < 4; i ++)
hmap[ints[i]] = strings[i];

//iteration
for(hash_map<int, string>::iterator it = hmap.begin(); it != hmap.end(); it ++)
cout << (*it).first << " => " << (*it).second << endl;

//deletion
hmap.erase(ints[0]);
cout << "Removed: " << ints[0] << endl;

//search
if(hmap.find(ints[0]) == hmap.end())
cout << "Couldn't find: " << ints[0] << endl;

if(hmap.find(ints[1]) != hmap.end())
cout << "Found: " << ints[1] << ": " << hmap[ints[1]] << endl;

return EXIT_SUCCESS;
}
It gets a little bit messy when using string keys. Since hash_map is not part of the standard STL, there're some issues you need to worry about. In our case, there's no implementation provided for hash, or in other words, the hash_map can't hash strings by default. Strangely though, hash is defined for char*, and we'll make use of that fact.

You can either specialize the hash template for std::string inside the __gnu_cxx namespace or define your own hash functor and use it in your hash_map declaration. Remember that hash_map is declared as hash_map<Key, Type, HashFcn, EqualKey, Alloc>. I prefer the second solution, you can check it out here. For now, we'll go on with the first one.
#include <iostream>
#include <ext/hash_map>

using namespace std;
using namespace __gnu_cxx;

namespace __gnu_cxx {
template<>
struct hash<std::string>
{
hash<char*> h;
size_t operator()(const std::string &s) const
{
return h(s.c_str());
};
};
}

typedef struct {
int x;
int y;
} point;

int main(int argc, char *argv[])
{
//declaration
hash_map<string, point> hmap;

//insertion
string strings[] = {"p1", "p2", "p3", "p4"};

point a, b, c, d;
a.x = a.y = 0;
b.x = b.y = 1;
c.x = c.y = 2;
d.x = d.y = 3;

hmap[strings[0]] = a;
hmap[strings[1]] = b;
hmap[strings[2]] = c;
hmap[strings[3]] = d;

//iteration
for(hash_map<string, point>::iterator it = hmap.begin(); it != hmap.end(); it ++)
cout << (*it).first << " => (" << (*it).second.x << ", " << (*it).second.y << ")" << endl;

//deletion
hmap.erase(strings[1]);
cout << "Removed: " << strings[1] << endl;

//search
if(hmap.find(strings[1]) == hmap.end())
cout << "Couldn't find: " << strings[1] << endl;

if(hmap.find(strings[0]) != hmap.end())
cout << "Found: " << strings[0] << ": (" << hmap[strings[0]].x << ", " << hmap[strings[0]].y << ")" << endl;

return EXIT_SUCCESS;
}

Repair Network Connection in Ubuntu

I'm running Ubuntu 8.04 under VirtualBox on Vista. I've created a virtual network interface for the vm and bridged my network connections. The network connection was down for a while, so when I started vm there was no connection. After a while however, the connection was restored and I was able to use it on Vista. The problem is, the vm didn't feel that the connection was restored. I googled for that and got a useful thread on ubuntuforums. I applied the solution I found there and added a launcher to my panel.

Right-click the panel -> "Add to Panel..." -> "Custom Application Launcher" then enter:

Type: Application
Name: NetRepair
Command: gksudo /etc/init.d/networking restart
Comment: Repair Network Connection
Click OK.

The launcher should appear on your panel. When you click the icon, it'll run the command you entered and will ask for your password. Hopefully, this should 'repair' your network connection.

btw, this is my first post from ubuntu!

Friday, August 29, 2008

Escapement mechanisms in mechanical clocks

I was fascinated by the simplicity and elegance of these mechanisms, yet it's not comprehensible at the first glance which adds to its charm. Illustrated above is the grasshopper escapement which was invented by British clockmaker John Harrison around 1722. Read more about that here.