I’m sticking with firefox… for now…
Crome can’t block Google Ads, Firefox can. nuff said.
September 4, 2008 by lxcidLatin small letter Y with diaeresis (ÿ) in your memory.
August 1, 2008 by lxcidToday I learnt something from my boss; one of the reason why I love working for him.
When you see ÿ filled in your memory, it means that the memory location have been freed.
ÿ is 0xFF in hexadecimal or 255 in decimal.
P.S. My boss suggested that it seems to only happen only to Microsoft platform.
Interesting, isn’t it?
Verbatim String: a string precede with a @ character (the at sign).
July 29, 2008 by lxcidC# support 2 type of strings: regular string and verbatim string.
In this post we will try to explain what is a verbatim string.
An explanation of verbatim string in MSDN is:
A verbatim string literal consists of an
@character followed by a double-quote character, zero or more characters, and a closing double-quote character. A simple example is@"hello". In a verbatim string literal, the characters between the delimiters are interpreted verbatim, the only exception being a quote-escape-sequence. In particular, simple escape sequences and hexadecimal and Unicode escape sequences are not processed in verbatim string literals. A verbatim string literal may span multiple lines.
The MSDN explanation of is clear cut enough but allow me to give you one example:
@"\w+([-.]\w+)*\@\w+([-.]\w+)*\.[A-Za-z]{2,4}$"
The above string is a regular expression for validating an email address.
Notice in the above string, I used the ‘\’ (escape) character quite a number of times. But a closer observation will prompt one questions: none of the escape sequence make sense. This is where the @ character preceding the string come handy. The @ character basically tell the compiler to ignore escape character in the string that follows.
Without the preceding @ character, the above regular expression string should be written as:
"\\w+([-.]\\w+)*\\@\\w+([-.]\\w+)*\\.[A-Za-z]{2,4}$"
Hope this helps.
How to not invalidate an iterator used to iterate through an STL container while removing (or deleting) its elements.
July 25, 2008 by lxcidMany of us who use STL containers and their iterators may need to delete elements while iterating. An example case is:
Delete the game objects that are dead.
To fulfil the above case, you need to iterate through game objects, check their health and delete them if they are dead. The pseudocode would be:
FOREACH game object in game object list IF game object's health is less than or equal to zero REMOVE game object from game object list DELETE game object
Many of us will write the above pseudocode this way:
std::vector< GameObject * > gameObjectList; ///< Game object list
// Throw in some zombies.
gameObjectList.push_back( new GameObject("Zombie01") );
GameObject * zombie02 = new GameObject("Zombie02");
zombie02->kill(); // Kill the zombie02.
gameObjectList.push_back( zombie02 );
gameObjectList.push_back( new GameObject("Zombie03") );
gameObjectList.push_back( new GameObject("Zombie04") );
// Initialize the the iterator.
std::vector< GameObject * >::iterator iEnd = gameObjectList.end();
std::vector< GameObject * >::iterator i = gameObjectList.begin();
while ( i != iEnd )
{
GameObject * gameObject = * i;
if ( gameObject.isDead() )
{
gameObjectList.erase( i );
delete gameObject;
}
i++;
}
The above code seems perfectly fine but when executed you will notice that after deleting zombie02, the iterator will be invalidated and crash at i++. This is because i is a reference to the element previously storing zombie02 which is now removed. The solution is to make i set to the next iterator after zombie02 (which in this case is zombie03). STL containers erase function will return the next iterator after the one specified in its parameter. So the correct code would look like this now.
while ( i != iEnd )
{
GameObject * gameObject = * i;
if ( gameObject.isDead() )
{
i = gameObjectList.erase( i );
delete gameObject;
}
else
{
i++;
}
}
P.S. I may update this post with more solutions when I have the solution and time.
Problem and Solution: Unrecognized configuration section ‘connectionStrings’
July 24, 2008 by lxcidI first encountered this problem while trying to deploy my client’s website from Visual Studio 2005 to my Windows XP’s Internet Information Services 5.1 (a.k.a IIS 5.1) in my Windows XP SP3 powered notebook. It wasn’t a difficult one as a search on google give me tons of solutions. Trying not to make this just another solution for this problem I try to explain how to spot the problem and then provide the solution in the most detailed way.
Figure 1: The error message you will get and the clue to the solution.
Figure 1 is a typical error page thrown by IIS for not being able to parse the configuration section ‘connectionStrings’. ‘connectionStrings’ configuration section is only available on ASP.NET 2.0 and above so the first thing to look at for clue to the solution is the ASP.NET version. As you can see (indicated in Figure 1), The ASP.NET version is 1.1 which is not what we wanted. The solution is to run the website in ASP.NET 2.0 and here’s how.
Step 1: Select “Start” icon
Step 2: Select “Control Panel” icon
Step 3: Select “Administrative Tools” icon
Step 4: Select “Internet Information Services” icon
Step 5: Right-click on the website which the problem occurs
Step 6: Select “Properties”
Step 7: Select “ASP.NET” tab
Step 8: Select “2.0.x” from “ASP.NET version:” dropdown list
Random quotes.
July 11, 2008 by lxcidQuotes are my inspiration and I love them. Here are some of them.
- “We are not retreating – we are advancing in another direction.”
General Douglas Mac Arthur - “I paint objects as I think them, not as I see them”
Pablo Picasso - “Action is the foundational key to all success.”
Pablo Picasso - “All children are artists. The problem is how to remain an artist once he grows up.”
Pablo Picasso - “Bad artists copy. Good artists steal.”
Pablo Picasso - “He can who thinks he can, and he can’t who thinks he can’t. This is an inexorable, indisputable law.“
Pablo Picasso - “I am always doing that which I cannot do, in order that I may learn how to do it.“
Pablo Picasso - “Inspiration exists, but it has to find us working.”
Pablo Picasso - “My mother said to me, “If you are a soldier, you will become a general. If you are a monk, you will become the Pope.” Instead, I was a painter, and became Picasso.“
Pablo Picasso - “Imagination is more important than knowledge.”
Albert Einstein - “Weakness of attitude becomes weakness of character.”
Albert Einstein - “Anyone who has never made a mistake has never tried anything new.”
Albert Einstein - “We can’t solve problems by using the same kind of thinking we used when we created them.”
Albert Einstein - “Not everything that counts can be counted, and not everything that can be counted counts.”
(Sign hanging in Einstein’s office at Princeton) - “Art is never finished, only abandoned.”
Leonardo da Vinci - “Time stays long enough for anyone who will use it.”
Leonardo da Vinci - “It’s easier to resist at the beginning than at the end.”
Leonardo da Vinci - “I have not failed. I’ve just found 10,000 ways that won’t work.“
Thomas Alva Edison - “Appear weak when you are strong, and strong when you are weak.”
Sun Tzu - “Those who are skilled in combat do not become angered, those who are skilled at winning do not become afraid. Thus the wise win before they fight, while the ignorant fight to win.”
Kong Ming a.k.a Zhuge Liang
C#: Casting with parentheses versus casting with as
July 6, 2008 by lxcidI always seems to forgot the differences between casting with parentheses
Control c = FindControl( "TextBoxControl" );
TextBox tb = ( TextBox ) c; // Throws an exception if fails.
versus casting with as
Control c = FindControl( "TextBoxControl" );
TextBox tb = c as TextBox; // Return null if fails.
Here’s the differences:
- Casting with as can only be done on reference type.
- On event of a conversion failure, casting with parentheses will raises an exception, while casting with as will yields a null.
expression as type
is equivalent to:
expression is type ? (type)expression : (type)null
except thatexpressionis evaluated only once.
Reference:
Let my voices be read!
July 5, 2008 by lxcidI have been thinking of starting a blog for some time already and today, at my Malaysia’s home, I finally make this a reality.
There’s several reasons behind starting a blog:
- I want to be heard.
- My girlfriend have a blog.
- I want to practice my command in English.
- I want to practice writing technical paper.
- I want to post problems I faced and their solutions.
- I want a blog.
That’s all folks!








