Pages

Thursday, April 19, 2007

Php, Firefox and IIS - Authentication Required message for localhost sites

I had some trouble trying to run some php scripts located on an virtual site located on a different place than the default root site of iis (c:\inetpub\wwwroot). In my case the scripts where located on d:\sites.
What I found is that I have to set the doc_root setting of the php.ini file to d:\sites
;doc_root = "c:\inetpub\wwwroot"

doc_root = "d:\sites"

Now the php script run very well on internet explorer but accessing the script with firefox browser give me an Authentication Required message box asking me to enter an user name and a password. To address this issue I googled here and there and I found that I have to configure Firefox by setting the network.automatic-ntlm-auth.trusted-uris entry of the about:config file to value localhost
Further reference:
http://en.wikipedia.org/wiki/NTLM
http://www.mozilla.org/projects/netlib/integrated-auth.html
http://www.crossedconnections.org/w/?p=89

Reference equality, bitwise equality and value equality

Reference equality means the object references that are compared refer to the same object.

Bitwise equality means the objects that are compared have the same binary representation.

Value equality means the compared objects have the same value even though they have different binary representations. For example, consider two Decimal objects that represent the numbers 1.10 and 1.1000. The Decimal objects do not have bitwise equality because they have different binary representations to account for the different number of trailing zeroes. However, the objects have value equality because the numbers 1.10 and 1.1000 are considered equal for comparison purposes since the trailing zeroes are insignificant.

Further reference : http://msdn2.microsoft.com/en-us/library/bsc2ak47.aspx

How to compare two fonts in .Net

Which of the two folowing expressions to use when you want to compare two fonts?
a) if (fontA == fontB)
b) if (fontA.Equals(fontB)

Answer
if you want to check whether the fonts have the same family font, same size, same style etc. use the first expression, (a) :
if (fontA.Equals(fontB)
if you want to compare if the reference of the fontA is the same as the reference of the fontB use the second expression, (b):
if(fontA == fontB) or the equivalent expression if ( Font.Equals(fontA, fontB) )

Further reference http://msdn2.microsoft.com/en-us/library/w4hkze5k.aspx

Thursday, April 12, 2007

XML CDATA

Astazi m-am lovit de urmatoarea problema: parsarea unui text in format xml de catre functia OPENXML intr-o declaratie T-SQL nu pastreaza spatiile la stanga si la dreapta ale textului dintre tagurile unui element.

De exemplu daca am

<separator>  -  </separator>

dupa parsare voi avea valoarea "-" pentru elementul .

Am descoperit ca pentru a pastra spatiile, trebuie sa introduc textul intr-o sectiune xml CDATA ( http://www.w3schools.com/xml/xml_cdata.asp) ca in exemplul de mai jos:

<separator><![CDATA[ - ]]></separator>
Asadar textul format xml va trebui sa-l construiesc astfel in .Net

xml.AppendFormat("
<separator><![CDATA[ - ]]></separator>>", separator);