Select Page

Author: Darren Cato

Setting an older Ruby project with RVM

I’ve decided to take the plunge into the world of Ruby. Because I’ve dabbled before I have some some other project on my Ubuntu machine that depended on a little Ruby. To get up and running I’m using the highly recommended book Agile Web Development with Rails (Pragmatic Programmers). The only problem is I am using the Third Edition where all the examples use Ruby 1.8.7 and Rails 2.2.2 One of the biggest gripes I had years ago when I was first presented with Ruby project to tweak was its complete lack of backward compatibility. A little utility call...

Read More

Use Zend acl with Codeigniter

So i’m still using CodeIgniter on my latest project and while I would prefer to use Zend Framework, CodeIgniter is getting the job done. There are some required things however that CodeIgniter does not do well out of the box. Things like Authentication, ACL and Unit Testing. The first of these issues, i needed to tackle was the ACL (Access Control List). Turns out Zend has a really good ACL library, which i’ve used before. Their documentation is also pretty decent. Since i wanted to gently introduce my team to Zend framework I jumped at the opportunity to integrate the Zend...

Read More

Append file type thumbnails to dom using javascript (jquery) after upload

There are several javascript utilities available to provide you user with a pleasant way to upload files from the front end of your web application. My utility of choice today is wonderful jquery plugin called plupload. You can read more about plupload on their website. What file upload utility you choose to use is up to you, my goal today is to present you with a little javascript code that will allow you to show an appropriate icon next to your freshly uploaded file. For example, pdf’s will show a pdf icon, and all images will show an image icon. // use some regular expression goodness to match the appropriate file extension var pattern=/\.[0-9a-z]+$/i; // extract file extension var ext = (file.name).match(pattern); ext = ext[0].toLowerCase(); // set default icon var icon = 'http://'+window.location.hostname+'/js/plupload/img/attachment.png'; // check for pdf's if( '.pdf' == ext){ icon = 'http://'+window.location.hostname+'/js/plupload/img/pdf_file.png'; }// check for images else if( '.jpg' == ext || '.gif' == ext || '.png' == ext || '.jpeg' == ext){ icon = 'http://'+window.location.hostname+'/uploads/'+file.target_name; } // at this point you can check for other likely extensions, such as word doc, or excel files. // display the icon var thumb = '<div class="plupload_thumb"><a href="" title="" rel=""><img src="'+icon+'"></a></div>'; Like this:Like...

Read More

Remove truncated var_dump on xdebug

Xdebug has been called the swiss army knife for php developers and for good reason. It’s a must have tools with helps with everything from debugging to code coverage. Once of the many cool features of xdebug is that it formats and and syntax highlights the output from var_dump. However a negative side effect is that it truncates this output. To fix this simple enter the information below in you php.ini file and restart apache. -1 sets the value to unlimited xdebug.var_display_max_data=-1 xdebug.var_display_max_children=-1 xdebug.var_display_max_depth=-1 See the five part series on Zend Developer Zone for a complete tutorial on using xdebug Like this:Like...

Read More

Setting up Virtual Hosts on MAMP

So you’ve installed MAMP and its been working fine for your one site you’ve been developing locally. However like most developers you are probably now working on several projects at a time or perhaps you are using a framework that does not like the “localhost” url. For the issue of multiple websites, there are a couple of solutions. MAMP makes it pretty easy to switch your document root folder in their settings. Another option is to support the MAMP team and go pro. However if you are a do-it-yourself-er. Here is how to set up virtual hosts with MAMP First edit your hosts file to create your custom local domain. I use the vim editor but you can use your favorite. You will need root access to edit your hosts file. sudo vim /etc/hosts Once you access you hosts file, add the following line to tell it to redirect your custom url to you MAMP server. 127.0.0.1 test.local The next step is to create the folder where you want your web content to reside. The default is the MAMP htdocs folder, but i like to create my sites under a Sites folder in my home directory for example: /Users/darren/Sites/test Ok now we need to edit the apache config file and tell it to to enable virtual hosts. Open the following file “Applications/MAMP/conf/apache/httpd.conf” and un-comment or add the following line....

Read More
%d bloggers like this: