Main
Latest
- South African Embassy
- Green Card Lottery 2008
- Zend Framework Google Login Example
- Custom Muti Widgets
- Google Social Graph API and PHP 5.2
- Google AJAX Feed API Muti Example
- Gnip API Changes
- Google Maps and Geolocation
- oEmbed, flickr and starstar
- Petition Against Public Holidays
Archives
- June 2004
- July 2004
- August 2004
- September 2004
- October 2004
- November 2004
- December 2004
- January 2005
- February 2005
- March 2005
- April 2005
- May 2005
- June 2005
- July 2005
- August 2005
- September 2005
- October 2005
- November 2005
- December 2005
- January 2006
- February 2006
- March 2006
- April 2006
- May 2006
- June 2006
- July 2006
- August 2006
- September 2006
- November 2006
- December 2006
- January 2007
- February 2007
- March 2007
- April 2007
- May 2007
- June 2007
- July 2007
- August 2007
- September 2007
- October 2007
- November 2007
- December 2007
- January 2008
- February 2008
- March 2008
- April 2008
- May 2008
- June 2008
- July 2008
- August 2008
- September 2008
- October 2008
George Burning Up & Blowing Away
We have been hit with absolutely terrible weather the last couple of days. First the got a pretty bad blazingly hot bergwind (which was more-or-less gale-force in my opinion) that fueled a few terrible forest fires. There were so many I lost count. Very close to my home, there was also a few bad ones going on. Luckily, it missed my house, but we got all the important papers and money and stuff together and were ready to evacuate.
Anyway, there are a few reports about this on the net if you could care to read more:
Firefox Rap Song
For those that missed this over at SFX, I'm very glad to see that I'm not the only one that likes open source gangsterism:
Hit it.
Dun, dun dun dun dundun
Dun, dun dun dun dundun
Dun, dun dun dun dundunOoo can ya hear me now?
Firefox in ya house
No more popups now
Get Get GetFirefox.comHey, Blake's in the House!
What up? Asa Now!
Get Get GetFirefox.com
Get Get GetFirefox.comWe ain't stoppin now
50 mill downloads how
Get Get GetFirefox.com
Get Get GetFirefox.comAwww we got tab browsin' yo
an' Mitchell in volcanoes
We spread firefox like a dirty ho
Don' f'get t' use protection, thoGet Get GetFirefox.com
Get Get GetFirefox.com
Hollah!!! Stop.
Oh, you got it nowFox_E_Mama in the house
You know it ain't stoppin now
Spreadin Firefox with 'er mouth
Unh, Unh, Get Get GetFirefox.comGet Get GetFirefox.com
Get Get GetFirefox.comWord out.
I'm out mothefoxes!
Much respek to Fox_E_Mama for this great sh*t! I can't wait to hear the audio version!
As I commented on that post (markup edited):
As I said earlier, I really like this song, and I would love to hear it. I think it's really funny as a joke, but it would be even better if you were serious with it. :)
I only have one complaint though: your spelling is very bad. For example, you have
Hey, Blake's in the House!. What?the? Everybody knows it should be "da"!"Hey, Blake's in da House!"
Much better. Other than that, I think you should continue with this. We really need to get the gangsters (even if it's only the wannabe gangsters) using Firefox too. Firefox is for everybody! ;)
Anyway, great work, keep it up! Note that this work is released under the CC Attribution-ShareAlike 2.0 licence with attribution to Fox E Mama.
Font Smoothing
Font smoothing is definitely a problem for designers all around the world currently. Many designers choose to replace text with images (with or without alt attributes) because of this. sIFR could be a very cool technology and, when used correctly, seems to be very handy (although I haven't used it myself yet); however, this is nonetheless a workaround for a fundamental issue and should be unnecessary to begin with.
Some people might suggest that this is a browser problem and that the browser should employ font smoothing for text by default. Indeed, that would be much better, but this is not a browser issue; it's an operating system issue.
There are a huge amount of applications that display text to the user; why should the browser be the only one to display text nicely? What about word processors, etc?
Microsoft Windows and other systems actually have some font smoothing technologies in place already; however, they don't seem to be enabled by default. On Windows 2000, open the desktop's context menu (for most people that would be to right-click on the desktop) and choose "Properties". Go to the "Effects" tab and make sure the "Smooth edges of screen fonts" option is turned on. On Windows XP, the option is also somewhere in the desktop's properties dialog, but it's a bit harder to get to. I can't remember precisely how to do it and I don't have a Windows XP box to check on right now; sorry. But you should be able to find info on it in the Windows Help.
One thing I can remember though is that Windows XP actually gives you two options: standard font smoothing and ClearType.
ClearType is actually a technology for flat panel screens; read Sub-Pixel Font Rendering Technology for more details.
On Linux, font smoothing seems to be far trickier although when you get it right apparently it works great. I haven't tried myself, and I really don't have the time to hack around now, but there's a lot on Google about it. I found a guide to getting it right in Gnome, but although KDE does seem to have some options it seems like it's not that hot at the moment.
These things should be sorted out and enabled by default on all systems!
Please note: I really don't care that Flash's font smoothing might be totally superior, because (for most of us) the implementations in Gnome and Windows are more than enough! :P
Please note another thing: I'm well aware that sIFR also allows you to use any font you like, but as I mentioned earlier CSS 3 will allow us to do that too into the future when (not "if" since I'm counting out IE) it's implemented.
Non-English User Groups
There was a (pretty heated) discussion going on in one of the LUG mailing lists I'm subscribed to recently regarding language use on the list. I didn't want to air my views since it was turning into a kind of a flame war, therefore I'm just going to post about it from the comfort of my own blog.
The list is mainly English, and some people are of the opinion that it's ridiculous for Afrikaners to speak English to each other.
I agree; by all means, when two Afrikaans first-language speakers speak to each other in a private discussion, why speak English? However, I do not think that one should speak a language like Afrikaans on a mailing list with a fair probability that some of the members on the list might not understand Afrikaans properly.
For example, let's take another language like Xhosa. It would irritate the crap out of me if some people would start to speak Xhosa on the list, not because I've got anything against that language, but simply because I don't speak it myself. Some people would say: "Simply ignore those mails!"; however, I'm already getting so much e-mail that I really don't need to be sent more that I can't even read.
This whole business does open up an interesting discussion, though. We at Translate are trying our best to translate software and documentation into the various local languages and to develop software to aid us in this. The reasons for us doing this includes:
- It makes the software more accessible to people that don't speak English.
- It's more fun to use software in your own language.
Ok, so now we've got localised software and maybe even localised documentation; however, what about localised support? Just as I don't want to be subscribed to a Xhosa mailing list, why would a person not speaking English be subscribed to an English mailing list? It would certainly be irritating, frustrating, and more-or-less useless for them.
Ok, so many people (especially Americans) would say: "Well, just learn English!" First of all, if you don't grow up with it, it's not all that easy. Even I, having grown up hearing a lot of English on TV, still struggle often (as you can probably see on this blog) and can never compete with a real native English speaker.
By all this I thoroughly realise that there seems to be a severe shortage of "localised" user groups (or user groups catering specifically for other languages than English) in South Africa currently. I think we should really consider starting open source communities for open source support in other languages like Afrikaans, Xhosa, etc.
I'm simply too busy with too many projects already; I can't start something like the Afrikaans Linux User Group (or Die Afrikaanse Linux-gebruikersgroep for that matter) in my current schedule. However, I'm going to be posting/asking around a bit for feedback. If there's any Afrikaans people reading this blog that might be interested in joining/starting such a group, please let me know!
Open Source Articles
I don't think many will disagree that the Spread Firefox community is doing an absolutely superb job of marketing Firefox as well as Thunderbird and now even Sunbird. I'm truly proud of it.
Articles about Firefox has appeared in so many online and offline publications the last couple of months that it's really astounding. It's even better to think that the money, often running into the thousands, paying for some of the advertisements has been sourced from the community willingly donating to spread the word.
However, the old open source motto still applies, even to marketing: Why pay if you can get it for free?
Many publications in South Africa (and I am also lead to believe in other places of the world) are willing to include some articles written by members of the public. Many newspapers and magazines even feature technical sections for technology-related inserts. Typically, if you can write a good article and manage to convince them that it's useful to their readers, they'll publish it at no cost to you! Why not exploit this to spread the word even further?
So, if you think you've got good writing skills and a limited budged, try your hand at writing something about an open source product that hasn't been reviewed in that particular publication yet, and see if you can get some free articles in your local newspaper/magazine/whatever. It can only help to get even more people interested.
Another project I would really like to get more people involved in is to actually create article templates. These templates can be a fairly maximal review of some product, and with the input of many individuals in the open source community I believe one can get quite a good article together. Then users can download the template, customise it for their specific needs and cut down where necessary, and get it published. Also, think translations for great localisation. That's anyway must easier and faster than starting from scratch. Here, again, another open source principle (actually a hacker principle, but what's the difference?) applies: If a problem has been solved once, why solve it again? Why do work that has already been done? It is, simply put, unproductive and unnecessary.
A wiki could be used for these purposes; multiple people can edit and there's a complete version control system in the good wiki systems. Although, not too many people should work on a particular article at the same time without properly consulting each other, otherwise it'll quickly become a mess.
Open source is a community effort. Let's get it together and help each other not only with building great software packages and documenting, but also with marketing. :-)
Open Source? It's Free?
The term "Free Software" seems to be ambiguous to most people. For some, it might mean "freedom software" (the right meaning), but for most it seems to mean "no-cost software".
When doing Afrikaans translations, this becomes a bit of an issue. While the English word "free" can have various meanings (as shown above), in Afrikaans there are separate words for these two meanings. "Free" as in "freedom" is "vry" and "free" as in "no-cost" is "gratis" or "verniet".
On the Afrikaans discussion mailing list at Translate, we were discussing the correct translation of the word "free". Dwayne Bailey also brought up a very interesting issue about marketing open source software, which happens to be so interesting that I feel I should blog about it.
One of the major concepts for us in Africa is that open source is no-cost because commercial software is relatively (very) expensive for us here. Therefore, we thought that one of the major reasons for people to use open source software is because it's affordable. This is indeed the case, but we also soon found out that this issue is more complex than we originally thought.
When you market open source as being no-cost, you actually seem to get many of the wrong kinds of people. You know, the kind of people that wants everything for nothing. It seems like many people think that, because the software is free, the training and support is also free. In other words, they actually want you to train (in other words, put up with) end users for nothing in return and actually give them 5-star software support at no charge too.
Remember, these are the kind of end users that think it's OK to phone you 1:00 in the mornings because they don't know how to start one of their games. And the kind of people that would expect you to drive 80 KM to their premises using your own transport to set up their e-mail account without any form of financial (or other form(s) of) compensation.
In short, you get the "bloodsuckers". I'm sorry; there I said it.
Of course, it's necessary to note that this isn't always the case. However, in general one should be very careful not to attract the wrong kind of people. Yes, open source is for everybody, but don't put yourself in a bad situation and remember that there must be strictly no exceptions. Anybody that has ever been involved in that kind of politics will be able to tell you how users (especially those in poorer areas) will try to play you to get more for less. Be strict with these guys at all times!
Oh, but you did this for x-x-x, why can't you do it for me too?
You think it's bad? It's worse than you think. Believe me. The sickest of all is that the first to plead poverty are the ones in the latest BMW convertibles and Mercedes-Benz's.
Ok, so it's really quite obvious that this isn't the way to go. Of course, there's (I guess) nothing wrong with saying that it's no-cost, but be very careful not to overemphasise it.
The worst thing of all is that it seems many people, especially the "better off" part of the population, think that the software must be crap (you can't get good quality for free, can you?).
From now off onwards, I believe I will emphasise the fact that the software is high-quality, compatible, reliable, secure, etc. more than the fact that it's no-cost. I would advise you to do the same if your community is at all similar to mine! :-)
Ali G a South African?
Ali G claims to be British; however, after watching him the past couple of weeks on TV, I'm almost convinced that Ali G is either a South African or got some serious inspiration from this place. Here is why:
First of all, any normal Englishman would say "Respect!"; Ali G, on the other side, prefers "Respek" which happens to be the correct Afrikaans pronunciation and spelling of the word.
Also, his phrasing closely resembles Afrikaans. For example, I is here with my mate...
is definitely not English. But now, let's take every word and replace it with its Afrikaans equivalent independently without changing the phrasing/grammar in any way. Now we get: "Ek is hier met my maat..." which is perfectly normal and acceptable Afrikaans.
Lastly, which country is the world capital for gangsterism? Surely, with places like the Gauteng Province (nicknamed "Gangsters' Paradise") and the Cape Flats, we are giving the rest of the gangster world a rather hard time to keep up. And don't forget about this blog itself, please!
Just some food for thought...
What? You Hotmail bastards!
Ok, now I've seen it all:
*250MB inbox available only in the 50 United States, District of Columbia, and Puerto Rico. Eligible Hotmail users will first receive 25MB at sign-up. Please allow at least 30 days for activation of your 250MB storage to verify your e-mail account and help prevent abuse. Microsoft Corporation reserves the right to provide 250MB inbox to free Hotmail accounts at its discretion.
Well, at least now I know why I still only have 2MB on my Hotmail account (which I'm not using anymore by the way, for obvious good reasons).
Ok, Microsoft's nickname is "Micro$hit", Internet Explorer's nickname is "Internet Exploder", so let's have a Hotmail nicknaming contest. What about "Hotfail", or even better, "Potmail" since you probably need to get smoked in order to put up with their service.
We could also try "Rotmail" or something... That would mean "rat mail" in Afrikaans and "bad mail" in Dutch.
But on a more serious note, I really don't know how they think they'll keep the competitive advance with GMail and even Yahoo Mail these days...
Open Source CD/DVD
TheOpenCD is a CD image packed with basic open source software packages (including Firefox and Thunderbird, naturally) for Windows. The autorun is set to a browser based on K-Meleon that allows you to browse between the various available software packages on the CD, complete with short descriptions for each package.
In South Africa, they're distributing these CDs for free through the Go Open Source campaign, and it seems to be very successful. All the copies I have disappear faster than about anything else, since many people that aren't ready yet for Linux are interested in open source software for Windows.
I think this is a truly great project, but two things bother me a bit:
- The software in the CD image isn't updated very frequently.
- Where's the DVD?
Software (especially open source) updates so fast that it's typically a waste to burn anything to CD. Just download it from the net when you need it. Heh, sure that works in "normal" countries, but not bandwidth-starved countries like South Africa. Therefore, we really need CDs. I know updating CD/DVD images are a pain in the neck, but (in my opinion) one should preferably create an update every two months at most to keep up; there's really no point in burning outdated stuff.
About every (at least half decent) computer gets sold with a DVD reader these days. I think it's becoming more and more practical to look into creating a DVD version of The Open CD so that one can fit in much, much more software!
Just think about the possibilities... Let's think only Firefox for a second. One could fit the latest Firefox for Windows, Linux, and Mac OS X complete with extension, theme, and language pack libraries! Similar with Thunderbird.
Open Office for various platforms complete with all the dictionaries one can imagine...
And just think about the possibilities of including documentation, help, and general information regarding open source. Even multi-media...
I don't know what to call the project though, because "The Open DVD" seems to be already taken. :-)
The only problem with the DVDs is that many people using older computers (typically poorer people) will not be able to read them. So the CDs will still keep their use after all (for now). :-)
The reason I'm talking about these things is because I want to start a few open source CD/DVD distribution projects in my local area. But more on that another day. ;-)
Unicode Normalisation
Anne van Kesteren wrote an interesting article about Unicode’s dirty little secret, which looks like something that one needs to keep in mind if one writes in a "different" language.
In Afrikaans, we have quite a few special characters like ê, ë, ʼn and many more that are quite commonly used. ʼn (ʼn) can also be written in two characters as 'n, although I guess the first is preferred since, when you want characters written vertically, you would have:
ʼn C h a r l
Instead of:
' n C h a r l
As if catering for character references and validating your UTF-8 isn't bad enough, here is even more stuff to keep in mind. Well, who ever said life was going to be simple? :-)
Spam on Blogger
I received my first piece of comment spam a few weeks ago here on Blogger. Ironically, that was the first time I actually realised that Blogger implemented (as to be expected I guess, being part of Google and all) rel="nofollow" for comments.
Between then and now, I've received (which probably amounts to) a few dozen comments advertising porn and other crap here. I swiftly deleted them all, and will continue doing so, but this morning alone I got about five new spam comments and I fear that if it's going to go on like this I don't know what to do. I might have to close comments to users which aren't registered in Blogger (which is obviously something I would really not like to do), but this particular spam seems to be coming from a registered Blogger user, actually, so even that wouldn't work.
I'm quite angry at Google for this whole situation. In my opinion, the whole rel="nofollow" business is a really poor attempt to stop spam.
Firstly it's unsemantical; the name nofollow doesn't represent at all what it actually is supposed to do. It's got nothing to do with following, it's got to do with not having it count towards the pagerank of the site the relevant link points to. unendorsed would have been a much better, clearer, developer-friendly and semantical choice. Yes, go ahead and swear at me for being a semantic purist, stick to semantic crap if you like, but nobody can tell me Google really sat down and put some thought into this one...
Secondly, and most importantly, this just doesn't work. This is thoroughly proven now by this blog. I mean, I never received a single piece of comment spam (as far as I could tell) until after they've implemented rel="nofollow". There were many predictions that it wouldn't work, and indeed, it doesn't. I'm still receiving comment spam; the spammers are specifically targeting Blogger blogs (having a registered user on Blogger and all) even though, as they should know by now, it's not really helping them build pagerank at all.
Until now, I was under the presumption that spammers are just simply looking after their own financial interests, but now it seems like they're either very thick people or they just enjoy irritating the crap out of the Internet (or maybe both).
The only way to stop comment spam is to make the system bot-proof. There are actually practical and even accessible ways to do this - just see the comment system in Lachy's Log for instance. Ask a very simple question every "normal" user could answer and evaluate it. Forcing previews also still seem to be working perfectly, as bots are not smart enough to look past this.
At the end of the day, do anything as long as it's unique. Spammers don't normally target individual sites - they target "standard" blogging software installations since that's what most people are using. However, there are also thousands of ways to create a "user friendly" anti-spam system for new bloggers without a knowledge of PHP etc.
Please, I beg you Blogger people, implement a proper spam protection system. Not this poor attempt that isn't working anyway.
Lachlan Hunt has a brilliant article about rel="nofollow" I would recommend you to read if you need more info on this matter.
Microsoft Roadshow
Although this post is actually published a bit late, I was present at the Microsoft Roadshow held at the NMMU York Street campus in George on the 6th of May 2005.
All-in-all it was quite interesting. My opinion was that Microsoft is a pretty crappy organisation, and I still think it is to a certain extent, but my opinion definitely changed for the better now.
The speaker (sorry, can't remember his name) was very energetic and enthusiastic, which is always fun. The only thing I didn't like was that his slideshow had some colours that made it difficult to differentiate between the text and the background which made it virtually impossible to read the text. I can't remember all the exact combinations, but I think one of them was light-yellow on white. Personally, I also have a problem reading yellow on blue, but that's just me since others seemed to read it fine.
But that is really the only complaint I had.
One thing I learned about was Microsoft's commitment to web services standards. Apparently, they signed a paper along with other member organisations of the W3C that they would follow the web services standards set forth by the W3C and that all extensions they make to the web services would not be released in their own software unless it's compliant to other implementations. This is truly great news; I really wish they had that same kind of commitment to other standards too. But nevertheless, this is a big step in the right direction.
One thing that was interesting to me and others was that the speaker talked about compatibility with Linux and Java and didn't talk about those in a negative or derogatory way at all. As a matter of fact, the speaker actually sounded quite positive about these technologies.
And yes, in case you're wondering, I got some free stuff for answering what WSDL stands for and how the web services proxy classes work. I got a T-shirt and a keyring. :-)
Another interesting thing they have going is the Project Firefly (it's difficult to spell "Firefly" because for some reason I keep typing "Firefox").
This project is all about getting students to create applications and do research, and then they award prizes and a trip to Japan for the leading teams. Cool!
Anyway, this is just a short report of what happened. But if I hear more from them I'll let you know.
The Problem with Creative Commons
I absolutely love and support the Creative Commons initiative, and I frequently make use of their licences; however, there's one problem.
All the Creative Commons licences require that you give attribution to all the authors for using their work. This is all good and well in most cases, but there are times where giving attribution is rather hard.
For example, take printable materials. Let's say I create a flyer and distribute that under any of the Creative Commons licences. What is a person from America now exactly supposed to do when he wants to print out those flyers and hand them out to people? Surely he can't hand one to a person and then tell them "Hey, this is with compliments from Charl van Niekerk, a person from the other side of the globe that you neither know nor are able to pronounce his name out correctly"?
Ok, not like anyone is really going to bother in such a case, but there are situations that are much more serious. For example, let's say I create a template for a newspaper article that a person wants to use for his local newspaper. Newspapers are big business, and with big business, you get big issues; copyright is not taken lightly in these cases. You simply don't have space in a newspaper to waste on trivialities like "this article is based on work by so-and-so and has been modified by so-and-so and so-and-so and is released under this-and-this licence".
Ok, many people might say, release it under your own licence. Well, easier said than done. I, for one, don't have a clue about all the potential legal issues hiding away behind copyright. I mean, why even bother with "proper" licences like Creative Commons in the first place? Those licences have been set up by lawyers, the kind of okes that actually know what they're doing. And for good reason.
Why not just ignore licencing totally? Well, a person using my work in a way as described previously will simply be believing in my goodwill while using my work, although legally (if I make an issue out of it) he might not have a foot to stand on.
Sorry, might work for some people, but not for me. When we're talking big, and I mean big, believing in goodwill is just not enough (or at least not in this world).
Ok, so what about just giving up my copyright entirely. "This work is not copyrighted in any way" or whatever. Ok, but what if I don't want to give up my copyright? What if I want to have people that build on my work also distribute the derivative work under the same concepts of freedom as I distributed my originals? Or what if I don't want them to use it for commercial purposes? (Remember that newspaper articles could be seen as commercial or non-commercial, depending on various factors, so this is again a red herring on its own, but I'll cover that another day.)
I'm not a copyright expert, so maybe I'm just being totally ignorant here, but I believe we need another Creative Commons licence. One even more liberal than the Attribution licence that will allow people to use my work, albeit under certain conditions and restrictions, while not forcing them to specifically give me direct credit when it's used.
I don't know, just a thought. Depending on the comments I get on this post, I'll be forwarding my ideas to Creative Commons.
Of course, a person can always ask the author for special permission to use their work without giving them attribution, but in certain cases (like with the example of the newspaper article template) it would be easier to just have a licence that grants everybody that permission in one go. Also, the issue gets more complex when you have multiple authors... That's what special licences are for, yes?
Coding hacker-style or crap-style?
Update: Between all the mess, I made another very stupid mistake. I forgot to include - ((y1 + 1) % 4) inside of the brackets along with y1 + 1. Corrected.
Much respect, or as we say in South Africa, respek (no this is not Ali G talk, this is the actual spelling in Afrikaans - who ever said Afrikaans isn't cool?) to Andre Grobbelaar for pointing out the (really stupid) mistake I made in the C++ code I published in the article Coding C++, Hacker-Style almost two months back.
The mistake was hiding away in my logic. I never checked for any leap years between the first and the last year. The solution turned out to be a bit more complex than I originally anticipated, so let's walk through the solution right from the start.
Here's a dump of the problematic code for easy reference:
#include <iostream>
using namespace std;
int pos(short m, short d, int y) {
int p = 0;
for(short i = 1; i < m; i++)
switch(i) {
case 1: case 3: case 5: case 7: case 8: case 10: p += 31; break;
case 4: case 6: case 9: case 11: p += 30; break;
case 2: if(y%400 == 0 || (y%4 == 0 && y%100 != 0)) p += 29; else p += 28;
}
return p + d;
}
int main() {
short m1, m2, d1, d2;
int y1, y2;
cout << "Please enter a start date (mm dd yyyy): ";
cin >> m1 >> d1 >> y1;
cout << "Please enter an end date (mm dd yyyy): ";
cin >> m2 >> d2 >> y2;
int p1 = pos(m1, d1, y1), p2 = pos(m2, d2, y2);
cout << "Difference in days: " << (long)(y2 - y1) * 365 + p2 - p1;
return 0;
}
I marked up the code in question above with strong.
Firstly, let's take a closer look at the problem. Leap years are taken into account for the first and last years in the pos method; however, later we simply multiply with 365 for all of the years in between without taking into account the leap years there.
The simplest solution would be to calculate the amount of leap years, and therefore the amount of extra days that we're missing and then add these to the rest of the equation.
The years in question is, as I said, the years between the first and the last years. In other words, the years y1 + 1 to y2 - 1. The logical step from here is to calculate the difference of these years:
int x = (y2 - 1) - (y1 + 1);
Next we need to take the start offset into account. The end offset doesn't matter, since that will automatically be canceled out when we do integer division later. In order to make this work, we need to round y1 + 1 down to the nearest year divisible by 4. In C++ this is quite easy (please note that the % operator has a higher precedence than the - operator, but brackets have been added for readability):
int x = (y2 - 1) - (y1 + 1 - ((y1 + 1) % 4));
Now finding the amount of leap years is trivial:
int x = ((y2 - 1) - (y1 + 1 - ((y1 + 1) % 4))) / 4;
However, only leap years that don't fall on a so-called "century year" (like 1700, 1800, 1900, etc) are valid, although there is the exception that a "millennium year" (1000, 2000, 3000) is always a leap year.
I think the easiest way to cater for this is to calculate the amount of century years and subtract them from x, and the amount of millennium years and add this to x again.
Calculating the amount of century years is much similar to calculating the amount of leap years earlier:
int y = ((y2 - 1) - (y1 + 1 - ((y1 + 1) % 100))) / 100;
Of course, in this case we could take a slightly simpler approach to rounding down y1 + 1:
int y = ((y2 - 1) - ((y1 + 1) / 100 * 100)) / 100;
Now we do the same with the millenniums:
int z = ((y2 - 1) - ((y1 + 1) / 1000 * 1000)) / 1000;
And then our final result should be:
int leapYears = x - y + z;
Now, before we insert this into our actual algorithm, we do a bit of maths and simplify the whole business to get this:
int leapYears = (y2 - y1 - 2 + (y1 + 1) % 4) / 4 - (y2 - 1 - (y1 + 1) / 100 * 100) / 100 + (y2 - 1 - (y1 + 1) / 1000 * 1000) / 1000;
And here comes our finalised algorithm with the differences highlighted with strong:
#include <iostream>
using namespace std;
int pos(short m, short d, int y) {
int p = 0;
for(short i = 1; i < m; i++)
switch(i) {
case 1: case 3: case 5: case 7: case 8: case 10: p += 31; break;
case 4: case 6: case 9: case 11: p += 30; break;
case 2: if(y%400 == 0 || (y%4 == 0 && y%100 != 0)) p += 29; else p += 28;
}
return p + d;
}
int main() {
short m1, m2, d1, d2;
int y1, y2;
cout << "Please enter a start date (mm dd yyyy): ";
cin >> m1 >> d1 >> y1;
cout << "Please enter an end date (mm dd yyyy): ";
cin >> m2 >> d2 >> y2;
int p1 = pos(m1, d1, y1), p2 = pos(m2, d2, y2);
int leapYears = (y2 - y1 - 2 + (y1 + 1) % 4) / 4 - (y2 - 1 - (y1 + 1) / 100 * 100) / 100 + (y2 - 1 - (y1 + 1) / 1000 * 1000) / 1000;
cout << "Difference in days: " << (long)(y2 - y1) * 365 + p2 - p1 + leapYears;
return 0;
}
I could easily have made a logic error here somewhere, since we're trying to do something that requires a fair amount of complexity. If you think I made an error, or you spot something that requires further explanation, feel free to comment!
Also, in practice, one could consider rather using integers of type long instead of int for C++ (Java's int is a C++ long anyway as far as I know).
Yahoo! Mail 1GB
I don't really use Yahoo a lot, but the other day I logged in again and something got my attention.
Yes, it indeed seems like they're now offering 1GB of space to customers of their free e-mail service. And yes, it's quite obvious why. If you don't have it yet, think "G" and then think "Mail"... Ok, I've really said enough; if you still don't have it, you must have been asleep for like the last year or so.
Hotmail is also providing 250MB for free, and if you pay 19.99 per year you get the full Monty with 2GB of space.
One thing I don't understand at all though is that my Hotmail account (which I've had for the last 6 years) still only packs 2MB and fills very fast with the rather large amount of spam I'm getting there.
Since I still have some legitimate stuff coming in there and therefore since I'm still checking it every few days, I don't understand why they don't "supersize" my account too. Why should new users get so much space while I, their 6-year-long customer, must be satisfied with 2MB? Not nice, not nice at all!
Well, this indeed proves that Hotmail sucks bigtime (like we didn't know it already).
And both Yahoo and Hotmail will still have to start getting their acts together. GMail is already giving out well more than 2GB for free, proving that it's still the top option at the moment for most people.
But then again, I guess not everybody needs so much space anyway...
PDFs: The follow-up post
After my initial post about the PDF format, I received many interesting comments. The post seemed to have came out a bit more serious than I actually intended it, and some people even thought I was provoking or trolling or something. ;-)
Sorry to disappoint you, guys, but I was and still am actually quite serious!
However, I am now convinced that there are certain cases where PDF might be a better choice, even for the future, though I'm still largely against it.
Anyway, time for a follow-up post. :-)
Standards
PDF is actually not really as proprietary as I made it look in my previous post. It was/is largely developed using the proprietary development model, yes, but the standard is actually quite open.
Speed
The Adobe Acrobat reader is very slow to start up, and sometimes it feels like my browser is crashing on me while it does. Remember that I'm in Africa and can't always afford the latest technology, although my equipment isn't really that old.
What I failed to mention last time is that there are many other applications that can also read PDFs. For example, the Foxit PDF Reader (thanks, Simon). Foxit is certainly much faster than Acrobat, curing some of my headaches. ;-)
Another issue related to speed is when you open up a large file. PDF allows you to skip to a specific part in the document without having to first (down)load/open it all. This is a feature XHTML and even HTML will never be able to provide, since even though incremental loading can potentially be achieved for both formats, the nature of SGML only allows for loading from top-to-bottom. Therefore, if you want to skip to the middle of the document, you'll first have to wait for the top part to load.
This problem can quite elegantly be solved by splitting the document up into multiple separate documents with a good navigation scheme to move between them. However, if you want to print something out, you want it all in one document logically. A good authoring tool should be able to handle splitting the large document up and maintaining the navigation scheme all very well. Having this document in XML still carries advantages above having it in PDF as I'll explain lower down.
I do believe that a XML/CSS combination used well will result in a smaller file additional to maintenance benefits. Remember that CSS allows you to easily do complex formatting on separate classes that can be repeated over and over again. At the time PDF was created, they didn't nearly have the knowledge, experience and techniques we have these days.
Also, although I'm not exactly sure how graphs are stored in PDF, they will most likely be able to be much more flexible and compact in SVG.
Layout/Formatting
With the almost unlimited power of CSS with absolute positioning, z-index etc it is difficult to imagine a layout that isn't at all possible with CSS.
Ok, so what are the actual possibilities of doing complex formatting reliably in CSS? Well, this is a very good question and currently it doesn't seem too good. If I may quote Ben Ward's comment on my previous post:
Interesting read, but I think there's a fundamental flaw in your XHTML/CSS replacement suggestion: namely that CSS isn't and wont ever be a 'pixel perfect' tool. The Working Group members (certainly Ian Hickson) have said this themselves.
PDF offers a document format that's supported well enough to implement reliably on multiple platforms (unlike, say, Microsoft Word) and provides the means for pixel perfect layouts. On the web this isn't as important but just as with demands for specific fonts, pixel layout is something that the print industry needs and uses.
The points about "choosing the right format" are very true, but I think that's a separate issue from attacking PDF itself.
Although I don't always agree with what Ian Hickson is saying anymore, this is indeed very true and I completely agree with what Ben wrote here.
Flexibility
XML/CSS is in essence much more flexible than PDF. PDF was built right from the start for printables and is therefore supposed to be as strict on the layout and formatting as possible.
This is not always ideal, even for printables, because let's think about it for a second. In Europe, South Africa, Austral Asia and I presume other places in the world too, we use standard A4 paper for everyday printing. In America, they commonly use the U.S. Letter format, which has slightly different (though somewhat significant) dimensions.
What normally happens when you print on paper with different dimensions, your document gets resized from the original paper size to the destination size. This is quite logical and works well most of the time. However, as I think most would agree, many layouts could benefit from being more flexible to fit any paper size perfectly, no matter which kind of paper you're using.
This now opens up a can of worms. What if my layout breaks? What if my layout is extremely strict and it should rather be automatically resized than be adjusted? Well, many of the same rules that apply to screen/projection (and other media) stylesheets apply to print stylesheets as well. You never know how your document is going to look on another person's screen, and that makes flow layouts so cool. However, if you really need to, you can create a fixed layout easily that I presume will be resized by the user agent. Out of principle, you should be able to make your layout as fixed or as flexible as you like. The point is that here you do actually have the power to decide.
I don't know what the current implementations do in all of these cases. The only thing that will reveal that is to do some proper testing. Although I'm experiencing a bit of a shortage of time at the moment, I'll try my best to look into it over the next couple of weeks. If you want to take the initiative, please do and let me know of the results!
One time you certainly don't want to let your layout be is too flexible when you're using a table of contents with page numbers. This might actually be quite a bit of a problem and might prompt you to rightfully stick to PDF for now.
What would have been ideal, of course, is if the User Agent could automatically generate a Table of Contents based on the heading structure of your document. Some applications do this already; maybe something to look into.
As a last thought in this section, think about this scenario: I design an image in SVG. When this is converted to PDF, I presume it will be converted to a normal image and won't be vector-based anymore. That might be fine for my purposes, only printing on a sheet of A4 paper. But tomorrow somebody wants to print it on a rather large poster or even a banner somewhere. Resizing the PDF might create terrible pixilation, however, the user agent resizing the vector-based equivalent will look much, much better.
Extensibility
There's already a ridiculous amount of XML-based formats available currently to express data. It seems like a real waste not to be able to use them. One of the main points behind going in against the PDF format is that why should we use different technologies for printing than what we use for display on a computer? Especially with print stylesheets making much of this possible, why not use those?
Copyright
PDF allows you to set an option that tells the viewer it shouldn't allow the user to copy text from a particular document, even if the text is stored as normal text (i.e. no images). This is another major motivation for current content publishers to use the PDF format because they (somewhat incorrectly) assume that people won't be able to copy their work.
The truth is that a viewer application supports that out of own will. Yes, of course Acrobat will support that, but there are viewers you can use (I'm rather not going to link to them from here for obvious reasons) that don't abide by that "law". Out of technical principle, anything that can be deciphered as text can be digitally copied some way or the other.
I also don't think that there's anything wrong with copying text as long as it falls inside limits, for example to do a small quote which otherwise needs to be retyped etc. Of course, some people use it for blatant plagiarism and copyright abuse, but the truth is that there's always a way for some users to "crack" something. However, at least this feature makes things fairly end user-proof.
A typical XML setup will facilitate copying/modifying freely so this might be a possible deterrent from using it and sticking to PDF.
Fonts
One thing I remembered too late to include in my original post was fonts. Fonts can be included in a PDF file so that it will display correctly on all platforms. This is indeed a very handy feature.
CSS 3 Webfonts Module Font Descriptions (currently last call) introduces a technique to do this too by allowing you to link an external font description file to a font name. Of course, this is CSS 3, but as I said in my previous post we'll only be able to replace PDFs when the relevant technologies are all well supported (in other words, we're talking about futuristic techniques, not what we can use currently).
Multiple Files
The fact that normal SGML documents typically need to save as multiple files (images/stylesheets/scripts/etc) is sometimes a bit pesky, but since most of the content on the web is not even available as PDF and many users (especially those with non-permanent internet connections) like to save web pages somewhere locally this might be something to rather get used to. Users should just get used to dealing with separate files and maybe local file browsers, like some already do, could make it easy for the user to associate the folder containing all of the "baggage" to the base SGML file somehow.
Re-inventing the wheel
One option is to reinvent the wheel to a certain extent. Create an open non-XML format with all the features of PDF and more, but get it developed using the open development model instead of the proprietary development model used to develop the "open" standard we call PDF. Use all possible modern techniques and create a great new format with much more public input.
The issue, however, is that PDF is already well-supported and the advantages are not all that obvious. Yes, surely you'll get a much better format, but at the end of the day it's most likely not really going to be worth the time and the effort.
The switch to an XML-based language, however, isn't so major since we can build on what's already there. There are a substantial amount of advantages in moving away from PDF as I've illustrated in this document, and also a few disadvantages naturally.
Conclusion
As Hayo mentioned, it will take a long time for all of the technologies mentioned in my previous post to become properly supported (history speaks for itself in this case). And print companies will most likely be some of the last. Currently, it seems like most of us will be sticking to PDF (I myself included). When backwards compatibility is of the essence (keeping IE in mind, assuming the worst) the only real reliable choice will be PDF for many years to come.
When really precise and very complex formatting is required, I guess PDF will also stay the format of choice. However, if I look at the amount of PDF files currently in existence around the web, it is still very clear that PDF is a largely overused format. I believe many people will benefit from switching to XML-based formats into the future, but first we need the support!
Also, remember that there's absolutely nothing wrong with offering the same content in XML and in PDF. That's actually the way to go - keep backwards compatibility while providing better alternatives to those that are "enabled". Remember, good authoring tools could be able to do multiple formats in one go!
If that's not an option, "choosing the best format for the job" is probably still the best thing to do for now and for long into the future.
Copyright © 2004-2008 Charl van Niekerk. All articles are released under the Creative Commons Attribution 2.5 South Africa licence, unless where otherwise stated.

