Making jQuery selector/contains case insensitive

Categories: 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)

Categories: 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.

Debugging an SQL Query

Categories: 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.

Steam Problem

Categories: Troubleshoot, rants

I bought fallout 3 using steam (digital distribution service from Valve), the first problem that I had was updating steam. I downloaded steam through their site and installed it normally. When I run steam, it updates something and then it can’t find a DLL (steam.dll). Searched through the forum on the net, found some answers, try it out, still the problem persists.

I went ahead and find steam.dll, downloaded it, and it says can’t find steamui.dll. I downloaded that too and continued, it updates just fine.

Few hours ago, when I arrived home from work, ran steam and it doesn’t load. It says there’s no connection to steam. I deleted cleanregistry.blob and still no luck (but this time all the login info is lost). Restored the blob file and restarted the router. Finally it runs smoothly. This is some crappy software that valve have. Time to shoot some mutants!

Take a step back and think!

Categories: Troubleshoot

On the weekend, I reviewed the tree traverse function that I did for an ongoing freelance project. Each node have 3 child. I tried to insert 200 records and it took quite a long time to insert the records into the database. 23 seconds.

thinking cat

I am quite sure of the code that I didn’t bother to look at it first and search for other means of alternative on improving the insertion. I googled around for MySQL performance and found a few posts on MySQL Performance Blog. Merge Tables. I need to find out more about this storage engine. I opened up High Performance MySQL, and read up on it.

After an hour reading the book, thinking of ways to implement it and including the constraints of current web host, I thought to myself, this is too hard and complicated, not that I can’t solve hard problems. Haha! I took a few steps back, and try to do something else like watching a funny anime, Gintama. Sometimes taking a break unravel the mind from all the messy thinking being done and makes it easier to think clearly.

Later on I try to think about it again and found out that I’m doing a depth-first search. Which is why it is taking such a long time. I rewrote it to use breadth-first search and it solved my problem for the mean time. I still have to test if it can handle 6165 data insertion.

Javascript, hide paragraph

Categories: Development, Troubleshoot

While I was developing a new app for use here at work. I tried to use javascript to hide an element and all of its contents.

JAVASCRIPT:
  1. function show_new(id_name)
  2. {
  3.     $('#category').hide();
  4.    
  5.     return false;
  6. }

To hide this html stuffs

HTML:
  1. <p id="category">
  2.             <label>Category</label><br />
  3.             </p><div class="select">
  4.                 <select class="medium" name="category">
  5.                     <option>-Select-</option>
  6.                 </select>
  7.                 <span class="moreinfo">Or add a <a onclick="return show_new('category');" href="#">test<span class="red">NEW CATEGORY</span></a> </span>
  8.             </div>
  9.             <div class="new">
  10.                 <input type="text" name="category" />
  11.                 <span class="moreinfo">Or add a <a href="#"><span class="red">NEW CATEGORY</span></a> </span>
  12.             </div>
  13.       <p>&nbsp;</p>

When I click on the link "NEW CATEGORY", it executes the javascript function but the only thing that it hides is the label. Everything else stays. I thought there was a duplicate or some shit, but no, there's none. Then I remembered that you cannot put block elements inside an inline element (thanks to weekly check using w3cvalidator on my blog).

Cannot delete folder: Access is denied

Categories: Tips, Troubleshoot

Ever stumble upon this message while trying to delete a file or a folder?

Cannot delete folder: Access is denied

Make sure the disk is not full or write-protected and that the file is not currently in use

sc_5-15-2008-115311-am.jpg

Most probably you have, and most probably doesn't know how to handle this.

Continue reading Cannot delete folder: Access is denied...

Google App Engine static_dir workaround, windows

Categories: Development, Tips, Troubleshoot, blog
appengine_lowres.jpg

There's two workaround for Google App Engine dev_appserver.py workaround regarding the app.yaml configuration file.

Change lines 2369-70 in <installdir>\google\appengine\tools\dev_appserver.py from:

PYTHON:
  1. regex = os.path.join(re.escape(regex), '(.*)')
  2. path = os.path.join(path, '\\1')

to:

PYTHON:
  1. regex = re.escape(regex) + '/(.*)'
  2. path = path + '/\\1'

or

PYTHON:
  1. regex = re.escape(regex) + '(.*)'
  2. path = path + re.escape(os.path.sep) + r'\1'

The latter works for me.

Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds. Valid XHTML and CSS.