Apple have released the new Mac Mini. This update includes an updated case/shell and they’ve introduced a HDMI port.

Capistrano Recipe for CodeIgniter Apps

I posted this a while ago on Forrst.

Make sure the logs and cache directory are writable. You can adjust the permissions based on your environment settings.

New plugin for jQuery that resembles the vibrating or nodding effect that can be seen on a Mac’s login screen (If there is an error with your login credentials).

An easy to use tool I created that generates your Apache’s virtual host configuration code. Useful if you manage your own web server and use virtual hosts to host your domains.

Tags: apache

A collection of anonymously contributed client horror stories from designers.

Generating Cleaner Thumbnails with CodeIgniter

CodeIgniter’s Image library has some very useful functions for resizing and cropping images to generate thumbnails. The library is so useful that it even provides a function to crop images based on it’s corresponding ratio so a thumbnail doesn’t look stretched out.

However, resizing an image so it doesn’t lose it’s original ratio implies that different images will have contrasting sized thumbnails. What if your site has a fixed size for these thumbnails? Resizing an image to a fixed size will result in some images looking stretched because of a ratio mismatch.

In such situations, the crop function comes into use. The following code demonstrates how to resize an image whilst maintaining a specific ratio so the thumbnail doesn’t look elongated and out of proportion.

This example assumes that all your thumbnails have to be resized using a 1:1 aspect ratio. The code first calculates the image’s original width ($width) and height ($height) - depending on which value is smaller, both width and height are set to this value. This will create a perfectly squared (1:1) cropped version of the original image.

The next step is to actually crop the image using CodeIgniter’s crop function. This example will crop the top left corner of the image using the GD2 library. It’s possible to crop any area of the image by defining the x and y axis in the $config array. 

Finally, if nothing breaks during this process, the cropped image can be resized using the resize function.

A very nice tool to create and preview your markup, on the fly.

Large File Uploads with Apache & PHP

Working with large file uploads can be a real pain if you don’t know what you’re doing. Until recently, most applications or websites I’ve worked with had file uploading capabilities, but these files were small. Getting file uploads to work with little data isn’t hard, but it becomes a problem when you’re handling large amounts of data.

In order to get large file uploads to work, it’s necessary to not only adjust your PHP settings but also Apache’s settings. Once you know what has to be done, getting large file uploads working is painless.

The following settings need to be updated in your php.ini file.

The following settings need to be updated in your httpd.conf file.

Depending on the requirements of your application, you need to adjust these settings accordingly. If your working with large files the value for these settings will be high and vice versa for smaller files.

Tags: apache php

Trimming timespan() in CodeIgniter

The timespan function on CodeIgniter outputs dates using the following format:

1 Year, 10 Months, 2 Weeks, 5 Days, 10 Hours, 16 Minutes

Whenever the date of an item or object turns a year old, the date is presented in a long format. Realistically you don’t need minor details such as hours or minutes.

It’s possible to reduce the output using the following technique:

The above code will output the oldest value, so if you’ve recently created something you will see just minutes, or a few hours ago once you wait a bit and years as you age.

You can modify the return to customise the date format and accordingly add or remove different time spans. If you’re unsure of what time spans are available var_dump($time).