Chorn Sokun's Weblog

Conquer inner fear, push it to the limit!

How to changing default Khmer Unicode Font in Ubuntu

with 2 comments

In Ubuntu 10.10 release cycle ttf-khmeros version 5.0.3 was included. However the only problem I had with Chrome.  Later on I was told that the fix is by trying various font until we find the one that work properly.

So the idea is to change default Khmer Unicode font so let see how we do it:

sudo gedit /etc/fonts/conf.d/65-khmer.conf

you can replace <family>Khmer OS</family> with <family>Khmer_Unicode_Font_Of_Your_Choice</family> or if you do not want to touch the line you can just add another line on top like this:

<family>Khmer_Unicode_Font_Of_Your_Choice</family>
<family>Khmer OS</family>

next step issue the following command to update font package:

sudo dpkg-reconfigure ttf-khmeros

logout and log back in again.

Thanks @rithy for sharing this technique.

Written by Chorn Sokun

December 10, 2010 at 8:27 am

Posted in OSS, Tips & Tricks, Ubuntu

.NET Database Application Development (C#)

leave a comment »

If you are interested in .NET and want to jump start with Database Application Development in no time here is your chance

Lady & Gentlemen, boy & girl I present you a .NET Database Application Development (C#) fast track with the following content:

  1. C# Programming Introduction
  2. Introduction to NHibernate .NET Object Relational Mapping (ORM)
  3. Advance Data Processing with NHibernate Criteria API
  4. Hand-on practice

At the end of the course your will learn tools & technique to develop database application which could talk various Database Management System (DBMS) from Microsoft Access, Microsoft SQL Server, MySQL you name it.

Now the truth about doing this in no time :D I lie :-P I need minimum 10 hours before I can transform a newbie into a .NET Database Application Development (C#)

Requirement:

  • Basic Programming Concept
  • Know basic C# Programming
  • Be able to read and understand this blog post – otherwise get yourself English tutor

If you, your friend interested or your employer got budget to develop your capacity drop me a line I would love to hear about it ;)

Written by Chorn Sokun

December 5, 2010 at 4:36 pm

Deploy MonoRail on IIS7

with 3 comments

Note to myself

1. On Default Web Site, click Add Application

2. Change Application Pools = Classic .NET AppPool , go to Application Pools and click on Classic .NET AppPool then take Advanced Settings

Calssic .NET Application Pools, Advanced Settings

3. Add the following setting to web.config

	<system.webServer>
		<handlers>
		  <clear />
		  <add name="PageHandlerFactory-ISAPI-2.0-64" path="*.aspx" verb="GET,HEAD,POST,DEBUG" type="" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" allowPathInfo="false" preCondition="classicMode,runtimeVersionv2.0,bitness64" responseBufferLimit="0" />
		  <add name="PageHandlerFactory-ISAPI-2.0" path="*.aspx" verb="GET,HEAD,POST,DEBUG" type="" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" allowPathInfo="false" preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="0" />
		  <add name="MonoRail64" path="*.castle" verb="*" type="" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" allowPathInfo="false" preCondition="classicMode,runtimeVersionv2.0,bitness64" responseBufferLimit="4194304" />
		  <add name="MonoRail" path="*.castle" verb="*" type="" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" allowPathInfo="false" preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="4194304" />
		  <!--
		  <add name="UrlRewriting64" path="*" verb="*" type="" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" allowPathInfo="false" preCondition="classicMode,runtimeVersionv2.0,bitness64" responseBufferLimit="4194304" />
		  <add name="UrlRewriting" path="*" verb="*" type="" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" allowPathInfo="false" preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="4194304" />
		  -->
		  <add name="StaticFile" path="*" verb="*" type="" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" scriptProcessor="" resourceType="Either" requireAccess="Read" allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
		</handlers>
	</system.webServer>

We good to go, hope I don’t waste my time again on this thing.

Written by Chorn Sokun

November 4, 2010 at 4:10 pm

Ubuntu (NHibernate Mono MySQL) Take 2

with one comment

In my previous post I am talking about the setting mono, Nhibernate and MySQL stack on Ubuntu, it was a fun experience. However I made a mistake since I didn’t intend seriously use mono at the time I just wipe the whole os off my laptop and boom all the sample code and assembly gone too. But guess what this time I did it again with the combination of

  • Nhibernate 3 (beta build from trunk)
  • ConfORM (just so I don’t have to worry about .hbm.xml files)
  • MySQL driver install via Synaptic Package Manager (cuz I’m a bit lazy this time)

Now see what I got:

SchemaExport in Action ;)

And of cause I do make the sample code & assembly accessible at http://www.joljet.net/nhibernate3-confORM-mono.tar.gz .

Written by Chorn Sokun

October 19, 2010 at 9:43 pm

Posted in Mono 2.6, NHibernate, OSS, Ubuntu

Tagged with ,

Relative local file path to Uri

leave a comment »

It just another weekend in my life time; let write a few line of code for fun.

// Do you know you can easily conver file with relative path to an Uri object?
// of cause you do :D
var fileInfo = new FileInfo(@"..\Files\TGIS.xls");
var uri = new Uri(fileInfo.Fullname);

Hope you enjoy your weekend :D

Written by Chorn Sokun

September 11, 2010 at 10:27 am

Posted in Tips & Tricks

Khmer Collation support in SQL Server 2008

leave a comment »

SQL Server ’08 using default collation as “SQL_Latin1_General_CP1_CI_AS” which most/all of us knew that

  • We can store Khmer Unicode (with NVARCHAR, NText etc)
  • Searching Khmer Unicode ? suck !

There are work around if you really want to search content in Khmer Unicode after you stored it; using SQL Server ’08 default collation. How?

Method #1: Try to break each word using hidden space

Method #2: Encoding incoming Khmer Unicode content and stored it as ASCI

It works but it hurt; there is an althernative SQL Server ’08 introduce a few additional collation algorithm among those “Khmer_100” is one of them.

Khmer Collation in SQL Server 2008

That awesome all you have to do is changing your column collation from <default collation> to “Windows Collation -> Khmer_100” that’s it no code isn’t that cool ?

No it’s not cool, It only works if SQL Server install on Windows Vista or Higher.

Edit: actually we can also use this

Written by Chorn Sokun

July 28, 2010 at 10:48 am

Mocking ASP.NET MVC 2 Context & Session using RhinoMock

leave a comment »

Watching video record from #mvcconf about “Making ASP.NET Apps Testable” by Eric B. Sowell. He showing how to test ASP.NET MVC Session make me wonder how difficult it is for RhinoMock so I load sample app and here how I test it. Since

[Test]
public void TestSession()
{
   // Arrange
   // HttpContextBase, HttpSessionStateBase are abstract classes
   // I can ask RhinoMock to generate stubs for those classes
   var httpContext = MockRepository.GenerateStub<HttpContextBase>();
   var session = MockRepository.GenerateStub<HttpSessionStateBase>();

   session["Name"] = "Sokun";
   httpContext.Stub(c => c.Session)
      .Return(session);

   // act
   controller.ControllerContext = new ControllerContext(httpContext, new RouteData(), controller);
   var result = controller.TestSession() as ViewResult;

   // assert
   Assert.IsNotNull(result);
}

and the action:

public ActionResult TestSession()
{
   ViewData["Name"] = Session["Name"];
   return View();
}

So, what you think? it just fine to love ASP.NET MVC 2

Written by Chorn Sokun

July 26, 2010 at 10:45 am

Me & the Onion Architecture

leave a comment »

Jump into ASP.NET MVC 2 in Action Chapter 23 which talk about an integration of ASP.NET MVC and NHibernate the author introduce us to the Onion Architecture.

Using this architecture we simply structure our solution like:

  • Core, storing POCO & various Interfaces
  • Infrastructure, talking with underline or external system
  • IntegrationTests, generally speaking this would test Infrastructure functionality
  • UI

Let focus on the Infrastructure because it is the main actor in this architecture; the following role given to this layer

  • Mapping between Core class & Database by talking through NHibernate (I agree)
  • Responsible for injecting NHibernate session into web session with NHibernateModule: IHttpModule (I agree)
  • Contain abstract RepositoryBase<T>: IRepository<T> (I agree)
  • Contain all Interfaces  implmentation hmm ? isn’t it too much for an Infrastructure? what about
    • Core
    • Infrastructure
    • Services
    • IntegrationTests
    • UI

I will do more investigation (Pros, Cons) but love to hear your take on this, if you haven’t read the chapter yet do it now.

Written by Chorn Sokun

July 25, 2010 at 2:35 pm

Posted in Uncategorized

Tagged with ,

What is it about WP that makes it so hacker friendly?

leave a comment »

@shanselman twitted an interesting message with an interesting response.

What to remember “With great power come great responsibilities”, if you want to be hot remember this defense in depth

Written by Chorn Sokun

June 29, 2010 at 11:42 am

Posted in Geek, Rumor

I lost the title

with 2 comments

Recently, I start listen to old Khmer song then I like this song but damn I don’t remember what the title of this song, and as you know title of oldies song is tricky to guess. So I needed your help do you know what’s the title of the song?

Written by Chorn Sokun

January 17, 2010 at 4:49 pm

Posted in Entertainment

Tagged with