Sunday, December 22, 2013

Mr Bone -- modified version of Hello Kitty The Singing Bone

I never like Hello Kitty but The Singing Bone changed my mind. It looks just cute and cool. Very seldom there is toy that can be cool and cute at the same time I feel lol.




















When looking at it, suddenly a thought came into my mind. What if I move the ribbon to the neck, then it will be a male version of Hello Kitty The Singing Bone. I googled and found no one modify Hello Kitty The Singing Bone yet, so I did it.

'Tadah...' (The sounds effect)




















I think the modified one looks cool too and it is named Mr Bone. No no it has no relationship with Mr Bond the James Bond ;)

Happy Winter Solstice, Merry Christmas and Happy New Year 2014 :)

Saturday, December 14, 2013

人间 ~ 天堂

一念地狱,一念天堂。愿你在天堂安好,我们在人间也安好。

C# split string using \ slash

If you are doing C# coding and need to split a string like this "ABC\0\0\0\0", you may be interested to read this post. If you have decided to continue reading, let's the code speak its all.

String a = @"ABC\0\0\0\0"; // Or "ABC\\0\\0\\0\\0"
String[] result = a.Split('\\');

We will be expecting the result array length is 5 with value result[0] ="ABC", result[1] to result[4] =  "0" and that's the result we will be getting.

Look at another case below.

String a1 = "ABC\0\0\0\0";
String[] result1 = a.Split('\\');

Are you expecting the same result ? If you are, you will be disappointed that no split has took place at all. You will get result1 array length is 1 and result1[0] = "ABC\0\0\0\0".

For a1, the \0 is treated as special character due to the single slash and no @ in front of the string. Sometimes you have no control on all source code, you may got a1 from another assembly that you have no source code access and no way to change the source code. 

If you are interested to get the value ABC and doesn't really care about what's after ABC, use below instead.
String a2 = "ABC\0\0\0\0";
String[] result2 = a.Split('\0');

You will be getting result2 with length of 5, result2[0]="ABC", result1[1] to result[4] are empty string. Yes, of course, you may provide options to Split method to remove empty entries.

Well, of course a2.Substring(0, 3) will also return you "ABC". But what if you encounter a string "ABCDVariableLength\0\0\0\0\0", then you may still want to use the split. 

Alternatively, use IndexOf('\0') which looks like this:
String a3 ="ABCDVariableLength\0\0\0\0\0";
String front = a3.Substring(0, a3.IndexOf('\0'));

Alternatively, use IndexOf("\0") or a1.Split(new String[] {"\0"}, StringSplitOptions.RemoveEmptyEntries), it works in my PC, although I thought it shouldn't.

Using IndexOf("\") will return -1 due to the same special character reason. 

Happy coding :)

Tuesday, October 1, 2013

Please, lower down your volume

If you do have karaoke set or hifi set at home, can you please lower down the volume, close all the windows and door so that your voice won't interrupt other people sleeping? This is the reason a person who used to sleep at 10.30pm still awake near to 12am. I couldn't fall asleep for more than an hour due to the 'super band' karaoke at the housing area.

If you do like to sing at night, please please please, lower down the volume and close all windows and doors, or go to Karaoke box. If you do know your friend love to sing at night, please share with them the same, to keep a peaceful residential area.

* I did call to the police station for help. The officer told me over the phone "Kalau awak tak tahu rumah mana, susahlah, saya tak bolek buat apa-apa." If I know which house, I would have go knock his house directly, I don't need you. If the band is still working after 12am, I will insist to have the police to come 'ronda'. Too bad it is not yet after 12am. Oh thank god, it started to rain heavily. Thank you my lovely sky.

Good night.

[后记:尚需努力修禅。加油]

Sunday, September 22, 2013

Wow Karaoke Box, All Seasons Place, Penang

前一阵子Wow Karaoke Box在Groupon 做促销,三小时每人RM7.50包括一杯饮料,朋友相邀一起去。我们在大约3星期前就预订了时间。这个Karaoke在 All Seasons Place3楼。啊,几个月没来,这里泊车已经收费了。周日每个进入RM 1,周末假日首二个小时RM 1,接下来每小时RM1,收费仅仅比Gurney便宜RM1,但如果住这儿附近,至少距离比去 Gurney较近,可能还是可以有市场吧。

如其他karaoke一样,我们得到的厢房也是充满烟味。在里面待了3个小时后变了烟人,什么香水都被盖掉了。至于它的点唱系统,和其他karaoke不相上下,还蛮容易用,只是点合唱歌曲比较麻烦,全部语言都参杂在一起,一共大约380多页歌曲目录,手指做了许多运动寻找华文合唱歌曲,现在手指都好像有一丁点酸麻。有些歌曲,嗯,大约是5首吧,偶尔会间断性没有声音。友人说她之前来时在另外一间房,没有这个问题。另外,厢房里的沙发不是特定的,是我们平常在家居摆设的,占去厢房蛮大的空间。我还是比较喜欢Redbox 或 Neway特定的,可以有比较多的空间放包包。另一个不太喜欢的是厢房的门,能看见空间比较大,所以别人在外面经过时可以看到厢房里边蛮大的空间,感觉上私人空间少了。也因为如此,我们看到它有一间厢房竟然摆放了一个双人秋千型吊椅,好像蛮特别,可是我不喜欢哈哈。隔音也不是太好。除此之外,也都还好。

偶尔在女歌手名单看到李心洁,想起她的一首歌曲同一个星空下。好久没有在槟城看到星空了,凭歌怀念星空一下,呵呵。

Wednesday, August 21, 2013

Error "No exports were found that match the constraint" in creating new WPF project using Visual Studio 2012

After Windows update (not really sure which updates since IT department in my workplace automated the installation process and it run silently) I was getting error when creating new WPF application project using Visual Studio 2012. The error message is as below.

No exports were found that match the constraint:
     ContractName
Microsoft.VisualStudio.Text.ITextDocumentFactoryService
     RequiredTypeIdentity
Microsoft.VisualStudio.Text.ITextDocumentFactoryService



The solution is easy. Close all instances of VS 2012, go to C:\Users\{userName}\AppData\Local\Microsoft\VisualStudio\11.0 and delete ComponentModelCache folder. Attempt to create WPF application project and it should works fine.

Happy coding.

Tuesday, August 20, 2013

Solution to "Microsoft C/C++ Optimizing Compiler has stopped working"

Out of the blue I got error below when building a Visual Studio solution.

After googled and try few suggested solutions, here's the working solution for me.

1. Clean the solution.
2. Use msbuild to rebuild the solution.

That's it. Ah, you may need an elevated VS command prompt for the msbuild command, if your solution has some build step requires more privilege, which is not related to this issue actually.