psychoric still trying to figure out what this blog is about

Happy new year to my family, beloved wife and friends all over the world! Love you all!
29Jan/080

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?

28Jan/080

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 :D

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

Filed under: Coder's Code No Comments
26Jan/082

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 :D

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 :D 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 :D

Filed under: Coder's Code 2 Comments
23Jan/083

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?

Filed under: Weird Sharing 3 Comments
21Jan/080

Begin Invoke..End Invoke

First post in the category :D This group is mainly to share coding stuff that is out of layman term. If you are not programmer, stay away at all cost! :P

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.

Original post

Filed under: Coder's Code No Comments
21Jan/082

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! :D

Filed under: Psycho's Note 2 Comments
19Jan/080

20080119 Today’s Photo

Dad and Mum at Rose Valley of Cameron Highland.

Retro Colors Stand out Original
_MG_5591a _MG_5591b _MG_5591-before
Filed under: More Photos No Comments
17Jan/080

20080117 Today’s Photo

Taiping lake. Merely up the contrast ridiculously to make it look like that.

_MG_5420a

Filed under: More Photos No Comments
16Jan/081

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 :D

Support by visiting this page, and let's help to keep earth the way it is!

pbpimg001.jpg

Filed under: Psycho's Note 1 Comment
15Jan/082

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.