Chorn Sokun's Weblog

Conquer inner fear, push it to the limit!

Build monodevelop on ubuntu 11.10

with 11 comments

Again? yes but this time I don’t have to built mono runtine Ubuntu 11.10 packed with mono 2.10.5 which good enough since what I am after is dynamic.
However monodevelop I got from Ubuntu Software Center (USC) is 2.6 and the official release is 2.8.x so I take my on my gut to try and built me an IDE ;)

This time it much easier what I have to do is get latest copy of the source code from github.com

> git clone git://github.com/mono/monodevelop.git

Then install build dependent by issuing this command

> sudo apt-get build-dep monodevelop

I don’t know why mono-gmcs was not install as part of the previous command (if you know why please comment) for now I have to install another package

> sudo apt-get install mono-gmcs

and then I’m ready to

> ./configure
> sudo make && make run

> monodevelop

BOOM !

MonoDevelop 2.8.2
Installation UUID: b220bfc2-57c6-4b94-840e-ff6c6477632d
Runtime:
	Mono 2.10.5 (Debian 2.10.5-1) (64-bit)
	GTK 2.24.6
	GTK# (2.12.0.0)
Build information:
	Git revision: e047f99f6df7b5c801102c03f903d4dd722b2989-dirty
	Build date: 2011-11-11 15:03:47+0000

Thanks to mono packaging team, you guy rock!

Written by Chorn Sokun

November 11, 2011 at 11:12 pm

LINQ 101 .NET Reflection

leave a comment »

In this post I am going over three points listed bellow:

What is .NET Reflection? Cut short it refer to a set of API built-in .NET Framework, which give you a greate power to load and manipulate type within assembly (.dll) one of the most favor use is to support late binding. There a whole lot of explaination available through google! but that all I care for now.

How about LINQ? stand for .NET Language-Integrated Query,

 a set of general purpose standard query operators that allow traversal, filter, and projection operations to be expressed in a direct yet declarative way in any .NET-based programming language. The standard query operators allow queries to be applied to any IEnumerable<T>-based information source.

What it mean to me?
Assume that I had ITrap interface and a bunch of Trap implementation as show in the code bellow:

interface ITrap{
  void Setup();
  int OrderNr { get; };
}

class LevelOneTrap: ITrap{
  public void Setup(){
    Console.WriteLine("LevelOne Setup First");
  }
  public int OrderNr {
    get { return 1; }
  }
}

class LevelTwoTrap: ITrap{
  public void Setup(){
    Console.WriteLine("LevelTwo Setup Next");
  }
  public int OrderNr {
    get { return 2; }
  }
}

Now I want to Setup all trap by respecting it OrderNr which mean LevelOneTrap.Setup() must execute before LevelTwoTrap.Setup() so far so good? Let see how many lines of code needed:

var trapInterface = typeof(ITrap);

var trapImplementations = ( from t in trapInterface.Assembly.GetTypes()
                      where t.IsClass && t.GetInterfaces().Any(x => x == trapInterface)
                      select (ITrap)Activator.CreateInstance(t)
                  ).OrderBy(k=>k.OrderNr);

// time to play ;)
foreach( var trap in trapImplementations ) {
  trap.Setup();
}

//   LevelOne Setup First
//   LevelTwo Setup Next

Cool isn’t it? Life is short so our code!

Written by Chorn Sokun

May 7, 2011 at 12:39 pm

Posted in Programming, Tips & Tricks

Tagged with , ,

.NET developer survive on linux

leave a comment »

I’ve been joking with my friends “the open source fan boyz” that I am a Microsoft slave for the fact that I am a dedicated .NET developer. But for all the joke I found some competitive disadvantage for me moving forward. If customer is looking for a low cost solution .NET is not the way to go. Base on what I do for a living, I build desktop and web application in .NET. But I tend to focus more on Web Application which dragged me to ASP.NET MVC.

Let taking ASP.NET MVC to build solution for me it yield a great ROI for me

  1. I got to learn more about .NET library
  2. it still .NET so I can use all the skill I got
  3. got great IDE support => productivity is high so and so …

for clients :/ intranet deploy

  1. invest on the server hardware (normal)
  2. software license just take Microsoft Windows Server + SQL Server hmm

and for Internet deploy ASP.NET hosting generally more expensive than LAMP stack. If I am about to help client cutting down expenditure cost I got to get rid of the underline infrastructure need to run the application. Possible with Mono but I am keep hearing incompatible issues on ASP.NET + Mono.

Anyway let me (us) forget all about ASP.NET glorious day. Recently, I start caught up with a movement in two different communities. Both of them trying to escape from ASP.NET sandbox and they both  gave birth to two unrelated open source projects manos and Nancy that the cool part.

These two project promised to free its user from underline infrastructure (no more IIS is required!) and it work x-platform.

Up to this point I can only make manos serve page, I am keep watching and follow-up with Nancy development. I hope to be able to compare advantage and disadvantage between the two projects in the future.

“Nancy start with a full range of view template to choice from, and I do not think it hard for manos to do the same thing”.

Which one is the best? is not really important at this point, what important is when these projects are matured we can use it to build low cost solution for my clients while still enjoy writing C# “YES, it pronounced C-Sharp” :D, but how? Here the spec

  • Web Application power by [manos | Nancy] + a few open source libraries
  • Mono 2.8.x or higher
  • Server OS OpenSuse 11.13
  • Back-end database name a few open source DBMS

Why OpenSuse? it is mono home’s os, and if you want to get hot-fix on time that the way to go. So let me end this blah blah post with a teasing screenshot!

Hello World from manos running on OpenSuse 11.13 inside VirtualBox, client access from Ubuntu 10.10 if you care about the environment :D

There you go it’s how a .NET developer survive on linux nice hacking weekend everyone!

Written by Chorn Sokun

January 22, 2011 at 10:36 pm

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 ,