Ubuntu Persistant iptables

By default Ubuntu doesn’t preserve your iptable rules between restarts.

You could create an init script, or you could just run the following command:

sudo apt-get install iptables-persistent

GraphSearch is amazing

Quite simply, the new Graph Search from Facebook is amazing. Not only is it extremely fast, but also highly accurate.

So far, I have been doing basic searches to discover new artists based on the pages that other people like that I also like.

The scope for searching content is endless, and it’s clear to see how this will be a benefit for sponsored results, e.g find Indian restaurants in Birmingham that my friends have been to.

A few enhancements for iOS

Ever since the first iPhone came out I have been in love with the platform, however a few missing features are really starting to annoy me. I’m sure I’m not the first, and won’t be the last to suggest some of these enhancements. They aren’t anything big, just small tweaks which I’m sure will make the experience that much sweeter;

Proper location support in Calendar

Within the Calendar app, I can create an appointment and add a location, however I can’t pick that location from my contacts, nor can I open it up in the Maps application. Another feature would be the ability to then not only see a week view, but a map view of all of the appointments for a given period.

Custom app context sheets

Apple have recently added Twitter support across the entire OS. This is great, but should be extended for any app, with the ability for the user to choose which actions appear in which menu’s (they managed to make the Notifications options pretty easy to manage). This is already half done with the ‘Open In’ dialogue; if I have Pages installed, I will have the option to open a .pages file in that application. This would mean deeper integration for apps such as Instapaper or Buffer across the whole system, and would be a way to get a simple type of plugin architecture for mobile Safari.

Add music controls for the Remote app

I have a couple of Airport Express’s dotted around the house so that I can stream music to different rooms. The Remote app is therefore used quite heavily. This means that each time I want to change a track, I have to open the app. It would be great if the shortcuts from the Lock and app switching panel currently used to control the Music app, could be instead used for the Remote app. This is already the case for other music apps such as Last.fm and Spotify.

Twitter links open in a native Twitter app

Most Youtube links will open in the native Youtube app, why is this not the case for Twitter now that it has been baked in at a system level? I’m not always logged into the mobile version of Twitter, which makes following and replying to a tweet via Safari rather cumbersome. This new feature should be accompanied by a preference toggle, for users who prefer the web based version.

Deeper mobile Safari integration

Mobile Safari needs to be updated in a few ways; the ability to have plugins, or at least custom context menu items, will mean tighter integration with third party apps. In the same way that the email sheet, slides up, performs the action and then disappears could be replicated for other apps. For example, rather than using a bookmarklet to take me away to another app, this action could be completed inline, resulting in a seamless interaction and allowing me to carry on with what I was doing without the need to switch back and forth between apps.

In addition, third party apps that utilise the Safari sheet, should be able to read and write to my bookmarks. They should also be able to share cookie and session data, so that if I am logged into a site in mobile Safari, the instance of Safari inside the Twitter app should also have me logged in.

Starting Out

This summer marks 4 years since I graduated form Birmingham City University with a bachelors degree in MultiMedia Technology. Since then, I’ve worked for a number of companies including the University that I graduated from. In that time I have completely changed my skillset to adapt to the ever changing market.

This post is aimed towards graduates that are looking to pursue a career as a web developer.

The degree that I undertook offered many routes in terms on career choice; web, radio, TV or print. I chose to go down the web root as I enjoyed the ASP and Flash modules (my final year project was to create a Flash based VLE with an ASP back end – the co-incidently lead on to me working as a Flash based eLearning Developer, within the Universities Knowledge Centre).

In contrast I’m now working as lead developer, specialising in PHP and Actionscript. The point is that this industry is constantly changing and in order to remain relevant you must ensure that you update your skillset accordingly. However, this doesn’t mean that you should constantly switch to whatever the trendy new language may be, but you must have a general knowledge of how it works, and when is best to use it.

Below are some pointers as to the skills that will make you stand out amongst other graduates:

Read

Never underestimate the power of reading and gaining knowledge, even if this isn’t directly in your subject field. Set yourself up with a Google Reader account and add some tech feeds. Also Subscribe to a service such as Instapaper, and collect articles and posts to read at a later date.

Connect

Find a local meetup group and connect with other like minded developers. If you are in the Birmingham area, come along to HydraHack. This meetup isn’t specific to a particular language and is a great way to discuss general development topics. This will help to broaden your understanding of other development practices and techniques.

Build

Hook yourself up with a Github account and go and build something that you will use on a regular basis. This pet project ca  be as simple or complex as you like. Try something that will actually help you in your everyday workflow as you’ll be more inclined to add features and maintain it. Social coding will help you to get peer related feedback, plus if you can introduce a new technique or language along the way you’ll help to widen your skill set.

Interact

Set yourself up with an account on Stackoverflow or Forrst and participate in some healthy dev discussion. Even if you can’t answer any of the questions straight away, this will help you in understanding how to answer questions. Remember it’s important to understand that a great developer won’t always know all of the answers straight away, but will know how or where to find the answers.

Write

Set yourself up with a blog and start writing about your experiences, knowledge and anything you feel would be good to start a discussion. You may find it tough starting out in terms of subject matter, but over time you’ll find your writing skills will improve. This will help you out when it comes to writing briefs and specs for clients.

In summary, you will never learn everything from a University course or a book, actual hands on experience is vital, and the more you can get the better you will become in your chosen field.

Installing Memcached for MAMP PRO 1.9 running php 5.3.2 on OSX

After a few tedious hours of trying to install memcached for Mamp on my 10.6.8 based Mac, I finally found a solution. This has been sourced from a number of places and I hold no warrant for it working for you. This has, however worked for me, so thought i’d post a quick how to. I’m no expert on how this works, so am unable to diagnose any issues you have.

The setup I have is:

  • Mac OSX 10.6.8
  • MAMP PRO 1.9
  • PHP 5.3.2

As i’m a it of a CodeIgniter nut, i’ve been using this Memcached library (default settings work out of the box).

Sources

  • http://www.re-cycledair.com/installing-memcache-on-mamp
  • http://blog.elinkmedia.net.au/2010/11/02/enable-memcache-on-mamp/

Sendgrid and CodeIgniter

I’ve recently been working on a new project that focuses around the sending of email for marketing purposes – not a newsletter project, but something a bit more advanced.

Without going into too much detail, the system allows users to upload assets and combine these assets to create a one page promotional site. The system also allows users to create lists of recipients and send an email out to this list with a unique URL to view a customised promotional page.
The recipient lists could be as small as 10 or as large as 500, so sending the email from our server wasn’t an option from a performance point of view. In addition we needed to collect analytics (open and views) on the emails. As these emails were for marketing purposes it was important to see how effective they were, for this we needed to know if it had been delivered, opened or had bounced.

We looked at a few services for sending email and decided to use Sendgrid for various reasons; the robust smtp and rest api’s, analytics support and price.

The SMTP api was especially significant to us, as it allowed us to make one api call to send any number of emails. The beauty lay with a custom header that gets sent with the email. This header contains a JSON object of various parameters which meant that we could construct our recipient list, and customisable variables (such as name and link) and send this with our email content only once. Sendgrid would then seamlessly take care of sending the mail out to our recipients with the correct content on our behalf.
As we were building the app using CodeIgniter, using the SMTP api meant that we could use the built in mail class without needing to implement many code changes. There was however one downside in that the class by default doesn’t allow you to set your own custom headers. A bit of tweaking later and I had added a new function that allowed me to pass in custom headers.


public function add_custom_header($header,$content){
$this->_set_header($header,$content);
return $this;
}

I also built a library (based on the PHP example provided by Sendgrid) that allows you to easily add and manage the content of these headers (which I’ll put on github once it’s a bit more polished).

Rather than build a whole library, I combine the creation of the headers with the default mail class which meant that sending out emails was fairly straightforward.

The second aspect of Sendgrid that appealed to us was the various api’s, especially the event api. This allows you to set a notification URL, and the listen out for events. This was great for us as we could get; deliveries, opens, bounces, spam reports and clicks in realtime. The info was posted to a controller which allowed us to easily log the data.

If you’re thinking of integrating with a 3rd party service to send email, i’d definitely recommend using Sendgrid.

Go take a look at the simple example I have put together over on Github.

HydraHack

Just a quick blog post to promote HydraHack, organised by Tom Martin (also of @383project fame).

HydraHack is a monthly meetup for web developers in Birmingham, who enjoy getting together and making things.

If you’re Birmingham based, you should pop along, and if nothing else say hi!

Hello World

I’ve decided to move things around a bit with regards to the name of the blog, and the hosting solution (more on that in a later post).

After all this blog is all about me, and the code that I write, both at work for 383project aswell as personal projects such as my beanstalk command line interface or Geckoboard CodeIgniter library. The whole sizzla thing was left over from Uni, when one of my projects involved creating an online music store for a fictional record label – Sizzla Records.

So, a new name and a new host (this blog is now hosted with @phpfog), but still the same content.

Beanstalk Command Line Interface

It’s fair to say that we love a bit of Beanstalk (affiliate link, gets you 10% off) at @383project. I’ve built tools to help you integrate with Geckoboard, display Growl notifications of your commits and a webapp for deploying and checking your repos. Fellow dev Andy Yates has gone way further and built a native iOS application called MagicBean.

We use Beanstalk on a daily basis, and it forms the centre of our workflow. Developers can easily collaborate on projects, and then when ready seamlessly deploy to a server.

Because of this, we have created a workflow for setting up new web projects which goes a little something like this:

  1. Create a Staging environment on our staging server
  2. Create a Production environment on our production server
  3. Create a Beanstalk repo, and add the staging and production server details
  4. Work on our code and commit (changes get automatically deployed to staging)

Step 3 is the part that is most tedious (we use Plesk on our server so 1 & 2 are pretty straight forward).

As almost every site we build will be staged on our development server on a subdomain of our development domain, the FTP details are always the same (apart from the document root), it seems silly to manually enter these details everytime we need to create a new repo.

Also as most sites are also hosted on our dedicated server the only details that change per site will be the FTP username and password.

This got me thinking; wouldn’t it be great to be able to type

$ beanstalk repo:create test_repo green

And have a Beanstalk account created with trunk, branches and tags set up, aswell as a Staging Server with automatic deployments and a Production Server with manual deployment.

I had a quick search and couldn’t find anything so decided to use the Beanstalk API along with php to write my own wrapper. After taking inspiration from Fire – a command line tool for CodeIgniter, I came up with my Beanstalk command line tool.

This is fairly specific to our own use case at 383project, so I decided to add a few more functions for general use.

Take a look at the source on Github and have a play, i’d love to hear if you manage to use it to save time in your own work flows.

Usage

To use the tool, first download the source from Github, open it up in a text editor and fill in your Beanstalk details. If you plan on using the tool to create release servers then scroll down to line 281 and edit the code with your own server details and then again at around line 339.

Place the file somewhere in your path, or create a folder called bin, in your home directory and add it to your path:

PATH=/Users/user_name/bin:$PATH

Then make the script executable by typing

chmod a+x beanstalk

You should then be able to use

$ beanstalk repo:create test_repo green

To make your life a tad easier!

You can also deploy by typing

$ beanstalk repo:deploy REPO_NAME

You’ll then be prompted through the steps to deploy your code!

CloudControl vs phpFog

When I first saw phpFog announced a while back I was pretty excited – a fully managed and scalable cloud hosting solution built from the ground up for php.

Whilst waiting for a beta invite, I came across CloudControl – a similar service but with a very different approach. This post details my initial thoughts from both services and part 2 focuses a bit more on the technical set up, where I will be creating a very basic CodeIgniter app locally and deploying it to both services to see how much modification is needed from my normal work flow for these new platforms.

For now though these are my initial thoughts on the two platforms.

First Thoughts

Side by side, phpFog has the more visually appealing website, but digging a little deeper seems thin on the tech details (after all this is a scalable cloud solution, i’d expect a bit more on the actual hardware).

CloudControl on the other have all the information that as a developer I need; docs, specs, pricing and contact info. They also have a very well documented Getting Started guide to get you on your way to hosting your first app.

CloudControll – 1, phpFog – 0

Support

I must say, the CloudControl support is second to none and can’t be faulted. Two issues that I had (connecting remotely to a database and setting up an alias) were resolved in around 10 minutes. They have a nifty little chat widget that allows you to chat with a member of staff. The two times I have used it (at completly different times of the day), there has been somebody there who has instantly managed to help me out.

In contrast phpFog use a TenderApp install for their support, I left a ticket but didn’t get a reply (at the time of writing this has been 6 hours). They also have a live chat widget, but the few times that I was online there wasn’t anyone online to answer questions.

Both services do have a phone number to call, however due to neither of them being based in the UK I prefer email/chat to resolve issues.

Purely based on the speed in response to my questions CloudControl has to win here.

CloudControl – 1, phpFog – 0

Documentation

CloudControl has a wealth of documentation on their site, which I fully suggest reading all the way through after you have completed the Getting Started tutorial. The docs are thorough and cover everything you would need to know in order to get your app working.

The docs for phpFog are a little sparse to say the least. There is no quick start guide when rolling a custom install (as opposed to a pre built app).

When using a new platform that is different to the traditional server set up, it’s essential to have as much info as possible.

CloudControl – 1, phpFog – 0

Pricing

CloudControl features a pay for what you use system, where you are charged for the amount of ‘boxes’ that you use. There is also a free package that is limited to one box meaning that you can get an app online for free. They have a very detailed explanation of what a box is and how it is charged plus you can opt for automatic scaling or set a cap to enable you to keep an eye on costs. Pricing is transparant and you can see it before you sign up.

In contrast phpFog features a completly different model; with a monthly base cost. You can also manually increase the number of boxes (thus increasing the costs) within each package. As there is no overview pricing matrix this more than a little confusing. In addition you can’t see the prices until you have created an application, however during the Beta your account is credited with enough money to get a few months usage (although should you really be paying for something in beta anyway)?

As phpFog are still in beta, they are probably still working out their pricing structure, but personally I prefer the fully scalable system of CC, after all – if i’m not using it then why should I pay for it?

CloudControl – 1, phpFog – 0

Platform

There isn’t really a direct comparison that can be drawn here as both systems are quite different in their set up. Without going into too much detail here (this will be in the second post), both systems were easy and straight forward when it came to setting up a database, creating an application and deploying your code.

CloudControl features a command line utility to interact and work with your apps. Once you get used to it, this is actually very nice from a developers point of view as you don’t need to go to a website to administer your application. CloudControl have also thought about the set up from a developer team point of view. They use Git (needs to be enabled as it’s currently in beta), as a version control system. Whilst phpFog also uses Git, the difference is in how your code is deployed. With CloudControl you must manually deploy your code, whilst phpFog automatically deploys your code on each push. A subtle difference, but fairly critical if you want to be in total control over which code gets released.

CloudControl also allows you to easily set up different environments, for example a staging area. I can’t see a way of doing this with phpFog without creating a new app.

In terms of setting up a database, CloudControl requires this to be done via the command line, whereas phpFog automatically creates one for you when you create your app. To administer your CloudControl database requires that you set up a tunnel (they reccomend using sTunnel). Whilst a little fiddly at first, I did manage to connect using SequelPro and could manage everything as I normally would. phpFog features phpMyAdmin to allow you to manage things. I couldn’t find a way to connect remotely however.

CloudControl also features add-ons that allow you to add extra capactity and features to your app. You can also modify any of these add-ons once they have been added (such as adding extra capactity for your databases). This offers intricate flexibility in scaling your app as it grows.

Running cron jobs is a little different, as at present CC don’t have any way to do this (although I have been assured that this is in beta and will be released very soon). phpFog on the other hand does have a method, but it involves you adding your functions into a cron.php file.

phpFog also features a set of pre built apps such as WordPress and Drupal that offer a one click install for the non technical.

Setting up a custom domain was a lot easier with phpFog, either point an A record to their server, or update your name servers to them.

CloudControl was a little more contrived; you need to create an alias for your app, then point a CNAME record to your CloudControlled domain. In addition you needed to verify you owned the domain by creating a TXT record – phpFog was the clear winner here.

CloudControl – 1, phpFog – 1

Conclusion

So after an initial sign up and app deploy CloudControl is the clear winner, however this is only half of the story; how well do these platforms actually perform and how much will I have to change the way I develop in order to use them. Come back for Part 2 where I will create and very basic CodeIgniter app that will write/read from a database, plus write/read from a static test file. I will deploy the same code to both platforms, with the only difference being the database config settings. I’ll also perform an Apache Bench test to gauge (vaguely) how well they perform.

It should also be noted, that phpFog is still in beta, this post isn’t designed to sway your decision in any way and i’m not saying phpFog isn’t any good – these are just my initial thoughts on the two platforms, both have their merits and drawbacks!

CloudControl – 4, phpFog – 1