Lunchtime Lounger

Recently I have been experimenting with Spotify things for a future project and figured it was about time I made a Spotify spin-off of Friday Lunchtime Playlist. Lunchtime lounger will be an evolving playlist, regularly updated with tracks I find on my web wanderings. Who knows, it may even double my listenership.

Read More

Simple IP Access Control

I just wrote this very simple IP access control script, and thought I would share it as it’s handy to put in front of sites you are working on but don’t really want others to see. It’s really not very sophisticated, that is intentional, it’s just designed to hide a work in progress site with something like a splash screen but allows people to grant themselves access to see the site in progress (if they know the required url to grant themselves access).

Read More

PHP Enforce Errors

When debugging code I always want to force PHP to display all the errors, including any warnings so I can make sure my code isn’t doing anything unexpected. Its something I do so often that I should know the two lines of code off the top of my head. If I really thought about it I probably do but sadly Google + Copy / Paste is actually quicker than typing it out. So as much for my own benefit as anyone elses, here are the two lines of code I use over and over:

ini_set('display_errors', '1');

Read More

AngularJS nested controllers

When you are new to Angular it can seem very confusing. One thing that gets especially perplexing is scope, where variables in your project can be accessed. This post looks at nested controllers and how that affects scope and we also look at whether they are passed by reference or by value between controllers.

We’ll use a very simplistic example:

Here we have defined the name variable in the parent and displayed it in both parent and nested controllers. What you will notice is any variable in the parent is automatically available to the child. However, be careful, if you are passing anything that isn’t an object then it is passed by value so if you try and change its value within the nested controller that change doesn’t propagate to the parent.

Now lets look at a different example, encapsulating that name variable into an object:

You will now notice that when you edit the name, both the nested controller and the parent controller are updated. This is because objects are always passed by reference, so in summary anything you want to persist between controllers should be encapsulated within an object first.

Read More