Rich Buggy

...Developer, CTO, Entrepreneur

phpConf.au

Written by Rich on April 5th, 2011

I don’t know much about phpConf.au or who is organizing it. If you’re in Sydney and interested in a PHP Conference then it’s probably worth registering your email address for more information.

Update: It’s amazing how easy it is to write config instead of conf when you’re writing while talking to a 3 year old.

Black Friday Hosting Deals

Written by Rich on November 26th, 2010

Black Friday in the US started a couple of hours ago. For those not familiar with Black Friday it’s the Friday after Thanksgiving and the traditional start of the Christmas shopping period. More recently it’s become known for crazy deals by retailers.

This year HostGator.com is giving 50% of everything for most of the day and 80% OFF between 5am and 9am CST. That makes shared hosting as low as $0.99/month, VPS from $3.99 and dedicated hosting from $34.80 for the first month.

jQuery UI sortable

Written by Rich on September 2nd, 2010

Recently I’ve been playing with a list of lists using the jQuery UI sortable component. Graphically it looks something like:

  • List 1
    • Item 1
    • Item 2
    • Item 3
  • List 2
    • Item 5
    • Item 6
    • Item 7
  • List 3
    • Item 7
    • Item 8
    • Item 9

The HTML for this is pretty simple

<ul  class="lists">
    <li>
        <h1>List 1</h1>
        <ul id="list_1" class="list">
            <li id="item_1">Item 1</li>
            <li id="item_2">Item 2</li>
           <li id="item_3">Item 3</li>
        </ul>
    </li>
    <li>
        <h1>List 2</h1>
        <ul id="list_2" class="list">
            <li id="item_4">Item 4</li>
            <li id="item_5">Item 5</li>
            <li id="item_6">Item 6</li>
        </ul>
    </li>
    <li>
        <h1>List 3</h1>
        <ul id="list_3" class="list">
            <li id="item_7">Item 7</li>
            <li id="item_8">Item 8</li>
            <li id="item_9">Item 9</li>
        </ul>
    </li>
</ul>

I want the user to be able to re-order the lists, the items in each list and move items from one list to another. 18 lines of Javascript later I had it handling this perfectly and displaying alerts telling me where items were moved to, the list they were in and if the lists were re-ordered.

$(function() {
    $(".lists").sortable({
        forcePlaceholderSized: true,
        stop: function(event, ui) {
            var list = ui.item.children('ul').attr('id').replace('list_', '');
            window.alert('Moving list ' + list + ' to position ' + ui.item.index());
        },
    });
    $(".list").sortable({
        connectWith: ".list",
        forcePlaceholderSized: true,
        stop: function(event, ui) {
            var item = ui.item.attr('id').replace('item_', '');
            var list = ui.item.parent().attr('id').replace('list_', '');
            window.alert('Moving item ' + item + ' to list ' + list + ' position ' + ui.item.index());
        },
    });
});

I love jQuery and jQuery UI.

Auto Increment in SugarCRM

Written by Rich on May 22nd, 2010

Earlier today I posted about creating a DateTime Picker in SugarCRM. A second problem I had was creating an auto increment field. This turned out to be slightly more difficult than the datetime picker. Again you need to edit your vardefs.php but this time you add the following to your field.

'auto_increment' => true,

You then need to manually alter the table structure so the id field is a unique index instead of a primary key then add your new column to the database as an auto_increment field and the tables primary key. I also found that if you try to install the module on another system it will fail because it can’t create the table properly. You can solve that by creating the table then installing the module.

Date/Time Picker in SugarCRM

Written by Rich on May 22nd, 2010

Recently I needed to add a date/time field to a custom SugarCRM module. Sadly the module builder doesn’t include support this and the documentation is pretty bad. Eventually I managed to solve my problem and the solution is suprisingly simple.

After adding a date field to the form I edited my vardefs.php file. You’ll find the file in custom/modulebuilder/packages/package_name/modules/module_name/. Find the field and change it’s type to datetime.

Next you need to change your views. They’re located in custom/modulebuilder/packages/package_name/modules/module_name/metadata. In my case I wanted to the edit view to show a datepicker plus a time combo. I found the field and added

'type' => 'Datetimecombo'

After that I deployed the package and my module was now saving as a date/time and in the edit view I could set both the date (using a date picker) and time (using drop down lists).

Don't blame the framework for bad performance

Written by Rich on April 8th, 2010

As a developer it’s all too easy to blame a framework for your applications bad performance. Before you do you might like to ask if you’re contributing to the problem. Most developers don’t think about what they’re really doing or how they could improve performance. I’ve seen a lot of code where every request results in at least one database query even though the database rarely changes.

Below are some stats for an application using the Zend Framework:

PHP – 36 requests/second

PHP + APC – 111 requests/second

PHP + APC + Memcache – 2,048 requests/second

By spending around 3 minutes to add code so the pages output is cached I’ve been able to improve performance 56 times without needing to throw out the framework. Of course this is an extreme example but it applies to most CMS, blogs, etc…

API equals dollars

Written by Rich on December 20th, 2009

Lately I’ve been looking at a number of SaaS providers covering a range of areas. It amazes me how many of them have no API or only a reporting API. If you’re thinking of building a SaaS start-up then you should be thinking about creating an API that allows your customers to do everything they can with your user interface.

Service providers with this API have an obvious advantage when it comes to migration and integration but they also have a more subtle and more important advantage. When reviewing potential providers I looked at those with an API before those without. Your SaaS may be the best but without this API are potential customers even considering you?

Please sack the NSW Government

Written by Rich on December 3rd, 2009

Committing unlawful acts one month, Premier elect the next.

The NSW Government has imploded and is no longer capable of governing this state. It’s time for the Governor of NSW to stand up for the people of NSW. If this is all we have left to run the state then it’s time to sack the government.

WebBlast

Written by Rich on November 30th, 2009

It’s that time of year again. Tickets are available now http://www.webblast.com.au/

Where's the data Nathan?

Written by Rich on October 15th, 2009

After reading Pia’s post about opening up government data I went back to a post I made the day the NSW Government announced that it was opening up government data. That was the 4th September. We were promised that a trial feed was being tested and a full feed would be opened on 21st Septemer. It’s now 15th October (nearly a month after the feed should have started) and the one government dataset covering NSW comes  from the Commonwealth Government.

Where’s the data Nathan?

Let’s be honest. The Commonwealth Government has started to open access to data. So have other states. The NSW Government has simply extended it’s policy of making grand announcements with no intention of following through. If there really is data available then put it in your data catalogue so we can find it!?!? I guess they’ll re-announce this every 12 months in between announcing yet another rail line that won’t be built.