Nhớ Em

Posted on Monday, 31 August 2009 06:09 PM

Chẳng nhớ là đã viết linh tinh từ khi nào...

NHỚ EM
Từng chiếc lá nhẹ rơi xuống chiều thu
Anh nhớ em viết bao lần cho đủ?
Để từng đêm em theo vào giấc ngủ
Mộng mơ người, che phủ những niềm đau.

Người thật xa, ta chẳng thể gần nhau
Để buồn vui ta viết nhàu trang giấy
Mỗi một ngày, niềm thương thêm đốt cháy
Hình ảnh người như lấy mảnh hồn anh.

Ngày dài quá chẳng chịu bước đi nhanh
Cho lá rơi trên cành thêm chua xót
Nhớ quá đi thôi làn môi thánh thót
Người trót mang theo, đi mãi xa rồi...

Em Đi Xa

Posted on Monday, 31 August 2009 06:07 PM

EM ĐI XA
Em đã ra đi xa thật xa
Để tình ta thêm một lần ngăn cách
Giữa dòng đời còn chìm bao đố thách
Có lúc nào tình sẽ nhạt mờ không?

Em đã đi mang theo những nhớ mong
Mang tim anh về bên em nơi đó
Anh nơi này và lòng như bỏ ngỏ
Chờ mong em đêm trăn trở anh buồn

Em đã đi cho tình mãi sầu luôn
Cho mùa đông bỗng nhiên về đây sớm
Cho nhớ thương ngày cứ càng thêm lớn
Vừa chớm yêu sao đã phải xa rồi.

Không Tên...

Posted on Monday, 31 August 2009 06:06 PM

Bài viết từ lâu rồi, some nice memories:

KHÔNG TÊN

Có một nỗi buồn nào đó vẫn cứ theo tôi
Tôi không hiểu, vẫn mãi hoài không hiểu
Một chút buồn, một chút đau, một chút lòng nặng trĩu
Những ưu phiền, những ray rứt người ơi.

Có một bức tường vẫn cứ mãi chia đôi
Tôi, và em, hai người vẫn mãi là hai nửa
Câu chuyện tình yêu muôn đời, muôn thuở
Vẫn chia lìa, hai nửa vẫn là hai..

Remove unicode accent marks

Posted on Friday, 28 August 2009 04:50 PM

I was having a little problem writing a "url friendly" for this site, since some of the blog will be in Vietnamese and I don't want to have all those special accent marks on it. (For examle, "tôi yêu tiếng nước tôi, từ khi mới ra đời, người ơi...", it should be just "toi yeu tieng nuoc toi, tu khi moi ra doi, nguoi oi" for a friendly, readily by the browser.) So this is the code to remove all the accent marks:

public static string removeAccents(string stIn)
{
	string stFormD = stIn.Normalize(NormalizationForm.FormD);
	StringBuilder sb = new StringBuilder();

	for (int ich = 0; ich < stFormD.Length; ich++)
	{
		UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(stFormD[ich]);
		if (uc != UnicodeCategory.NonSpacingMark)
		{
			sb.Append(stFormD[ich]);
		}
	}
	return (sb.ToString().Normalize(NormalizationForm.FormC));
}

But for the life of me, I can't understand why this character's accent mark can't be removed: đ and Đ. So what I did was just to do a replace at the return, so the last line should be:

return (sb.ToString().Normalize(NormalizationForm.FormC)).Replace("đ", "d").Replace("Đ", "D");

If you know a better way or a different solution, please share :) That is it for now, I will post another post on how to do friendly url on your mvc site.

Added code syntax highlighter

Posted on Thursday, 27 August 2009 06:53 PM

I was looking for a code syntax highlighter and found this great code written entirely in java script. Initially, I have some problem integrating it with TinyMCE (this website's richtext editor), but finally I've found the solution. This is working great and it will help me to better post codes on this website.

Below is an actual example of the code that I wrote for this website's blog:

using (var dc = new KennyDataContext())
{
	if (!dc.BlogExists(id))
	return RedirectToAction("Index");

	DataLoadOptions options = new DataLoadOptions();
	options.LoadWith(c => c.BlogComments);
	dc.LoadOptions = options;

	var model = new BlogViewModel
	{
		BlogDetailsModel = new BlogDetailsViewModel
		{
			BlogDetails = dc.GetBlogById(id),
			BlogTitle = dc.GetBlogTitleById(id),
			id = id,
			BlogComments = dc.GetCommentsByBlogId(id)
		}
	};

	if (dc.GetCommentCountByBlogId(id) > 0)
	{
		ViewData["Comments"] = "Comments";
	}

	string realBlogTitle = UrlEncoder.ToFriendlyUrl(UrlEncoder.removeAccents(model.BlogDetailsModel.BlogTitle));
	string currentUrlTitle = (blogTitle ?? "").Trim();

	if (realBlogTitle != currentUrlTitle)
	{
		Response.Status = "301 Moved Permanently";
		Response.StatusCode = 301;
		Response.AddHeader("Location", "/Blog/" + id + "/" + realBlogTitle);
		Response.End();
	}
	return View(model);
}

1   2   >