Friday, 30 November 2012

Saturday, 17 November 2012

Web page speed check and optimisation

There are at least 3 places where one can check a web page speed, and obtain various recommendations regarding ways to improve page load time:

Google Page Speed Insights

YSlow and here the original yahoo site, with tips on site performance. Firefox addon is available too.

Webpagetest which offers the ability to select a different location for the test and different browsers.

These are certainly useful tools when it comes to web page loading times improvement and optimisation.

Update: Recently I found the site www.modern.ie which seems quite good for checking for valid pages against various browsers, OSes and devices. Not all the functionality is free, but seems reasonably priced for commercial web sites.

Friday, 7 September 2012

open source license types in simple English

I found 2 articles with simple english explanation of the license types:

part 1 http://www.zdnet.com/blog/burnette/howto-pick-an-open-source-license-part-1/130[^],
part 2 http://www.zdnet.com/blog/burnette/how-to-pick-an-open-source-license-part-2/131[^]

They are a bit old (since 2006) but these things don't change much over time. Just in case the original articles get lost, I am making a copy here, but for the interested reader, I suggest to read the originals cause they contain useful comments from other readers, and they are the intellectual property of the original author Ed Brunette:


Part 1:


Summary: If you write some code keep in mind that it's yours and you get to decide if, how, or under what circumstances, other people can use it. Let's say you've made the decision to release your code as "open source". What does that mean, what is an open source license, and how do you pick the right one? This question comes up all the time so I thought I'd write up a simple decision tree to try to explain the choices.

You've made the decision to release your code as "open source". Ok, what does that mean, what is an open source license, and how do you pick the right one? This question comes up all the time so I thought I'd write up a simple decision tree to try to explain the choices.Many people use GPL without realizing the implications or understanding the other options. This isn't legal advice, and I'm not a lawyer, and I'm probably over-simplifying some of the points, but I hope you find it helpful.
First of all, if you write some code, it's your code and you get to decide how other people can use it. Period. Nobody but you can say how your code can be used, either by putting restrictions on it or taking them off, without your permission. That's a very important point to keep in mind while reading this article.
The second point to keep in mind is that nobody but you can even use your code unless you explicitly give them permission. Another way of saying this is that all source code is closed and proprietary and off limits until you, the author, open it.
Note: The text of all the licenses mentioned here can be found at opensource.org.
Decision 1: Do you want to relinquish any control over how your code is used and distributed?
If yes, then don't copyright it, and don't license it. Put it in the public domain, and you're done. This is a good choice for examples, templates, and other illustrative code where the whole point is that you want everybody to feel free to use what you've written. [Alert readers pointed out that "public domain" is is not a good choice because in many jurisdictions you can't give up your copyright. Use a liberal license like MIT/BSD instead. -22jun/ebb]  Example: code listings in a book or article.

If no, then Copyright the code (paste copyright notices all over it) and continue with decision 2. 

Hint: Just to make sure your intent is clear, either put in explicit copyright notices, or put in explicit notices that the code is in the public domain. Copyright is how you retain control. Without a copyright, there is no control. [Technically the notices might not be necessary but they don't hurt and are still recommended. -22jun/ebb]
Decision 2: Do you want to allow people to use your code in non open-source programs?
If yes, then continue to decision 3.
If no, then release your code under the GPL, a restrictive "free (libre) software" license that actively promotes user choice at the expense of direct commercial interests. For the most part, GPL'd code can only be used with other GPL'd code, and in fact if you start using [and distributing -22jun/ebb] some GPL code in a program you wrote then you either have to release your program under GPL as well or quit using that code. This is why GPL is sometimes described as "viral". Examples: Emacs,  Linux kernel.
Hint: Don't take this choice unless you really mean it. Many people use GPL without realizing the implications or understanding the other options, and thus lock the code away from a whole segment of potential users, so please read the rest of the choices first.
Decision 3: If somebody uses your code in their program and sells their program for money, do you want some of that money?

If yes, then you have two choices. The first choice (3a) is not to release it as open source at all, i.e., use closed source and you're done. This would preclude anyone from using your code in free (no cost) packages. And it would only allow people to use your code in commercial programs if they came to your first and worked out a deal for a commercial license. Note that even if the source is "closed" you can give permission if you like for certain people to have access to the source and use it in limited ways. Example: Microsoft Windows, Sun Java (sort of).

The second choice (3b) is dual license. I'll talk about licenses more in a moment, but dual license just means you give permission for people to use your code under two or more licenses. You pick one license (probably GPL) for free (no cost) programs, and one for commercial ($$$) programs. This is a good choice if you're trying to make a living off licensing fees for the code itself. Examples: MySQL, JBoss, SleepyCat. Continue to decision 4.

If no, then give permission for others to use your code under one or more "commercial friendly" licenses. This is a good choice if you want your code to get into as many hands as possible and either you don't care about the money or you plan to make money in other ways, for example by selling your own programs that use the code or from consulting or support. Examples: Apache HTTPD, Eclipse, Firefox. Continue to decision 4.

Decision 4:  If somebody uses [and distributes -22jun/ebb] your code and improves it (fixes bugs or adds features) do you want to make them give you the improvements back so you can use them too?
If yes, then use a "reciprocal" license. Any modifications to your code need to be made available under the same licensing terms as your original code. This is useful if you're worried somebody will take your code and go off on their own private "fork". Examples: Eclipse (EPL), Solaris (CDDL), and Firefox (MPL). Done.
If no, then use a non-reciprocal license. Often times the people using your code will send back improvements anyway, especially if you have a history of frequent releases and they get tired of having to re-merge in their changes every time. This is the most wide open type of license so it will get you the most exposure and users, but it can also relegate the original writer(s) to the sidelines. Example: FreeBSD (BSD).  Done.

Part 2:

Public domain 
Description: This isn't really a license at all, but rather a renouncing of any rights you might have under copyright law. The idea is simple to understand but gets a little hairy legally. Some say it's not possible to renounce these rights, some say it depends on the country, some say that once renounced you can un-renounce them later, and some say it's perfectly fine.  After reading about it some more, my advice is to punt and and use a BSD/MIT license instead.
Code is protected by copyright? No
Code can be used in closed source projects? Yes
Program that uses (incorporates) the software can be sold commercially? Yes
Source to bug fixes and modifications must be released? No
Provides explicit patent license? No

BSD/MIT
Description: The BSD and MIT licenses are two of the oldest and most liberal licenses available. They basically put no restrictions on how the software can be used. These licenses are used by a wide variety of projects including FreeBSD.
Code is protected by copyright? Yes
Code can be used in closed source projects? Yes
Program that uses (incorporates) the software can be sold commercially? Yes
Source to bug fixes and modifications must be released? No
Provides explicit patent license? No

ASLv2 (Apache)
Description: The Apache license is only slightly more restrictive than the BSD/MIT licenses. The main thing it adds is some clauses about patent licensing and termination. You should carefully read all the patent clauses in the licenses that have them because they all have subtle differences. All the Apache.org projects use ASL but it's also in wide use outside Apache (for example Google uses it for GWT).
Code is protected by copyright? Yes
Code can be used in closed source projects? Yes
Program that uses (incorporates) the software can be sold commercially? Yes
Source to bug fixes and modifications must be released? No
Provides explicit patent license? Yes

GPL (v2)
Description: This is a very common license that allows people to freely use your software as long as they don't charge for it and use the same license for parts of the program that they wrote themselves. The copyright holder is not subject to these restrictions. Widely used, but largely misunderstood. The canonical examples are Linux and MySQL.
Code is protected by copyright? Yes
Code can be used in closed source projects? No* (except by copyright holder)
[*Note: If GPL code is only used in-house, then the answer is Yes. But if someone uses the GPL code in a derived work, and distributes the work, then the answer is No. I'm assuming distribution for this article. -22jun/ebb]
Program that uses (incorporates) the software can be sold commercially? No** (except by copyright holder)
[**Note: If you take "sold" to mean charge for distributing, charge for bundling and packaging, charge for reproducing, charge for support, and charge for indemnification, then the answer is Yes. This is the Linux distributor model. However if by "sold" you mean "paid a fee for a license to use" then the answer is No. Working at a commercial software developer that does charge such fees, the latter definition is most natural to me, so it's the meaning I'm using for this article. -22jun/ebb]
Source to bug fixes and modifications must be released? Yes [if distributed, see above]
Provides explicit patent license? No (but v3 is supposed to address this)

LGPL
Description: A derivative of GPL, LGPL includes an exception that is intended to allow code that is released under other licenses to co-exist with and call the LGPL code. However this exception is a bit fuzzy legally as it's currently written, so some businesses shun it. The author of the license encourages people not to use it. Personally I think LGPL is a much better choice than GPL for most software, but that a more modern license like EPL is often even better.
Code is protected by copyright? Yes
Code can be used in closed source projects? Yes (maybe)
Program that uses (incorporates) the software can be sold commercially? Yes (maybe)
Source to bug fixes and modifications must be released? Yes [if distributed; see notes under GPL]
Provides explicit patent license? No

MPL/CDDL
Description: MPL is used by Mozilla, Firefox, and many other projects. CDDL is based on MPL with a few minor tweaks to make it more applicable outside of Mozilla. CDDL is used by many Sun products such as Solaris. It's expected that Java will be open sourced either under the CDDL or (L)GPL. Note that the patent clauses are not palatable to some businesses, so you may want to consider EPL instead.
Code is protected by copyright? Yes
Code can be used in closed source projects? Yes
Program that uses (incorporates) the software can be sold commercially? Yes
Source to bug fixes and modifications must be released? Yes [if distributed]
Provides explicit patent license? Yes

CPL/EPL
Description: CPL was derived from the old IBM Public License and was also influenced by MPL. CPL was originally used by Eclipse, but that project switched to EPL. CPL is also used by some Microsoft open source projects on SourceForge. EPL is a newer version of CPL with some improvements in its patent language to make it more acceptable to businesses. For example if there's a patent dispute it will only affect the part of the software covered by the patent and not the whole thing.
Code is protected by copyright? Yes
Code can be used in closed source projects? Yes
Program that uses (incorporates) the software can be sold commercially? Yes
Source to bug fixes and modifications must be released? Yes [if distributed]
Provides explicit patent license? Yes
Dual license
Description: This isn't really a license, it just means making your software available under two or more different licenses. This is useful in two circumstances:
  1. The license you originally picked isn't compatible with the license somebody else uses and they want to use your code (or vice-versa). This is how you get things like "GPL/LGPL/MPL/EPL" licenses (a quad-license). Then there's no question that your code can be used in programs that use any of the licenses you mention.
  2. You want to make your software available without charge in other free programs, but if somebody is going to make money off of it then you want a share. The typical example is MySQL. It's licensed under GPL, but if a different company wants to embed it in their commercial program then they have to get a different, commercial license. The copyright holder, of course, can use their own software however they like. It's this situation that earned GPL the nickname of "The Greedy Programmer's License". See also this slashdot thread. Of course, one could argue other licenses like BSD, MIT, and Apache, are "greedy vendors' licenses". That's one reason I like the pragmatic, middle-of-the-road licenses like EPL.
Note: Normally, only the copyright holder can re-license the software (for example to issue commercial licenses). So if multiple people contribute to your project, you may need to get them to sign some kind of contributor's agreement that spells out who owns the copyright and what kinds of activities are allowed. For this you definitely need a lawyer.
Final notes
Several people noted the "anti-GPL slant" of the previous article. I admit I'm not too fond of the GPL. If people pick GPL on purpose, with full knowledge of its restrictions and philosophy, that's fine. I just see too many people pick it when they don't really need to. As one responder to my original article wrote:
If you think using GPL'ed software in commercial software is "smooth sailing" you don't understand the license. There are safe situations, but in everything except the very straightforward cases, you have to understand more about contract and copyright law that most developers do to know what is safe and what isn't.
Pick what you want, but pick it for the right reasons. And consult a lawyer if you need to cover your assets.


Sunday, 26 August 2012

Why Windows 8 won't be a success...

I wanted to post about this for a few days now, but never found the time.

All the hype these days is about the Windows 8 release... lots of lengthy posts all over the internet, and endless debates. My simple and humble opinion is that this new OS by Microsoft will not be well received, for the following reasons:

1. It tries to cater for the needs of the desktop and the tablet users at the same time. This is not possible with a single user interface, simply because the dimensions of the screen are different, so the use patterns are different. This is the single one and main reason why not only Microsoft, but anyone cannot design one single OS that will be efficient both for tablets and PCs.

2. The tiled interface is not very efficient for office use, has too high learning curve, so businesses won't be adopters, there goes a huge part of the revenues.

3. The power users won't be thrilled as a lot of screen space is wasted, so that's another part of the market that won't buy.

4. Finger interface makes no sense in managing a server remotely.

5. The screen will get very dirty if you try using it with fingers... I know this reason sounds silly, but doesn't help.

Under different circumstances, I would say the new OS will be a flop, but given the mighty Microsoft advertising machine which is already at work, I will say that they will manage to convince a few people to buy, and it won't be a total disaster. It might make a few sales in the tablet market, which is clearly its target market, although even there, it has a hurdle to overcome: it is not free (compare this to Android). In any case, I think Windows 8 will go down worse that Vista did.

On a relevant and a bit more philosophical note, I dare say that the only reason Microsoft is creating this OS is  to compete in the tablets market, I mean it is obvious by the UI design that this OS will offer better usability to the tablet users. And at the same time, they try to have the benefit of having to maintain one OS only, for both desktop and tablet users, and the need for applications to be developed for one OS only, this is why they are selling the same OS to desktop/laptop users.

I believe it would have been better if they made 2 partially different OSes for these 2 different markets, perhaps with the same underlying (i.e. non UI part) core, and then offer 2 different SDKs or UI platforms or whatever, for developing the UI parts of the applications. I think they will realise this and Windows 9 will be based on this model, and it won't be long before it arrives. They just need to see the low sales numbers to be convinced, just as it happened with Vista.

Personally, I'll skip Windows 8, just as I did with Vista, and I never regretted it. However, everybody has a different taste and I am sure some people will like the new OS, which is perfectly fine. Diversity is always good!

Friday, 24 August 2012

Cassini ultidev web server SLL failed to register website1 because System.ComponentModel.Win32Exception the operation completed successfully

So today I was setting up the latest Cassini UltiDev web server, version 4.65.0.0. The guys did a good job, the server is easy to use and functional. I used the default website of Microsoft WebMatrix and seemed fine. However, I run into a weird exception, the moment I tried to add an SSL certificate:

Failed to register Website1 because  System.ComponentModel.Win32Exception the operation completed successfully

Well, this doesn't make much sense... how can it fail and succeed at the same time? In any case, the https part of the site was not working. After a bit of digging around, I discovered that it was not registering the certificate with the port. The work around (windows server 2003) was to register this manually, with the command:

httpcfg set ssl -i 0.0.0.0:443 -h CERTHASHWITHOUTSPACESHERE

After that everything was fine. I hope this saves someone some time...

Saturday, 18 August 2012

A very well written summary on Scrum


This is a very clear overview on scrum, by a very knowledgeable author.

I must note that the book he recommends is a bit old, there are newer ones in the marketplace which could offer more up to date information. I very much like Pro Agile .NET Development with SCRUM (also amazon link) because it offers recent (2011) and a hands on real life scenario to the methodology of scrum, TDD, BDD, with the tools developers use in every day work (it is geared towards ASP.NET though, if you use another environment you might not like this part...).

how to repair a corrupted .net framework 1.1 installation on a microsoft windows server 2003

OK so recently a friend of mine administering a windows server 2003 managed to corrupt his .NET framework installation. I decided to lend him a hand, and after a lot of searching this is what I found out:

The situation:

He tried to remove all .NET framework versions in order to install version 4.0. As it turns out, version 1.1 is part of the actual OS, and when he removed it, he didn't remove it completely, some registry key remained there, and the OS was thinking it had a fully working 1.1 version installed. As a result, when trying to reinstall the version 1.1 he was getting a message like "the product you are trying to install has already been installed as part of the OS" or something similar, because windows thought the framework is already installed. Also, any attempt to install any of the later versions of .NET framework were failing, the same when trying windows updates.

The solution:

It is outlined very clearly in this microsoft support page, and it did work. Took me some time to find it, hopefully this post will help someone else find it faster.

And because microsoft links have a tendency to disappear from time to time, here is the process in summary:

1. Delete netfx found in the registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\OC Manager\Subcomponents

2. in C:\Windows\inf make a file, call it sysnew.inf, with contents:


[Version]
Signature = "$Windows NT$"
DriverVer=10/01/2002,5.2.3790.0

[Components]
netfx=netfxocm.dll,UrtOcmProc,netfxocm.inf,,7


3. run this command:

sysocmgr /i:C:\windows\inf\sysnew.inf

4. Click next, if it asks for the files, download the SP2 for windows server 2003 (about 380 MB), extract it with 7zip and click browse to the folder i386 you just extracted.

5. Install assemblies in the global assembly cache (replace xxxx with correct version, in our case was 4322):

"C:\windows\Microsoft.NET\Framework\v1.1.xxxx\gacutil.exe" /f /il C:\windows\Microsoft.NET\Framework\v1.1.xxxx\assemblylist.txt

6. Run windows update to get any patches you need, and you should be all set.

I hope this post saves someone some time...

Tuesday, 7 August 2012

Firefox Memory Manager

OK, for a long time I was not happy with the huge amount of memory used by Firefox. Recently I came across a nice little application, firemin, that can be found here: http://www.datum-forensics.com/2012/05/firemin/

It is quite nice, I tried it for a couple of days. However, I was quite surprised by the huge amount of memory reduction (down to about 1 MB from 300-400 MB or more), and I thought that this does not seem normal, something else must be sacrificed. The point is, the more we reduce the memory used by firefox, the more page faults we will have.

So I wrote a small C# application to verify this and to check how many page faults I have and how much memory is used by firefox. Then I added a little bit of code to perform a "memory collection" using the EmptyWorkingSet unmanaged function (same as firemin uses), whenever the memory used by firefox reaches a certain limit which we can set. This way we can set the limit to as high as we like (for example 200 MB), depending on the available physical memory in our computer, and avoid the huge amount of page faults we get when firefox memory drops to something like 1 MB... In fact, we could just as easily let the OS handle the whole thing...

The application works on my system (windows 7) without problems (requires .NET 4.0 client profile). It is nothing extraordinary, and there are tons of things that could be improved on it, from a coding point of view. It is rather a quick hack and a proof of concept than a proper application.

Still I decided to share it here, so perhaps other people will find it useful, or decide to take the code and improve on it. One thing I was going to add if I had more time would be some real time zedgraph plot of the memory and page faults, I think that would be cool. Currently, the results can be visualised if logging is enabled and then copy/paste the resuts in excel and plot as a 2D graph. Takes a few seconds to do, and looks like this:



Please note, I have not tested it extensively and I cannot be responsible for anything that might go wrong, however, I doubt anything will, in the worst case it will probably just crash itself, as it doesn't try to do anything else other than release the memory... now if you start doing funny things like setting negative memory target and so on... you are on your own :)

In the application I used coding ideas regarding retrieving process information from a site that I can't remember now (sorry), about EmptyWorkingSet from http://forums.codeguru.com/printthread.php?t=368990

and about a task running in the tray from http://www.codeproject.com/Articles/18683/Creating-a-Tasktray-Application

(there is a more advanced tutorial on tray applications here http://www.simple-talk.com/dotnet/.net-framework/creating-tray-applications-in-.net-a-practical-guide/ but for the purposes of this application the first article on codeproject is just fine)

The application runs by default in the system tray, so you won't see anything the first time you run it. By default, it will monitor memory usage once per second. The default setting is 200 MB to perform a memory collection, and I found that it gets hit quite often with around 20 tabs open... you might want to play around. If you open the application window, you will see something like this:











The left side contains the process name (firefox.exe), process ID, number of page faults (total), working set size in bytes, average page faults in 1 sec interval over the last 60 seconds, and number of page faults in the last 1 second.

In the middle we see a log (1 line per second) of the working set size in bytes, the page faults for each second interval and the total process page faults.

On the right we see one line each time a memory collection occurs, and what was the working set size the moment the collection was triggered.

At the top right we can set the desired limit (in Mega Bytes), at the bottom left we can stop the process monitoring, and finally the Hide Window button will send the application to the tray. If you want to exit the application completely, you need to right click at the system tray icon and select "Exit".

I hope this covers the basics....

There is no license for the application, you can take it and use it for free in any way you like. If you create
some improved version, I would appreciate a post here, so that people can then know where it came from and where to get the improved version.

Here is the link to the application http://www.mediafire.com/download.php?6pafyd4d257pojy

and here is the link to the source code http://www.mediafire.com/download.php?akzcto8g3v5m5y6

Any comments are welcome, I hope this post helps someone in any way.