November’s Cloud
Posted by mkhairul - November 27, 2008 at 08:11:46 am - No CommentsCategories: blog
I missed the deadline for this month’s cloud. I was too deep inside some code for a new application, the Master Plan, that I forgot all about the cloud.

Making jQuery selector/contains case insensitive
Posted by mkhairul - November 26, 2008 at 03:11:49 pm - No CommentsCategories: Troubleshoot, blog, code
Just another stuff from work. There’s huge list to select people to be put into groups in the LMS. I added a javascript function for the user to type in a name and it will search and select a user in the list box.
I use Selector/contains for this but the problem is, it is case sensitive. That’s gonna be a problem to type in the exact case from the list. Here’s a snippet to extend the selector.
jQuery.extend(
jQuery.expr[':'], {
contains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0"
});
Took the snippet from StackOverflow, but it has a typo.
CodeIgniter 1.7 DBForge Error (Array to string conversion error)
Posted by mkhairul - November 20, 2008 at 11:11:13 am - No CommentsCategories: Troubleshoot, blog, code, php
I think the ellislab team is swamped with bug reports and stuffs. But I’m sure the next release will solve this problem.
I found this solution at the forum, CI 1.7 Forge Problems. Basically what you need to do is find DB_driver.php inside the database folder. Go to function _protect_identifiers (most probably on line 1193).
Add in this code (inside the function).
if (is_array($item))
{
$array = array();
foreach($item as $one)
{
$array[] = $this->_protect_identifiers($one, $prefix_single, $protect_identifiers, $field_exists);
}
return $array;
}
Alright, that should fix it up.
Master Plan
Posted by mkhairul - November 19, 2008 at 02:11:13 pm - No CommentsCategories: blog
There is a new assignment. I am being assigned to create a system for the Master Plan! Woah! Sounds like a notorious scheme by the Masters of Evil. But alas it is not.
It is a collection of forms that creates a timeline for specific types of stuffs. Its a form generator something like Wufoo. But with specific custom needs, like a DataTable. I went through all the examples and some other examples from other developers but none to my liking.
There’s a datagrid plugin called Flexigrid for jQuery but then again, there’s all this hurdles that I have to go through to make it perform certain stuffs and I don’t like to constraint myself inside that type of UI.
After browsing through Smashing Magazine’s Pricing Table Examples and Best Practices. I’ve decided to use jEditable to accomodate a normal table with the function that I need by just putting in an inline editable feature to it.
The deadline is in 10 days. The system must be functional on 1st December. Let the death march begins!
Adding confirm dialogue box for delete links with jQuery
Posted by mkhairul - November 15, 2008 at 01:11:33 am - No CommentsCategories: Tips, blog, code
I use this all the time. Its simple, clean and gracefully degrades. Even though its simple some people might miss it. So I post it here.
$('.delete').click(function(){
if(!confirm('Are you sure you want to delete?'))
{
return false;
}
})
By returning false you stop any action from the link (redirecting you to the url)
You can see the demo here.
Form Snippets for CodeIgniter in Komodo Edit
Posted by mkhairul - November 13, 2008 at 12:11:03 pm - 1 CommentCategories: blog
Here’s a code snippet(in CodeIgniter) for creating a submit function inside a controller. I use this all the time.
$rules[''] = '';
$fields[''] = '';
$this->load->library('validation');
$this->validation->set_rules($rules);
$this->validation->set_fields($fields);
if($this->validation->run() === FALSE)
{
$this->
}
else
{
$timestamp = strtotime('now');
$data = array(
'' => ''
);
$this->load->model('', '');
$this->session->set_flashdata('misc_success', '');
redirect();
}
I intentionally left some stuffs inside there, which is supposed to be filled anyway.
This is usable but it can be better. I’ll try to elaborate in the next post, or the post after the next. As soon as I finish up an example.
Debugging an SQL Query
Posted by mkhairul - November 12, 2008 at 11:11:26 pm - No CommentsCategories: Tips, Troubleshoot, blog, code
So, I debugged an error for a good friend recently. Only certain kind of item would be displayed, everything else was not found in the search. The first thing I suspect is the SQL Query. I printed out the SQL Query and tried to debug it.
The first thing I did is to arrange the SQL Query in a readable manner.
Since I do not have the time to follow the trail from the SQL Query manually, I just comment out 3 conditions at a time, and add a condition each time until the item was found. In the above picture, I’ve found the culprit its the one below the commented out line.
When I commented out the line, the results for the keyword appeared as follow.
So thats the divide and conquer part. So now I know the problem is with the commented out criteria and the one below it. I traced it back to its table (products_to_categories) and found out that the category_id value is empty. Thats why it can’t join in with the categories table and thus there’s no result.
So what did I do? I told my friend about the problem, explained it to him (I gave him a couple of screenshots to explain the problem) and gives him a solution. UPDATE products_to_categories SET categories_id = xx. So that all the item have a category and will be displayed when it is searched by the application.
Erm, yeah. Thats about it.
Disappointing and frustrating
Posted by mkhairul - November 11, 2008 at 03:11:47 pm - 2 CommentsCategories: blog, rants
Right now I can’t think of anything. There’s too much stuff in my mind and my train of thought just wanders aimlessly to one subject to the other and my attention span is the size of a gnat.
Between that and my frustration from lack of communication within the team, it just felt like taking a blow with a sledgehammer in the chest. It brings you down, lying on the floor, barely alive in the pool of your own blood with every bit of hope crushed out of your lungs. Its the feeling of helplessness that is too much to bare. After 5 months of relentless effort to nurture communication between team members, I felt as though I have accomplished nothing. There is still very little communication.
A typical day would be like this.
*comes over to teammate cubicle*
Me: "Whats up? What are you guys people doing?" ("Korang tengah buat ape?")
*long explanation of the tasks at hand which they can solve*
Me: "Ok, cool. Just don’t forget to log it into the Issue tracker and update the wiki"
Teammate: "But I don’t have time. I’m very busy, you know"
Me: "So you’d rather answer phone calls over in the weekend when something happens than write about it? We are a team we need to know how to solve problems that the team members have already solved. We must not think as many but as one!" (My ramblings continues.. )
Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds.
Valid XHTML and CSS.





