= fn(n){n xor 0xFFFF004B eq 0×0 ? n : fn(n – 0×1)}

Archive for the ‘Principle’ Category

Koumei New Domain!

Saturday, July 31st, 2010

Koumei got a new personal domain: koumei.co which is the same as koumei.net though. :)

Gonna make a page: koumei.co/ol :) cool !



An Experimental Html5 Drama

Sunday, July 25th, 2010

After reading through all useful articles about Html5 and CSS3, I try to create a new Html5 template for my blog. If you would like to see something new about html5 and css3, have a look at this article:
70 Must-Have CSS3 and HTML5 Tutorials and Resources

Koumei’s experimental page is available here: http://koumei.net/html5.html

Nothing much currently. I am quite interested in creating the gradient background and rounded corner.

This page will be kept updating.



Say Hello to koumei.net on HelloVPS

Friday, July 23rd, 2010

Yesterday koumei.net was condemned due to bring down the whole hosting server for harmful scripts, according to the server support. Not easy to contact them since they are in states. I am desperate to stay on their server without any secure. I would rather move to another server than to explain I am innocent. So I will move out from their server, I don’t like their service as well. How come they close down my website so suddenly without 1 day or 2 days notice?

Thanks to Howie from states who provides me a shelter at this moment. koumei.net is homeless, desperate and depressed last night, but because of his kindly help that make me home again. Now let us say hello to koumei.net again on HelloVPS (HelloVPS.com).

hellovps

hellovps



MVC2 Bug on Data Binding in Listbox?

Wednesday, June 23rd, 2010

Seems MVC and MVC 2 don’t realize that there is an issue when binding the data on the view:

Given an extension on HtmlHelper: this extension will generate a list box in view based on the collection “cakes”. (Because I like cake, so I use dessert object as example :)

public static MvcHtmlString MyDropDownList(this HtmlHelper target, string controlName, IQueryable<Cake> cakes, object htmlAttr)
{
if (cakes== null)
return MvcHtmlString.Empty;
var cakesList = new SelectList(cakes, “Id”, “CakesName”);
return target.ListBox(controlName, cakesList, htmlAttr);
}

It is okay, but the main issue is if the when I specify the Model data on control name, it IS SUPPOSED to generate the list box with the data which retrieved from database are selected. Yes.  IT IS SUPPOSED TO BE. But, unfortunately, MVC fail to automatically bind data for us…  The data “cakesList” is showing properly, but with no preselect options. In most of the business logic, it’s not gonna work, because it is no point for user to re-select the options every time before save the data.

In this case, MVC is not gonna auto-bind the data for us, we just need to figure out another way to display and manipulate the data properly. So we will change something on the extension, view and the controller:

1. On the view, don’t specify the name to model’s name, For example, the data which will be weaved to list box is CakeViewData.CakeList, the data related to database is CakeViewData.Dessert.Cakes. Normally, we will use the extension to weave the data:

<%=Html.MyDropDownList(“Dessert.Cakes”, Model.CakeList, new { @class = “multiselect”, size = 5 })%>

Since MVC is not gonna take care of the data binding, The name (on parameter controlName) should and NEED to use other name instead. Change “Cakes” to any other name, for example, change to “MyCakes”:

<%=Html.MyDropDownList(“Dessert.MyCakes”, Model.CakeList, new { @class = “multiselect”, size = 5 })%>

2. Extension is changed to:

public static MvcHtmlString MyListBoxWithSelectedList(this HtmlHelper target, string name, IQueryable<Cake> cakes, List<string> selected, object htmlAttr)
{
if (interests == null)
return MvcHtmlString.Empty;
var cakeList = new MultiSelectList(cakes, “Id”, “CakeName”, selected);
return target.ListBox(name, cakeList, htmlAttr);
}

I just add a parameter “List<string> selected” in the extension which will be used in MultiSelectList object that can be bind to the the items to be selected.

3. In controller, before saving the data, need to use FormCollection or Request["Dessert.MyCakes"] to obtain the data “MyCakes” manually.

string myCakes = Request["Dessert.MyCakes"];
Dessert dessert = new Dessert{Cake = myCakes};

It might not be a bug actually. And in this example you can feel how flexibility that MVC can bring you: the way to manipulate the model or data varies!  :)

Happy programming in MVC 2!



Hailstorm Late Updates

Thursday, March 11th, 2010

All photos are copy-right by David Jones.



There Is Nothing Meant To Be :)

Tuesday, February 9th, 2010

Do you have an experience that life just feels like a movie show? I bet many people do. Someone comes in your life, someone leaves. I think there would be 1000 of people walk beside you everyday who just passing by. You never know their names. By any chance, you meet someone who is passing by, and catch the name. Soon you guys develop relationship. Do you believe that is the fate?

500 Days of Summer is such a good movie, that let people think something seems meant to be, a decision, a response could easily make things different. But who knows? If everything is meant to be, why should we spending time to explore our life? In the story, Tom believe that the girl,whose name is Summer, is the one of his life, he spends his time with her, hanging out together, they seem like couple, lover. Summer gets merry, but her husband is not Tom. At the end of story, the movie mentions that Tom finally figure out that there is nothing meant to be, and he meets a girl who is a competitor of his new job.  Will Tom fall into another 500 days again? I hope not.

Good story , good movie and it is a real, or much closer to real life. I strongly recommend it.



Home Made Kim Ba (Sushi)

Friday, January 8th, 2010

Yummy!



UP – the adventure of a lifetime

Monday, January 4th, 2010

All his life is dreaming of adventure, finally, he is taking off!

It is a moving story at the very beginning when he is living with his wife before the exploration. It’s pity that he can’t take his wife who encourage him to take the adventure :(

What’s the story of the movie? Well, I think pixar is gonna tell us, an adventure could be a lifetime, as long as you still dream of it. But it would become a true story when stop dreaming, just take off today!



Live Cast! David’s Wedding Party (China, GMT+8 20:30)

Thursday, December 31st, 2009

First of all, Happy new year~

Yummy foods and happy David’s big day!

1

4

5

6

(last updated: 31 Dec 09  21:01 GMT+8)

7

(last update: 21:07 GMT+8)

8

You guys are perfectly natural!

(last update: 21:10 GMT+8)

9

(last update: 21:19 GMT+8)



Aquavista Building in Dockland – Photo by Mr Jones

Sunday, December 13th, 2009
Aquavista in Dockland

Aquavista in Dockland

City circle is from central city, its free. But sometimes it is crowded. :)

The photo is taken and owned by Mr Jones who is an enthusiast in photography. I “steal” some from his repository. *.*



Profile

  • Koumei Deng's Facebook profile


Submit Your Site To The Web's Top 50 Search Engines for Free!