Assuming you already understand how to do CI + AJAX jQuery, using JSON should be pretty easy. We’ll only need to extend couple things. First, we’ll be extending Message::view in Message controller from that tutorial. Then we’ll extend the view to fetch/process the data.

Since we already handled the view type we want to return, all we have to do is add more handler for json. We’ll just convert the array of objects we get from model using json_encode function. Here’s the code:

If you’re using php + apache in Lucid Lynx (Ubuntu 10.04), you’ll notice that the php is disabled when you’re using userdir module (http://localhost/~yourusername). To enable it, open /etc/apache2/mods-enabled/php5.conf (alt+F2, then type gksudo gedit /etc/apache2/mods-enabled/php5.conf) and comment this part (add ‘#’ character in every line):

php_admin_value engine Off

The result should be like this:

#
#
# php_admin_value engine Off
#
#

Save the file, then restart the apache by typing sudo /etc/init.d/apache2 restart in terminal.

If you’re using ubuntu as your choice of linux distribution, and you like to add some unofficial repositories, you probably find some warnings when you run apt-get update command.

The warnings are probably like this

W: A error occurred during the signature verification. The repository is not updated and the previous index files will be used.GPG error: http://dl.google.com stable Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A040830F7FAC5991
W: Failed to fetch http://dl.google.com/linux/deb/dists/stable/Release
W: Some index files failed to download, they have been ignored, or old ones used instead.
W: You may want to run apt-get update to correct these problems

That’s the warnings I got when I added google debian repository. There won’t be anything bad about it, since we could still install the packages from that repositories. But, I we could get rid the warnings, that’s would be a lot better. We could use gpg command to get the key.

Short Version

For you who don’t want to read pointless explanations below, here’s the short version

This is merely my personal note. I was about to rename all my files under a directory. I need to replace the space with underscore character ('_'). My first thought was a simple bash script to do that. Apparently, it’s been very long time since my last bash coding session. I spent 15 minutes reading how to read all files and rename them. And I got nothing.

Luckily, I know python. Stupid me. Why didn’t I think it at first time. It was couple minutes of python and all the spaces were replaced by underscores. Thanks to python. All I did were