Archive for the ‘OSS’ Category
Yii overwrite accessRules in base class
Suppose you defined a base class Controller with basic accessRules
class Controller extends CController
{
public function filters()
{
return array(
'accessControl',
'postOnly + delete',
);
}
public function accessRules() {
return array(
// allow authenticated user to perform 'create' and 'update' actions
array('allow', 'actions'=>; array('index', 'view'), 'users' => '@'),
// deny all users
array('deny', 'users'=>'*'),
);
}
}
and you want to add (overwrite) rules in derived class, using array_merge here how you do it:
class Site extends Controller
{
public function accessRules()
{
return array_merge(
// allow all user to perform 'help' actions
array( array('allow', 'actions'=> array('help'), 'users' => '*') ),
// parent go last
parent::accessRules()
);
}
}
As best practice your base class default access rule is deny all by default.
Build monodevelop on ubuntu 11.10
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!
.NET developer survive on linux
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
- I got to learn more about .NET library
- it still .NET so I can use all the skill I got
- got great IDE support => productivity is high so and so …
for clients :/ intranet deploy
- invest on the server hardware (normal)
- 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!
How to changing default Khmer Unicode Font in Ubuntu
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.
Ubuntu (NHibernate Mono MySQL) Take 2
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:
And of cause I do make the sample code & assembly accessible at http://www.joljet.net/nhibernate3-confORM-mono.tar.gz .
Build mono on Ubuntu Karmic 9.10 x64
As always I would start off with CRY ME A RIVER :L, lol I told myself that I will never ever build mono from release source or /trunk again. I am lying myself :( ok here I go again this time I load Ubuntu Karmic x64 on my Toshiba M100 ~2 years old the original purpose is to just load it with multimedia app so that my wife could enjoy watching DVD, play MP3, browse the Inernet and blah blah blah … all just for entertainment :) It turn out !
Ok, here is the main story it turn out that I caught an e-mail from mono mailing list Mono 2.6 for Ubuntu its haunting me. Why don’t I just spend sometime with that instead of wasting time playing JX2 :D yeah let try.
- Download Mono 2.6.1 stable source
- Read instruction Parallel Mono Environment; ** people keep telling me to reference this instruction although I did follow the exact step, perhaps someone better shot a webcast instead of writing unworkable instruction.
Build Source
First thing first extract the source code from .tar.bz2 since I not a command savvy *yet* I use nautilus context menu to extract the source file; when all source code extracted let get into command line:
// create mono-dev-env using script written in http://www.mono-project.com/Parallel_Mono_Environments > ./mono-dev-env // your command prompt now shall look like this where ~src is the location that I stored source code [mono] ~src @
libgdiplus-2.6
// just in case execute [mono] ~src @ sudo apt-get build-dep libgdiplus // ... now you are ready to build libgdiplus-2.6 [mono] ~src @ cd libgdiplus-2.6 [mono] ~src/libgdiplus-2.6 @ ./configure --prefix=/opt/mono [mono] ~src/libgdiplus-2.6 @ make; sudo make install
mono-2.6.1
[mono] ~src @ cd mono-2.6.1 [mono] ~src/mono-2.6.1 @ ./configure --prefix=/opt/mono [mono] ~src/mono-2.6.1 @ make; sudo make install
gtk-sharp-2.12.9
Here come the pain :D as gtk-sharp depend on a lot of library we need to make sure those library are installed first before compile gtk-sharp-2.12.9 as of Ubuntu Karmic I need to install the following packages:
> sudo apt-get intall libpango1.0-dev libatk1.0-dev libgtk2.0-dev // after that I can just do [mono] ~src/gtk-sharp-2.12.9 @ ./configure --prefix=/opt/mono [mono] ~src/gtk-sharp-2.12.9 @ make; sudo make install
gnome-sharp-2.24.1
// dependency library just in case > sudo apt-get install libgnomecanvas2-dev libgnome2-dev // resume build task [mono] ~/src/gnome-sharp-2.24.1 @ ./configure --prefix=/opt/mono [mono] ~/src/gnome-sharp-2.24.1 @ make; sudo make install
gnome-desktop-sharp-2.24.0
[mono] ~/src/gnome-desktop-sharp-2.24.0 @ ./configure --prefix=/opt/mono [mono] ~/src/gnome-desktop-sharp-2.24.0 @ make; sudo make install
The rest of the library seem to go just fine, I learn that execute sudo ./configure cause me a lot of troubles thanks @alex for pointing this out.
mono-tools-2.6.1
description on what this library give coming up next …
mono-addins-0.4
description on what this library give coming up next …
mono-debugger-2.6
As I reached to this point ./configure started to complain me like this > configure: error: Cannot find termcap library to solve the problem I need to install
// ref: http://ubuntuforums.org/showpost.php?p=2929293&postcount=3 $ sudo apt-get install libncurses5-dev
Side Note
Petit Eric <surfzoid[at]gmail[dot]com> wrote:
For those who want 2.6.1 deb, there is OBS repository for i586 http://bit.ly/MonoDebOBS, the X86_64 are available here http://surfzoid.free.fr/Mono/ubuntu9.10/ or http://dl.free.fr/c1roVOfLL
in sources directory you will find libgdiplus sources and all files need to build deb from them (.dsc, …) here http://dl.free.fr/iHFHXaIuj you will find mono2.6 idem
NHibernate + Mono + MySQL Fly by
I thought about it and I want to see it works for me and there it goes ;)
- Ubuntu Karmic
- Mono 2.4.3
- NHibernate (trunk)
- MySql connector-net (trunk)

rebuild the stack for new home ;)
Sweet :) next rediscover Castle stack on Mono that should be fun let see how much I stress MonoDevelop 2.2
Gdo, Gazetteer Database Online
There are 3/4 variants of the Cambodia Gazetteer after UNTAC created the list; now it time to put this mess to rest one and for all.
Ministry of Interior, Department of Local Administration currently setup a task force to reconsolidates the master list and make it an only office Gazetteer.
Now my colleague expected to write up a forward document about this project; which I’m not going to discuss here.
What you should know in the near future there is only one set of Cambodia Gazetteer and you can access it online absolutely free, so stay tune …
And you don’t have to guess how I built or when it goes live since I had 3 projects developed & maintenance in parallel no doubt I no longer had time to enjoy playing JXII :(
Feature Highlight:
- Online browsing Province, District, Commune, Village meta data
- Province, District, Commune Map (produced by external consultant)
- Download Gazetteer data in Excel format for offline use.
I love this job ;)
PHP date diff
I call out for an excuse for not practicing PHP enough recent year; with just a simple date_diff could knock me out :) not to open my complain of having different version of PHP to check before using a function(s) I got a request from a friend to help workout how many days from two given date.
Now if I have two date string (it is what we get from form post right?)
// fixed format as I don't want to deal with complicate of different world format :(
$day1 = "26/03/2009";
$day2 = "28/03/2009";
// now I need to know how many days does it take from day1 to day2
// PHP 4.x; ignore my out of date PHP skill this is how I did it
$break_day1_apart = explode('/', $day1);
$break_day2_apart = explode('/', $day2);
$day1_number_form = $break_day1_apart[2].$break_day1_apart[1].$break_day1_apart[0];
$day2_number_form = $break_day2_apart[2].$break_day2_apart[1].$break_day2_apart[0];
$day_diff = abs((int)$day2_number_form - (int)$day1_number_form);
// and it should work by theory
echo $day_diff;
Suck ! what would you do instead?


