Update any index in CodeIgniter Cart class

If you use the Cart class that was introduced in CodeIgniter 1.7.2 very often, you’ll notice that it has some shortcomings. In particular, the update() method will only update the quantity of the item in the cart; it will not update other indexes.

This is troublesome because sometimes you may want to update the price, for example, if the quantity goes above a certain threshold. Suppose you want to give a 10% discount on an item to anyone who orders 10 or more of that item. As it stands, you would have to remove the item from the cart, calculate the discount for the item, and re-add the item with a different price. I have also ran into the problem when I added a flag index to items in the cart to which I needed to do additional processing during checking depending on its status. I’ve found in both cases that the better solution is to extend the cart class. Here is how we can do it.

Read more »

Forwarding X11 over SSH from Linux to Windows

For those that are not familiar with Linux, X11 is a part of the graphics system, and that is really all you need to know for this short blog entry. Below is a video that demonstrates what forwarding x11 over SSH will actually allow you to do: in the video, I run a remote session of Kate (a Linux text editor) and Gwenview (a Linux image viewer) from my Linux machine to my Windows machine. It’s similar to remote desktop, but instead of the whole desktop, you can use certain applications. You’ll see what I mean in the video if you’re not following already.

The first step is to configure SSH client and server on your Linux machine. Instead of repeating what’s been written a thousand times before, I’ll send you to the Ubuntu SSH Server instruction guide . If you use a different distribution, you can look up it for yourself if you have to, but as far as SSH goes it is pretty much the same wherever you go.

Read more »