Working with Eclipse and Code Igniter

eclipsecodeigniter_ideTill recently I had been using my trusted editor, Notepad++, for doing all my development work. Not that I am not using it anymore, but I was looking for something more powerful and integrated, something like an IDE. I had tried few IDEs including Eclipse before but did not get much into it and hence left it there. I picked up Eclipse again and tried to give it one more try. I also tried out Aptana which is another awesome IDE built on Eclipse with all the web development tools you need built into it out-of-box (PHP, Ruby, jQuery, Python). Continue reading “Working with Eclipse and Code Igniter”


Magic Mime Database Workaround

Timthumb is a very useful PHP script used heavily to resize images on the fly in many WordPress themes. Timthumb uses a PHP function FINFO_OPEN to get info regarding the image. The function FINFO_OPEN uses a magic.mime database, which is basically a text file, to get information regarding the type of image. Many hosts (like mine) do not provide the magic.mime extension and hence the script cannot resize the image on the fly. The magic.mime file if present is present at /usr/share/magic.mime. However, if the host does not provide it, there is a workaround to get the magic.mime file working with the Timthumb script.

The FINFO_OPEN function takes the path to the magic.mime file as a parameter. You could download the file and put it in the same directory as the Timthumb script and test out if the images are being resized. The code which needs to be changed should look like this :

$finfo = finfo_open(FILEINFO_MIME, "./magic.mime");

You could get the magic.mime file from any Apache installation. does not allow me to upload a .mime extension file or else I would have upload it here directly. Let me know if you need the magic.mime file.

Job Trends: Ruby shows 1200% growth

Job Trends: PHP, Ruby, Python, Perl, C#

In my previous post, I mentioned about the trends in PHP frameworks and was curious to know if there is anyway to know the job market for those frameworks. I did not find any such trends, but what I came across was trends or popularity of programming languages. is a job search engine site which searches various job sites and shows results. They have an interesting utility to see trends using search terms. I did a comparison of popular programming languages namely PHP, Ruby, Python, Perl, C# and the result is clearly showing Ruby has gained 1200% in the past 4 years. The graph shows “relative” trend (as compared to “absolute” trend) comparing the number of jobs being advertised for Ruby as compared to other languages. The runner ups were Python and PHP. Ruby has gained a lot of popularity in the past 4 years and it is good to see that programming languages are getting popular again specially the open source ones in this struggling economy. Is it time to learn Ruby and Python?

Google Trends: PHP Frameworks

googltrends_phpframeworkGoogle Trends is a useful tool to compare the trends in what is being searched on Google. I was curious to see what PHP frameworks are being searched ( and used) on Google. The image above shows that Cakephp is the most popular framework while Code Igniter/Kohana are trailing behind. But Code Igniter started relatively late (late 2006) as compared to other frameworks (mid to late 2005) but has been picked up quickly.

Another interesting observation from the above trend is, Code Igniter is most popular in Bangladesh, Indonesia and Philippines. I wonder if there is a way to get trends of jobs for these frameworks.

Google Trends: PHP framework

Displaying resized images as links in WordPress

While working on a WordPress theme for a friend, I was looking for a way to display links as images rather than text. WordPress provides wp_list_bookmarks function to display links. The parameter show_images controls whether to display images or not. But my requirement was to display just the images and no text. And I wanted to resize the images rather than showing the entire picture.

WordPress provides another function get_bookmarks which can be used to controls what links we need to fetch. Together with parameters, the function can provide the solution to my problem.

The function was called in the following way:

$bookmarks = get_bookmarks('category_name=bands&limit=3&orderby=id&order=DESC');

I have a links category called “bands” and wanted to get the latest 3 links in descending order using the “id” column.

The function returns an array $bookmark which needs to be looped through to get the results.

foreach($bookmarks as $bookmark) {

echo $bookmark->link_name;

echo $bookmark->link_image;

echo clean_url($bookmark->link_url);

The final code block with the resize script (timthumb) looked like this:

 $bookmarks = get_bookmarks('category_name=bands&limit=3&orderby=id&order=DESC');
 foreach($bookmarks as $bookmark) {
	<li><a title="<?php echo $bookmark->link_name; ?>" href="<?php echo clean_url($bookmark->link_url); ?>" target="_blank"><img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo $bookmark->link_image; ?>&h=100&w=300&zc=1" alt="<? echo $bookmark->link_name; ?>" id=""/></a></li>

Building a headless linux box : Part 3

In our previous post, we saw how to setup access to linux box files using SAMBA. In this post, we will setup remote desktop access in case if you are more comfortable using the GUI or for some GUI related actions.

In order to setup remote desktop access, we need to install VNC server on our linux box. So, fire up PuTTY and log into linux box and run the following command to install VNC server:

sudo apt-get install x11vnc vnc-java

Once installed, we need to secure our access to the box via VNC by creating a password. This password will prompted by the VNC client software while connecting. Create a password using the command:

x11vnc -storepasswd

By default VNC server runs on port 5800 and 5900. So, if you are going to access it from outside your network, make sure you open up the ports on your router.

Next, run the following command to start the VNC server:

x11vnc -forever -usepw -httpdir /usr/share/vnc-java/ -httpport 5800

Once the server is running, using a VNC client like (TightVNC, RealVNC) connect to the linux box using the hostname and password. Once connected you should be able to see your linux desktop and perform actions as if it was the actual desktop.

The command to start the server should be added to startup commands so that the VNC server starts everytime the machine reboots. On Debian system, you can add the command to /etc/rc.local file. For other distro, please check up with their manual/website.

That’s all for now folks, in the next post we shall see how to setup a web server, ftp server for web development.

Previous Posts:

Building a headless linux box : Part 1

Building a headless linux box : Part 2

Pagination for custom query in WordPress

WordPress is good at taking care of pagination automatically if you are displaying all the posts. But incase if you have a custom query to retrieve results for example: all posts from a certain category then the default pagination does not display the next page of posts. Instead, it displays the same posts again. However, there is a way to get pagination (paging as some call it) with a custom query.

Following code will take care of the pagination:

$page = (get_query_var("paged")) ? get_query_var("paged") : 1;
$wp = new WP_Query();
while ($wp->have_posts()) : $wp->the_post();

<!-- Display your posts here -->

<?php endwhile;?>