Chorn Sokun's Weblog

Conquer inner fear, push it to the limit!

Archive for July 2009

jQuery.selectboxes removeOption()

leave a comment »

Base on the doc page located here http://www.texotela.co.uk/code/jquery/select/ if I wanted to remove (clear) items from a select box all I need to do is call:

$('#select_box').removeOption(/./);

But in my case I had a select box like this:

<select name="select_box" id="select_box">
    <option value="">N/A</option>
    <option value="1">Low</option>
    <option value="2">Meduim</option>
    <option value="3">High</option>
</select>

and of cause the syntax specified above doesn’t do the trick; this is how I fix it:

$('#select_box').removeOption(/(.?)/);

Was that how it should be done? oh ! by the way the shorter way

$('#select_box').empty();

Written by Chorn Sokun

July 28, 2009 at 3:58 pm

Posted in Tips & Tricks

Tagged with

Weekend => app.goLive ;)

with one comment

Early this month I got into a busy schedule in order to release my new database application. I needed to run & check a final test, wrote up manual and do some paper work to invite my colleague across the country (2 staffs from each province X 24) to attend a 3 days training workshop in total we get approximately 48 staffs which is too much for an IT training so we split it into 2 batches 12 provinces each.

In term of the actual database I allocated 2 days and for the first day of the training I leave it for general IT update lesson which include Khmer Unicode orientation half morning, and for that session alone I am very lucky to have Mr. CHEA Sok HuorCountry Project Leader from PAN and his colleague came in for help. Without them I wouldn’t know where to get such precise Khmer Unicode Orientation somewhere else, so thank you from the deepest of my heart.

Oh! Talking about helping there is another gentle who I owe him as well, that gentle is Mr. Tuy Pheap my long colleague. We share room in the last 3 years before he moved on to his current job and come back to seat behind my back :) “Again :D”.  I disturb him from time to time :D policing what my system do against his employer needs (the World Bank) not only that he also help me correct my Khmer Translation + Spelling :) and this phrase “ខ្ញុំយល់ហើយ!!!” for a button which in English say “I Understand” was his innovation :) let me tell you about this joke

In our new application if there are any problems or errors detected a list of detail explanation will show up ( jQuery modal )  what I originally did was to have user click on “Ok” button to close the message. But without anything special user might just click “Ok” and go on … that not fun. So we came up with an idea instead of naming the button “Ok” we called it “I Understand” :))

And as a side effect during the training we forget to translate a few messages so default message showed. Since the user  do not read English and he dare not click on the button to close the message :(

I am glad with the result as it turn out and thanks to all the backend libraries that I used without them I wouldn’t know how much I would need to damage my brain cells to get this job done :)

What I used?

  • NHibernate
  • Castle (MonoRail, ActiveRecord)
  • Rhino-Tool (Rhino.Security, Rhino.Common)
  • Oh ! ASP.NET for sure :) but I a brail devil don’t blame me for not using webform
  • Log4net
  • jQuery & it plug-in(s)

Challenges:

  • For the past 5 years most of them get use to do data entry in desktop mode (VB6)
  • Some of them using the Internet for the first time; right this is (1==1).
  • The amount of data that we collect had increase 1.5X
  • More restriction in term of data modification – they used to have full control over there data and that cause me alot of headache over the past years.

At the end of training session I got a request to setup a demo URL (http://db.ncdd.gov.kh/pid-train) so that when participant get back to their duty province they can teach their colleague, by doing this I get a few additional feedback on how to improve the process of data entry as well as knowing how user interact with the application.

For sure: “No one is perfect” and “No software ever release bug free” as long as it could do it main job properly I would call it V1.

Now the weekend is coming I had to switch on actual URL and for that mean I had to copy a folder change connection string to get another URL up and running KOOL stuff ;)

Written by Chorn Sokun

July 24, 2009 at 3:59 pm

Posted in Community, Development, Geek

Tagged with

PHP date diff

with 2 comments

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?

Written by Chorn Sokun

July 4, 2009 at 11:37 am