Continuous iPhone Application Integration with my buddy Hudson and Xcode… and then some
Jul 30th
So you wanna take your iOS development to the next level? I’ve got just the thing for you!
Continuous integration allows you to continuously create up to date versions of your application whether it be iPhone, Android, PHP or JS and deploy them to the appropriate platforms as well as run other tasks depending on whether the application built successfully. It is the ultimate development tool and is the last line between you and your production application. The days of you deploying applications directly from your desktop are gone.
CI works extremely well with large groups using SCM or with solo acts who want to maintain their code and automate builds and deployments. The days of “well it works on my machine” are over!
At fishrod interactive we wanted to take this to the next level. We’ve acquired a mac mini and wanted to turn it into something special… Here are our requirements.
- When a developer check something into SVN
- The iPhone application should be built on our CI server
- During the build any unit tests should be run
- If the unit tests fail then the build should fail
- On a successful build
- The iPhone application should be deployed to the CI’s protected web directory
- Developers should be able to download it for beta testing
- The iPhone application will also be added to iTunes so that our dev iPhone/iPad and iPod touch always has our latest apps for demo
- The iPhone application should be deployed to the CI’s protected web directory
We like to share… so this is how we did it!
More >
New Toys, Old Thinking – Advertising in a new age
Feb 25th
As a content provider a switch or move towards distributing content over the internet is quite a big thing, you can leverage the power of the internet, the extra input devices such as built in cameras, microphones and the standard keyboard and mouse.
With that, one would assume that you could offer a much richer platform for your advertisers and far more entertaining advertising content for your viewers, rather than disliking advertising breaks and finding ways to avoid them by installing various plugins for their web browsers they could at some point enjoy them.
The BBC have been great pioneers in the UK for experimenting with online distribution of their content. Most recently they have integrated twitter into their subtitles so that rather than users sending a text message into a show with their thoughts, viewers simply tweet with a hash tag of “bbcrevolution” and their thoughts are displayed as subtitles whilst the show is being broadcast on BBC iPlayer. (via http://www.rsc-ne-scotland.org.uk/mashe/2010/02/twitter-powered-subtitles-for-bbc-iplayer/)
Examples like this are great, but it should be down to the advertisers and content providers to communicate with each-other to develop a platform that benefits both the user, advertisers, the products and services that are being advertised and the content providers.
The current way of thinking is that you broadcast a program, and you allocate time slots in-between the breaks to place advertising, this is great, and it works. But why? Research at the London Business School has found that most people don’t actually sit through and take in the advertising breaks, they ‘chose one of six activities: social interaction, reading, doing a chore, surfing channels, watching the television and interacting with adverts.’ (via http://www.independent.co.uk/news/media/what-viewers-really-do-during-commercial-breaks-596691.html). I haven’t found any research but I assume that the same applies to online, but what makes online so different from advertising on TV? Technology would be the first thing that springs to mind, content providers use the same types of distribution platforms, these are primarily Adobe Flash and Silverlight.
What confuses me is the lack of interest in experimenting with these platforms, they were never intentionally made just to distribute video, they were created to offer ‘breakthrough Web experiences to over 99% of Internet users.’ (via http://www.adobe.com/products/flashplayer/) the flash player intro video says it all.
In my experience, it doesn’t take much to produce an interactive flash advertisement that’s enjoyable for the viewer, why can’t advertisers spend their £1.752bn (via http://news.bbc.co.uk/1/hi/business/8280557.stm) advertising budgets on creating good interactive advertisements for content distributed online? Or is this really the root of the problem? Maybe the problem is that content distributers don’t have a platform that can offer rich advertising experiences for the online viewer, I’m sure most viewers would find playing tetris or breakout for 30 seconds with the end result being a special offer for cheap car insurance far more entertaining over watching another annoying go compare advert.
Or maybe the problem’s even worse, advertisers simply can’t get their head around how to advertise on the current online distribution platforms, not realising that the internet is non-linear and that people often don’t/won’t do what we expect them to do with our content.
We really need new thinkers in the industry, advertising has changed from advertising things that people need to things that people want, people (I’ve switched to people here over viewers as I’m looking at it from another perspective) can switch channels, or watch your programs on websites such as surfthechannel.com where there are no advertising breaks and no restrictions of what you can watch and when. Feel free to discuss this topic, any input would be much appreciated.
Setting up Zend Framework from PEAR
Feb 18th
Alright, so I’ve just changed my VPS provider because 1&1 are shit and my buddy Andy runs a good hosting gig http://www.theserve.com/. We’re running our stuff one one of his VPS’s until September and will more than likely move to a dedicated server once we move office. Any way!
One of the teething issues I have with Zend Framework is that with every ZF project I put up on the server I’ve had to include a distro of ZF in the library folder, or constantly keep a centralised version up to date by downloading and overwriting… Until now… There’s an unofficial pear channel that will let you install and update ZF with 1 command… Here’s what you need to type in terminal…
pear channel-discover zend.googlecode.com/svn pear install zend/zend
That’s it, the Zend Framework will be installed and accessible from every website, as with PHP, make sure you only update to the latest version if you’re 100% sure that all of your web applications will work.
There has to be an easier way :(
Feb 18th
So I’m working on a project, and I want to find all of the rows that don’t have a row in it’s related table using Zend_Db_Table_Select… Simple right? Not really
. In theory this would be the query that I would write…
SELECT author.id FROM author LEFT JOIN project ON project.author_id = author.id WHERE project.author_id IS NULL ORDER BY RAND() LIMIT 1
After toying with Zend_Table for a while I’ve managed to figure out how to do it…
/**
* Fetches a random author who has not had a project assigned to them
* @return Ambigous <Zend_Db_Table_Row_Abstract, NULL>
*/
public function findRandomNull(){
$authorModel = $this->getDbTable();
$select = $authorModel->select()
->setIntegrityCheck(false)
->from('author')
->joinLeft('project', 'project.author_id = author.id', array())
->where('project.author_id IS NULL')
->order('RAND()');
return $authorModel->fetchRow($select);
}
Which will produce the following SQL
SELECT `author`.* FROM `author` LEFT JOIN `project` ON project.author_id = author.id WHERE (project.author_id IS NULL) ORDER BY RAND() ASC
ZEND FRAMEWORK 1.10 IS OUT!
Jan 28th
Zend Framework 1.10 is out, and with it a bunch of new features, and for once… the documentation is VERY helpful! For those having problems getting their head around Zend_Acl check out this tutorial… http://framework.zend.com/manual/en/learning.multiuser.authorization.html
Zend_Acl + Zend_Auth + Zend_Controller_Plugin = HAPPY!
Aug 3rd
Ok, so after playing around with Zend_Acl for what seems like forever I’ve finally cracked what feels like the perfect marriage between Zend_Acl, Zend_Auth and an application.
You may ask yourself, why the fuck is it so hard? The simple answer is this…
Zend_Aclwas designed in such a way that it does not require any particular backend technology such as a database or cache server for storage of the ACL data. Its complete PHP implementation enables customized administration tools to be built uponZend_Aclwith relative ease and flexibility.
Ease and flexibility my arse! This is the reason quite a few Zend Developers are just pulling their hair out day in day out. The documentation at zendframework.com by far is the most confusing I’ve ever seen and quite a bit of it is outdated. It’s actually easier reading through the API documentation and trolling through the code than it is reading this stuff. I truelly feel sorry for people using ZF in anything less than ZendStudio or an IDE without the code completion. Authentication and Authorisation are pretty key aspect of any application, if they made it simple for people to set up they wouldn’t need a 2 paragraph section saying how to store the data by serializing it. Any way, rant over!
The Solution
There are many ways to store the ACL data for persistence, but I think that’s the problem. As soon as you hear the words store and persistance the bells and whistles in your head are screaming at you telling you to store it in a database just like in CakePHP. For months I’d been trying to work out a way to do this until last night.
Why not put this in the application configuration (application.ini)? This is application configuration after all! What’s the point in taking a hit on your database every time you want to check authorisation and then having to write caching code to counteract that? It’s counterproductive and not cost effective (thanks Kennedy stole your phrase).
We can then read the configuration from ini file which contains all of our Resources and Roles.
To begin I set my self some conditions:
- Whatever the solution is, it has to be decoupled from the rest of the application apart from the models used for the user obviously.
- It has to be piss easy to implement
- It has to be so easy to implement my mum could do it!
PHP Variable Variables
Aug 3rd
Whilst I don’t advocate assigning variable variables, there are times when you need to create variables in PHP dynamically.
What is a Variable Variable?
A variable variable is a variable that can be set dynamically. For instance the normal way to create a variable in PHP would be:
$foo = 'bar';
But what happens when you’re setting a variable dynamically, i.e. it doesn’t exist already and it’s dependant on user input or an unpredictable event? The solution… a Variable Variable
$foo = 'bar'; $$foo = 'hello'; echo $bar; // this will output 'hello'
This may seem useless to you but after just over 5 years of programming I’d finally found a sane some what safe use for it. I had an object that has a property that contained an array of data, I wanted to be able to access that data from within an included file in my function. To do this I had to assign a load of variables that were dynamically set within the object… you know what, let me just show you!
class Template {
protected $variables = array();
public function set($key, $value){
if($key === 'this'){
throw new Exception('Key cannot be set to "this"');
}
$this->variables[$key] = $value;
}
/**
* Outputs the fully rendered view
*
* @param bool $output
*/
public function output($output = true){
$this->_loadTemplate();
$this->output = ob_get_clean();
if($output === true){
echo $this->output;
}
}
private function _loadTemplate(){
foreach($this->variables as $key => $value){
$$key = $value;
}
require_once 'layout/' . $this->layout . '.phtml';
}
}
So now in my layout, instead of having to do this to get my template variables..
<?php echo $this->variables['foo'] ?>
I can use this
<?php echo $foo; ?>
All done, also as a side note, people who use
<?=$fool; ?>
to output content, stop it! You’re shooting your self in the foot, when you migrate to a server that doesn’t support short tags and you can’t change it, you’ll be fucked and annoyed!
Use
<?php echo $foo; ?>
Instead, the extra key strokes saves the weeks of headache!
JS – Adapting to the situation (smart coding) with Portlet’s
Aug 3rd
Preface
For the past few months I’ve been workin with a content management portal to deliver my XHTML/JS/CSS I can’t stress how big a pain in the arse this is, as with any CMS there are limitations in the way that it works and problems when you try to use it for more than what it’s really made for. Limitations of a CMS can include:
- not being able to add code/css to the header
- the CMS just spitting out any old JS/CSS in the HTML
- HTML not being formatted correctly, or just spitting out random XHTML tags
The list could go on, but I’m too tired to really carry on. It puts a big downer on you most of all when you’re so anal that all of your HTML is well formated and perfectly indented, only to find when the site goes live, all of your code is on one line or it looks like it’s been run over by a bus.
My main concern with coding for CMS’s that use portlet’s is the simple fact that each portlet is in essence it’s own self contained application/controller. It becomes a pain when you have to constantly check to see whethter a portlet exists in the DOM on runtime.
How can you work around this? Think like a CMS. You might be thinking, what the f**k is he talking about? The simple solution is to adapt the way you code to suit the CMS. Instead of having one big JS file for a page or site section, seperate your code into small chunks, this will also help you unit test your code which I’ll come to a bit later.


