I Learned and Applied RegularExpression Today
Scenario: I have a number of patterns that I need to check and replace in a string. I don't want to transverse the string and play with characters and length. What other option I have?
I want the library FAST!
My MSDN 2008 Library didn't install a direct link to launch help like the 2005 version. So i tweaked the 2005 shortcut and hoila, i have the shortcut for 2008 version. You like the F1, but i prefer this so i can easily answer people's query without opening the IDE
Create a new Shortcut and put this in the shortcut path (single line):
"%YOUR PROGRAM FILES%\Common Files\Microsoft Shared\Help 9\dexplore.exe"
/helpcol ms-help://MS.MSDNQTR.v90.en /LaunchNamedUrlTopic DefaultPage
coalescing null yield return
Ok the title means nothing at all, and they are not related too, except that they both are of C# family. As requested by Klaw, i am going to blog about it so that we all learn
Coalescing Null Operator
You are probably thinking what's that. Maybe it is just me, but it is one of the cool subtle features in C# that I just discovered today. Shame on me ya. Basically you all are familiar with this:
string myStrVarB = (myStrVarA == null) ? "null string" : myStrVarA
So with coalescing null operator (??), you can shortened it to:
string myStrVarB = myStrVarA ?? "null string"
Let's see, that is saving of 17 characters. Your boss sure will praise you for that
On a side note, in case you don't know, you can allow a scalar type to be null by using the nullable operator:
int? myInteger = null
yield return
Definition from MSDN: "Used in an iterator block to provide a value to the enumerator object or to signal the end of iteration". I assume you have previous knowledge with IEnumerable (or iterator), so i am not going into detail with it. The yield statement appears only inside an iterator block and returns the value that is expected by the calling foreach statement. Cut the theory and show me the example.
public static IEnumerable Power(int number, int exponent)
{
int counter = 0;
int result = 1;
while (counter++ < exponent)
{
result = result * number;
yield return result;
}
}
static void Main()
{
// Display powers of 2 up to the exponent 8:
foreach (int i in Power(2, 8))
{
Console.Write("{0} ", i);
}
}
There you go, another simple bit of my learning
Sharlinie and Black Magic
Read about this super interesting post here. My first reaction upon reading just the first paragraph: WTF. Why so much publicity on hiring bomoh to find the poor gal? And worst, 50 of them?! You can say i am heartless as they were trying all their mights, but this is really getting overboard. You know what, i seriously suspect there is consipracy behind this. Some political parties could have paid for this at the back. Why? Election is near mah. Why there isn't such big thing for Nurin before? Why now?
The bomohs predicted that she will return in 1 week. I really like to see theirs and public reaction if it doesn't come true. If they are so good, why cant they determine the exact location?! When the power combine, they are Captain Bomoh mah. They could even say there are 3 kidnappers whom used black magic to trap her. WTF again?! Black magic and kidnap? So what now, we should all learn some of the arts so we can fight back when necessary. And from this statement, shouldn't the police be searching all bomohs in Malaysia (since they know black magic)?
Not that i am pessimistic about Sharlinie safety but not this method alright. Even if you do, keep it low. Headline man, what is the paper thinking? Is Malaysia really that boring till we need to use such news for headline?
Begin Invoke..End Invoke
First post in the category
This group is mainly to share coding stuff that is out of layman term. If you are not programmer, stay away at all cost!
Found this very easy to read yet informative post on Asynchronous Method Invocation. I admit that what i know about .NET is merely the tiny tip of what the iceberg can offer. Oh hell, life is long and learning is life long, ain't it?
Here's a summary of what i learnt:
- MethodInvoke - built in delegate in .NET that allow you to call a method that takes in no parameter
- BeginInvoke - execute the target function and return to caller instantly
- ThreadPool in .NET has a limit of 25. Avoid 'starving' the pool else be fined by performance loss
- EndInvoke - return proper values/parameters from the previous function call
- IAsyncResult - log of all datas (exceptions, return value, output parameters, etc) after execution is completed
- AsyncCallBack - used when you don't wish to wait for completion of the execution (that's the purpose of asynchronous call bah)
- Command Pattern (ICommand interface) - rather than BeginInvoke, EndInvoke, CallBack everywhere in your Main(), apply this pattern to group calls together.
That's all folks. I might not have explained everything properly, so best for you to read it yourself.
I am on Facebook
You would be saying, "What? You are so out man! We've been fooling around in there for ages". Alright alright, i know i am slow. The main reason that i registered for it was to view photos from my ex-colleagues. Only after i logged in, i found tonnes of my friends in there (who weren't active in such portal before).
Frankly, i don't like Facebook much, except that it is responsive and hell lots of friends are in there. They have too much of those 'applications' which complicate the whole thing. Whenever i browse profiles, i am only interested in the top section, where the biodata and photos links are. I still prefer Friendster style where things are kept to simplest form. Oh maybe i am not into 'socializing through the web' now, so i don't see the usefulness of those goodies.
Anyway, if you want to, you can find me in there with email digital.ric@gmail.com. Happy Facebook-ing!
20080119 Today’s Photo
Dad and Mum at Rose Valley of Cameron Highland.
| Retro Colors | Stand out | Original |
20080117 Today’s Photo
Taiping lake. Merely up the contrast ridiculously to make it look like that.
Do our bit!
Inspired by Blacksnail on her effort to start reducing waste (http://blacksnail.wordpress.com/2008/01/14/save-the-world-chapter-1-reduce/), i started a page to keep track of how am i doing in the same. If each of us can do the little bit (which doesn't even need 0.01% of your daily effort), the world will be a better place to live in. Well, that's if keeping politics and war aside
Support by visiting this page, and let's help to keep earth the way it is!

Kungfu Dunk – Expected Dung
If you don't know what dung means, it basically means sh-it. When i first heard of the name, the reaction was WTF. When i first saw the trailer, i almost puked. When i first saw the advertisement, i had nothing more to say. Come on, you wanna ride on the wave of Shaolin Soccer? I doubt it can, 1001%. If the movie is about the original Slam Dunk, then at least i will have the tendency to watch.