Most information here is in English. Only entries not relevant for the international audience are in Dutch.



 2004.11.01
Calculating the Gregorian number for a given date

If you are interested in calendar math and want to develop the ability to calculate the day of the week for any given date, I present these postings I did here. With a little math and a little exercise it should be possible to determine the day of the week mentally within a few seconds:


[parts of discussion snipped]


Your little algorithm is too simple, because you assume that January 1st is the first day of the calendar. It is not. The first day of the year is March 1st.

You missed the fact that the number of leap years (or actually: days), between to given years, depends on whether the days of the year are before or on/after March 1st.

What you should do is normalise the Gregorian dates to a calendar that starts on March 1st (like the Julian calendar did originally, hence the leap day at the end of the year).

For those who are interested to know: historically the leap day is not on February 29, but February 23rd (excuse my possible off-by-one error). Not that it makes any difference for your question, but it is a good Triviant-question.

 
[parts of discussion snipped]
 
 
I wrote 'first day of the calendar', not 'first day of the year'. An important difference.

Taking January 1st as the start of the year is a modern convention introduced some places as late as the 18th century. I think the start of the year used to be celebrated in England as 'Mayday'. The names of the months still provide a clue as does the position of the leap day. More information via Google. If you use broadband I can email you the paperback with the details (in Dutch).

Calendar calculations are greatly simplified if the date is first normalised to a calendar that starts on March 1st. Then there is even a regularity in the number of days in each month. The calculation becomes so simple that I can mentally calculate the day of the week of any date using these normalised dates.
 

[parts of discussion snipped]


Forget directly calculating the difference in days. Just calculate the Gregorian numbers for both dates and subtract these.

To give you an indication how to do this (I do not have the complete algorithm at hand):

function gregorian(yy, mm, dd: Int) return Int
   --
   -- first normalise the input
   -- then calculate the Julian number
   -- then make correction to obtain Gregorian number
   --
    if mm< 3
    then m2 := mm+9; y2 := yy-1
    else m2 := mm-3; y2 := yy

    julian: Int := int(y2*365.25)+int(m2*30.6+0.5)+dd
    return julian - correctionForEvery100and400yrs + calibration

If well-calibrated, the function returns 1 for the first date of the Gregorian calendar, i.e. 0001.03.01.

Now do not ask me to give you the inverse of this function (-8.



 2004.10.30
Finding palindromes in texts

In a thread on Joel on Software I proposed the following algorithm for finding palindromes in texts (small editorial changes aside):

Finding palindromes is very simple using a different view of the matter.

Iterate over all the characters in the input text. Then comes the second and interesting part: assume that this character is the *middle* of the palindrome. So all you have to do is check the characters to its left and right etc. The third step is similar, but for even numbered palindromes: if this character and the next one are equal then inspect the characters to the left and the right of this pair, etc.

Obviously this is O(n^2) but it is simple to program and prove correct. It has good average time performance, approaching O(n), since most input texts have no or few palindromes.

[addition of 2004.11.01]:

Two simplifications are possible in the algorithm I presented. If a palindrome should not be sensitive to punctuation, then drop the punctuation from the input text *before* the searching. This greatly simplifies the most complex part of the algorithm.  However, be aware that the result thus obtained should be transformed back to the form where it had its punctuation. That should not be too difficult though.

The second simplification involves adding two different sentinel values at either side of the input text before the searching begins. These values must be unique in the entire resulting text string. Since they are unique, they can never be part of any palindrome. Therefore, they act as a very simple stopping criterion. Of course the outer iteration should now start at low+1 and stop at high-1.



 2004.10.29
Meer beveiligingstips

In het derde artikel met beveiligingstips staan aanwijzingen om problemen met virussen te voorkomen.



 2004.10.29
Beveiligingstips

De beveiligingstips voor relaties zijn uitgebreid. De komende tijd zullen er nog een aantal hoofdstukken bijkomen. Op dit moment zijn er twee artikelen: Beveiligingstips I gaat over spam, hoaxes en het kiezen van wachtwoorden. De tweede verzameling beveiligingstips gaat over patching en veilig gebruik van accounts.

In volgende updates zullen draadloze netwerken, veilige browsers, bestrijding van spyware en het computer-equivalent van onbeschermde seks aan de orde komen: attachments met de uitgangen .doc, .exe, .xls, .ppt, .jpeg, .htm en .html.. Ook zal het idee de wereld uitgeholpen worden dat een virus scanner voldoende beveiliging biedt tegen virussen. Een virus scanner is zo veilig als het wassen van de handjes na genoemde seks.



 2004.10.26
WBSO voor technostarters

In Nederland bestaat de WBSO-regeling die inhoudt dat een onderneming 42% van de loonkosten die toegerekend kunnen worden aan speur- en ontwikkelwerk in mindering gebracht kunnen worden op de afdracht loonbelasting. Voor technostarters is dat percentage zelfs 60%. In prima regeling zou ik zeggen, maar ook een die de doelgroep niet bereikt wat betreft dat percentage van 60%. Bij lange na niet.

Startende bedrijven hebben weinig overhead. Technostarters hebben in de beginfase veelal alleen maar technici in dienst. Ze hebben weining ondersteunend personeel om de kosten in de aanloopfase te drukken. Ook hebben deze bedrijven geen marketing-medewerkers en verkopers in dienst om de doodeenvoudige reden dat in deze markten niets verkocht kan worden als het nog niet klaar is. Percentages van 100% technici die voor meer dan 90% WBSO-deklarabel zijn, zijn niet uitzonderlijk. Dit zijn technostarters pur sang. Deze doelgroep kan niet profiteren van de technostartersregeling.

Zelfs als alle medewerkers vallen in de hoogste belastingschijf, komt de afdracht loonbelasting nooit uit boven de 52% van de loonsom. Omdat de WBSO-regeling alleen recht geeft op vermindering van de afdracht en niet op teruggaaf of doorschuiven, is de 60% regeling een hoofdprijs die nooit uitgaat. De enige bedrijven die in staat geacht moeten worden om gebruik te maken van de 60%-regeling zijn bedrijven met een aanzienlijke aandeel niet-deklarabele medewerkers. Dat deel van de beschikking dat niet opgemaakt kan worden op basis van de lonen van de S&O-medewerkers kan namelijk gekompenseerd worden met de afdracht over de salarissen van de andere medewerkers. Maar welke technostarter heeft tegenover elke deklarabele S&O-medewerker en niet-deklarabele kollega in de ondersteuning?

Een goede regeling, buitengewoon geschikt om bestaande bedrijven aan te zetten om een S&O-medewerkers in dienst te nemen. Dat is een beslist lovenswaardig streven van de rijksoverheid, maar heeft met technostarters niets te maken. Helaas zal het zo zijn dat deze bestaande bedrijven in het MKB vaak al te oud zijn om voor de 60%-regeling in aanmerking te komen. En als het al werkt, dan levert het niet het soort ondernemingen op waar het rijk in het innovatiedebat zo op zinspeelt, namelijk de kennisgedreven en technologiegedreven starters.



 2004.10.25
Photos

Added photos from Corsica and 's-Hertogenbosch.



 2004.10.20
Two XP-articles

I wrote two articles on Extreme Programming. The first 'Twee metaforen voor Extreme Programming' explains extreme programming using two different metaphores. The second article 'Hoe moet een stageverslag voor XP-projekten eruit zien?' explains how interns can write a report that meets the requirements as formulated by their institutions and that is not at odds with XP-practices. Both articles are in Dutch. Translations will be provided in due time.



All my blogs: