Archive for the ‘Software Engineering’ Category

Footprint – Now Open Source

Footprint was my first real web app with Webstrong, but for a multitude of reasons I never launched it. I have no regrets with that decision, it was definitely the right thing to do at the time. But lately I’ve been looking back on what I’ve achieved so far and I’ve decided that despite Footprint never reaching it’s potential as a business, it can still provide some value as an open source project.

The Original Idea

Started in 2007, I came up with the idea whilst on a flight to China, having just finished 37 Signals’ Getting Real. Feeling totally inspired and with absolutely no market research whatsoever I went about wireframing up a web app, that I would use myself, to help me work more effectively with the web design clients I had at the time in Webstrong.

During the flight, I filled a large notebook with ideas, features, names, technologies, wireframes, and even the infrastructure of the software. The ideas were pouring out of me. I wrote hundreds of pages. Filling the notebook on that flight was and still is the most productive work I’ve ever done.

Two weeks later, on the return flight to Dublin, after having fleshed out the plans for the app over the holiday, I began coding. As luck would have it, we were upgraded to business class, which gave me plenty of room to work on my laptop and personal access to power. I began coding. Whilst others slept on the flight I was writing code. I coded non stop for 14 hours, another session of extreme productivity, and by the time we touched down in Dublin Airport I had the outline of a working prototype.

Getting Support

Over the next week, I put together an application for the Hothouse incubation programme after having heard about it from a friend. As luck would have it, they were just closing their next round of the programme and I managed to get an interview straight away. And so, with no business plan, a working prototype, a hastily filled out form, and a 2 hour interview I managed to land a place on Hothouse.

Over the next month, I continued to work on the app, adding new features, multi-tenancy, and even built out the start of the promo site. During the same time, I prepared my CORD grant application, a business grant from Enterprise Ireland, aimed at technology startups with international potential. It gave you half your salary from the previous year, tax free, up to a maximum of €38,000. Entrprise Ireland took no equity in the business and the money didn’t have to be paid back or even matched. It was, and still is, the cheapest way to fund your startup in Ireland.

Whatever I said in the CORD interview, I must have impressed the judges, because a few weeks later, I was approved for the grant. And sure enough, the next month I began to receive the first of 12 monthly payments into my personal bank account. Plenty of cash to support me whilst I worked on and launched Footprint.

Polishing and Polishing

I was on a roll. I was 25, and running an Enterprise Ireland funded technology startup. Over the next few months, nothing could stop me. I added features, installed a blog, a forum, integrated Amazon’s new S3 storage, OpenID, RSS, and even made a start on an RESTful API. I did some real market research, wrote a proper business plan, went to networking events, told people about what I was doing, got feedback – some good, some bad. I did all of this, all without launching the actual app.

This was my mistake. In hindsight, I now know that my ego was too fragile to launch an app that I wasn’t completely happy with. I had a minimum viable product, but I kept on polishing it. I postponed launching it, constantly giving myself reasons not to launch. Despite what everyone was telling me, I felt I knew best, and that launching now was a mistake. However, nothing was further from the truth.

Failure to Launch

The truth was, launching it immediately was the only way it could have worked at all. These days, once you have an MVP (minimum viable product) it’s time to launch. Period.

And as time went on, I got distracted. People started asking me to help them on their own projects, I got busier, and worked less often on Footprint. And all the time in the back of my mind was this doubt, that it simply wasn’t good enough.

In reality, I should have let the public decide whether it was good enough.

Over time, development on Footprint slowed, and eventually stopped. Consulting took over, and the seduction of a large paycheck won out. I guess I just wasn’t ready for what could have been.

Finding My Passion

That was in 2008. Almost 4 years ago. What I learned through that process has helped shape my career ever since and gave me my mission for the rest of my life. Despite the failure, I had found my passion  – I wanted to run a web app business. Bleeding edge technology, community, leverage, global reach, passive recurring income. It had everything. It was looking likely now that it wasn’t going to be Footprint. But the lessons  I learned from that journey gave me skills and experience that ironically I may not have gotten had it succeeded.

Having learned so much, and gotten so much out of it, I wanted to share it with you – especially if you’re thinking of getting into the business of web apps. It’s the greatest industry in the world. And whilst the rest of the world is in a deep recession, web apps are booming.

Going Open Source

Now it’s 2012, and rather then have Footprint continue to gather cobwebs on an old server, I’ve decided to give others the chance to learn what I’ve learned. And so, as of today I’m opening up Footprint completely and releasing it open source.

The Footprint web app has been fully launched now at footprintapp.com, despite it not being completely polished.

I’ve released the source code on GitHub under the Open Software License v3.0. Included is a full installation guide and database generation scripts. If you want to host a copy of it yourself, you can. If you want to improve the currently hosted version, just make your changes and send a pull request. If you want to strip it down and take out the pieces you need for your own project, that’s fine too.

To help understand how Footprint works, here’s an overview of it’s system architecture. I wrote about it in more detail previously.

Footprint was built in PHP 4.2 on an Apache web server, and uses PEAR and the Smarty Template Engine extensively. You will need a MySQL database and an Amazon AWS account to get everything up and running. Follow the instructions in the installation guide for step by step instructions.

What Next

Nothing would make me happier, then for someone to take a copy of this code and do something interesting with it. In fact, if all they did was write some improvements and use it themselves, then that would be just perfect. Footprint is now open source – that’s the whole idea! It’s over to you now to decide what you’d like to do with it.

Code Igniter and Smarty Template Engine

Earlier today I decided to spend some time looking at new ways to improve Code Igniter’s template code. I’ve been using Code Igniter for about a year now and I’ve always been a little frustrated with how it’s template code can get a little out of hand. Sure, PHP has a shorthand syntax but it can still get a little messy without a lot of self discipline. Now I could blame myself and my sometimes undisciplined coding habits, but I’d rather blame my tools and look for a better way, which is why we aren’t all still coding in the 8086 assembly language.

So since then, I’ve been on the constant lookout for better ways to structure the template code. I’ve been coding professionally now for a good 10 years and I’ve still not seen a better way to seperate out PHP code from frontend code than by using Smarty.

I started using Smarty in 2005. It’s the most popular PHP template engine and sports it’s own template language. If you’re a PHP developer and you’ve never checked it out, you should take a look. You’ll have to go through the hassle of learning it’s own templating language, but once you’ve done it, you’ll see how much simpler your frontend code can be. In fact, I’ve never managed to find a better way to write it, which is why I started looking for ways to improve Code Igniter’s frontend code, and you’ll never guess what I found. It turns out that I can have my cake and eat it, I can use Smarty with Code Igniter!

I stumbled upon this excellent tutorial, written by coolphptools.com where it shows step by step exactly how you can get the two of them working together. So, I followed it, and made some small improvements along the way.

I won’t repeat what the tutorial covers, you can check it out if you want to go through the steps yourself, but if you just want to try it out, then you can download my working copy of Code Igniter and Smarty.

I used Code Igniter version. 2.0.3 and Smarty Template Engine version 3.1.4 along with the bridging code provided on coolphptools.com. In my environment I used PHP version 5.3.5 running on Apache 2.2.17. It’s also worth noting that  Smarty v.3 is not backwards compatible with PHP 4.x so if you haven’t updated to PHP 5.x by now, you should.

I made two slight amendments to the steps outlined in the tutorial.

Template Code Delimiters

I changed the left and right template code delimiters from the standard curly brackets to a combination of tildes and square brackets. If you write a lot of Javascript and embed it in the template files then the default code delimiters in Smarty can cause a few issues…

So with my new change {smarty_variable} becomes [~smarty_variable~].

It’s a little more verbose, but gets around having to use {literal} tags everytime you need to add Javascript in your .tpl files.

Error Reporting Level

By default in Smarty 3, template error level reporting is not used. Instead Smarty uses the global error reporting defined by PHP. As many Smarty templates use code such as:

<snippet>
[~ if $message ~] Please complete the form. [~ /if ~]
</snippet>

… then in times when $message is not defined and PHP is set to throw an error on a Notice then this
code will display an error. As this code is very common, particularly in legacy .tpl files, I amended
the Smarty.php file again to not throw notices on errors in the Smarty templates.

If you haven’t tried out this combination, then this should help you get started easily. It’s a great combination that combines the power and structure of Code Igniter with the simplicity of Smarty in the view.

Download the Code Igniter and Smarty Package.

UPDATE: I’ve put the code up on Github: https://github.com/iarfhlaith/Code-Igniter-and-Smarty

Writecamp Pre-launch

I’m launching a new concept for a web app over at http://writecamp.com.

Writecamp is a connectivity web app that turns Basecamp Writeboards into a content management system for websites that are normally static.

This is something we’ve had cooking for a while so it’s nice to finally start talking about it.

There’s a signup page setup for those of you who want to be invited to test it when it’s ready. We’ve also got a product blog where we’ll be discussing technical issues, marketing strategies, pricing, and other things related to the project worth sharing.

And just in case you can’t handle the short silences between blog posts you can follow progress on our new Twitter account too.

Footprint’s System Architecture

A Deep Dive into Footprint\'s Architecture

As some of you may already know, I’m working on a web app called Footprint. Essentially it’s a business collaboration tool to help designers run their business. I’ve really enjoyed building it and I’ve learned a huge amount in the process. So in this post, I’m going to share some of that and show you how the whole system comes together.

The Tools of The Trade

At its core, Footprint has a simple, modular code architecture that I’ve slowly built up during its development. I wanted the system to make use of all the latest AJAX libraries while at the same time, failing gracefully if Javascript wasn’t turned on at the browser. So, I developed a framework using a combination of jQuery, Smarty, the SmartyValidate plugin and PHP sessions to support both synchronous and a-synchronous calls to the same script using centralised messaging and form validation.

Other key libraries include the well known PEAR library, the PHP OpenID Library by JanRain and the S3 SDK by Geoffrey Gaudreault.

The Poster

To get a better idea of how everything is organised within the app I created this poster:

Footprint Architecture Diagram

(Click on the image to enlarge)

This colourful image represents all the main libraries, plugins, data stores, and communications channels used in Footprint.

The Framework Features

I’ve used an MVC architecture, built on a set of controller files. These control the flow of the app and acts as a buffer between the system’s business logic and the UI layer. Other aspects of this design that I’m very proud of are:

  • Dual Support for OpenID and Standard Authentication;
  • An API layer so that the app can be expanded on once it’s released;
  • Support for both Synchronous and A-synchronous communications;
  • Centralised Email Centre, where all email templates are held;
  • All users’ binary data is stored on Amazon’s S3 Simple Storage Service;
  • Built in support for multiple languages.

I created this poster to act as a reminder for myself of Footprint’s structured codebase, and to enforce a disciplined approach to code amendments and additions as the system matures and grows.

The Original

Here’s the original sketch that acted as the basis for the poster: (I kind of prefer this one! How about you?)

Footprint Architecture Original Sketch

(Click on image to enlarge)

What Does Your Architecture Look Like?

I’d like to see more of these graphical representations from other developers. It’d be great to see in a visual way how others organise their code. I’m not exactly sure why these appeal to me so much, maybe it’s because I’m left handed and therefore a visual learner. Who knows.

If you already have a poster for your web app, I’d love to see it so please leave a comment and let me know.

How to Use the Twitter Search API

How To Use the Twitter API

I’ve always wanted to play around with the Twitter API. Everyone seems to be doing it these days. All I needed was a reasonable excuse. So, I decided on integrating relevant Twitter posts into Short.ie.

Recently I created a Twitter account for the new URL shortening service. The purpose of which was to post up new release information, engage with the users and essentially put a ‘face’ onto the service. But for this to be really effective I needed followers, and the best way to get those is to start following people yourself.

Maximising RSS

The only problem was, I needed to know who to follow. This is where Twitter Search comes in. I wanted to follow anyone who was currently using the short.ie service and Twitter Search allowed me to find them.

Getting Comfy with the Twitter API

So, to make my life easier, instead of trawling through the search results by hand and manually following each Short.ie user I decided to write a script to automatically follow everyone who posts a tweet that’s got a Short.ie link in it.

Here’s the code:


// Parse Search Feed
$rss =& new XML_RSS("http://search.twitter.com/search.rss?q=short.ie");
$rss->parse();

// Loop through all Tweets
foreach ($rss->getItems() as $item)
{
    // Get username of who posted it
    $user = substr($item['link'], 19 );
    $posi = strpos($user, '/');
    $user = substr($user, 0, $posi);

    // Follow the user via the Twitter API
    $req = new HTTP_Request('http://twitter.com/friendships/create/'.$user.'.xml');
    $req->setMethod(HTTP_REQUEST_METHOD_POST);

    $req->setBasicAuth('username', 'password');
    $response = $req->sendRequest();
}

It's a very basic script right now, but it will form the basis of a more comprehensive solution as it matures. But, for only 10 lines of code, it's pretty powerful!

The script has 4 main parts:

  • Retrieve and parse the RSS feed for the search
  • Loop through the feed
  • Extract the username from the link of each tweet
  • Use the Twitter API to follow the creator of the tweet

Obviously there are some issue with duplicates to be ironed out, and I think I'd like to store some of this information in a database too, but that can all come later. For now, I can say that I've dipped my toe into the world of the Twitter API and so far I like what I've seen.

Notes

To use this script, you'll need to install and configure PEAR. I used the XML_RSS and HTTP_Request packages in this example.