CIRP: iPhone 6 Plus sales are jumping šŸ”—

The Loop:

iPhone 6 sales dropped from 56% down to 53% and iPhone 6 Plus sales jumped from 22% to 29%. The survey is based on 500 Apple customers. Large enough to be a trend indicator, small enough to have a significant margin of error.

I am surprised thereā€™s a jump in iPhone sales in the Marchā€“June quarter, but Iā€™m not surprised that the 6 Plus is the one that increased.

I was one of those who laughed at the larger size and wondered who would buy such a thing. But turns out, I got it wrong. From what I understand, the Plus is better.

I still prefer the iPhone 5 generation size, but when it comes between the iPhone 6 and 6 Plus, the larger one is easier to use. The middle ground of the iPhone 6 compromises too much, and it still doesnā€™t feel comfortable to hold (also, itā€™s too easy to drop).

If given the choice again, hands down Iā€™d pick the Plus.

Why the Great Glitch of July 8th Should Scare You šŸ”—

Zeynep Tufekci, on why we should worry about the state of software:

From our infrastructure to our privacy, our software suffers from ā€œsoftware sucksā€ syndrome which doesnā€™t sound as important as a Big Mean Attack of Cyberterrorists. But it is probably worse in the danger it poses.

I agree. Duct tape fixing duct tape, and taking short cuts because it has to make money (and never fixed because of ill thought out cost-benefit analysises) is a big problem that will only get worse before it gets better if we arenā€™t careful.

As a profession, weā€™re lucky that we have relativity lax regulation. And we are a massively growing profession which is moving at an incredible pace.

Yes, we did things badly in hindsight, I bet most engineers look at work they did only six months ago and cringe.

But we canā€™t let quality be a second class citizen, and we have to keep things maintained: just as we do with buildings, roads, and cars.

It shouldnā€™t be ā€œmore glamorousā€ to be working on a brand new greenfield project. Me, I love working my skills on keeping things ticking, pushing systems to its limits then putting the bits back together again.

Letā€™s hope Iā€™m not a dying breed.

Speaking: PHPNW

On 7th July at PHPNW.

Testing can be boring, but thereā€™s also some interesting ways you can check your application. Iā€™ll be going through some interesting tools and techniques, showing them in action, and who knows ā€” maybe weā€™ll break something while we do so.

Slides

What Steve Jobs Knew That the Rest of Us Didn't šŸ”—

Michael E. Gerber, on Steve Jobs:

What did he know that the rest of us did not? My answer was simply that Jobs didnā€™t actually know more than the rest of us; he simply cared more.

Bingo.

ā˜…  Apple Watch In Review

Itā€™s been around 6 weeks since Iā€™ve had my Apple Watch. Whilst not perfect, Iā€™m still very happy with it. Hereā€™s a rundown of my thoughts.

Iā€™ve got the 38mm Sport edition, with the black sports band. Itā€™s a lot smaller than I imagined it would be, which is for the better. This means that it doesnā€™t have the bulk of other smart watches, and after the first few days I donā€™t feel conspicuous at all.

Not only does it look good, it feels really nice too. In fact, you forget itā€™s even there. There is a bulge at the bottom where the sensors sit, which I thought may be a problem, but that isnā€™t the case at all.

This is something I never thought would be said in a watch review: the sports band is really quite soft too. Itā€™s firm enough to feel secure, but also smooth so that the last thing youā€™re thinking as you put it on is ā€œIā€™m basically wearing a rubber band around my wristā€.

I have to admit, the box was a little bigger than I was expecting: the Watch comes in a case just like any other watch on the market. Unlike other smart watches, this is not a gadget. Apple clearly wants this to be an accessory: using technology to change how we think of watches.

And what a watch it is. Granted, this isnā€™t something that is kept for generations ā€“ I expect the Watch to have an update cycle of about five years ā€“ but I truly think that this is a watch wearerā€™s watch. Unlike the Pebble, which doesnā€™t really have much in terms of quality watchfaces, the Apple Watch has carefully designed faces that look beautiful and are genuinely useful.

But what makes this better than a regular watch, and indeed other smart watches, is the notifications. Within minutes I had muted all sounds, and had turned off both sound and vibration on my phone. The taptic engine is very subtle, and it really does feel like someone tapping you on the wrist. It feels nice, and it doesnā€™t disturb you or anybody else.

One thing, however, that does make it frustrating as a watch is Activation on Wrist Raise. With a classic watch, the time is always there for you to glance at. The Apple Watch requires you move your wrist, then wait, to see the time. The gesture detection isnā€™t quite right either, and so you find yourself exaggerating your arm movement, especially when wearing a coat.

The slight sluggishness is a problem in other areas, too. Apps can often take a noticable time to load; even the glances can take time for the data to appear. But being a first generation device I canā€™t see this being a problem for too long.

Sluggishness aside, compatibility with apps and services is at a high level, especially considering the watch has only been on general sale for a couple of months. Requiring a pairing with an iPhone has been a really smart move: Watch apps can talk to Phone apps, which means that any data you can access on your phone you can access on your wrist.

However, the best integration so far in my book has to be with Health. I put the activiy rings as a complication on my watchface, and whenever I look at my Watch, I know how active I am being, and how close I am to my goal. This is the feature which Iā€™m sure I would miss if I had to do without my Apple Watch.

So, would I recommend it? Absolutely. Especially if you are a watch wearer and a heavy user of iPhone apps, the Apple Watch is a genuinely useful second screen, and turns the timepiece on your wrist into a ā€œWatch Plusā€.

Itā€™s a purchase I donā€™t regret at all. I wouldnā€™t go back to my Pebble Watch, and certainly wouldnā€™t go back to a regular watch. The Apple Watch gives me far too many advantages that improves my life in small ways.

But then again, Iā€™m a gadget lover. And if youā€™re not into gadgets, Iā€™m not sure that you will see the point behind the Apple Watch. And thatā€™s ok: itā€™s not for everybody.

Achieving the Ken Burns effect using CSS

The Ken Burns effect is a common technique used in video-making where a photograph or image is zoomed in and panned across, to make for more interesting visuals.

This effect can now be achieved using CSSā€™s animations properties. Iā€™ve made up some example code to give a basic demonstration of what can be achieved.

To be able to pan across an image, we would need to use a size thatā€™s bigger (either taller or wider) than weā€™ll be showing on the page, and we need to use CSS to tell the browser not to try and squeeze the image to the size we gave it. We use the object-fit property alongside setting a width, height, and overflow property to do this:

img:hover {
    object-fit: cover;
    overflow: hidden;
    width: 300px;
    height: 300px;
}

Once weā€™ve done that, we need to do the effect! This is achieved using CSS animations. Here, Iā€™ve used CSS classes which I give the image to create two different animations depending on whether the image is a landscape or portrait image: each will pan in a different direction (across or up).

.portrait {
    animation: portrait 30s;
}
@keyframes portrait {
    from {
        object-position: bottom;
    } to {
        object-position: top;
    }
}

.landscape{
    animation: landscape 30s;
}
@keyframes landscape {
    from {
        object-position: left;
    } to {
        object-position: right;
    }
}

Notice that Iā€™ve used unprefixed attributes here, but some browsers may need to be prefixed, or may not support either animations or object-fit.

Mocking in phpunit

To test a class in PHPUnit, itā€™s easier if you use dependency injection which enables you to mock other classes that we arenā€™t interested in testing (such as your database layer). So for example, instead of writing code like this to test a made-up User class:

class User() {
    private $db;

    function __construct()
    {
        $this->db = new Database;
    }

    function getUserData()
    {
        return $this->db->getUserData();
    }
}

$user = new User();

We can pass in the database class instead:

class User() {
    private $db;

    function __construct($db) {
        $this->db = $db;
    }

    function getUserById($userid) {
        return $this->db->getUserData($userid);
    }
}

$db = new Database; $user = new User($db);

This means that we can mock the Database object when weā€™re testing the User class, and pass the former into the latter. We do this as PHPUnit wonā€™t override the new keyword.

In PHPUnit, itā€™s a case of creating the class but in place of using the new keyword we use a slightly longer one instead:

$mockDb = $this->getMock( 'Database', array('getUserData') );
$mockDb->expects($this->any())
                      ->method('getUserData')
                      ->with('joebloggs')
                      ->will($this->returnValue(
                          array('userid' => 'joebloggs', 'name' => 'Joe Bloggs')
                 );

$user = new User($mockDb);
$this->assertEquals( $user->getUserById('joebloggs'), array('joebloggs', 'Joe Bloggs') )

In a nutshell, those two commands says what the class should be, and what the method should expect and return respectively. To break down what each bit of the two commands do:

  • getMock() is saying mock the class given in the 1st parameter, and we want to return given values for the methods given in the array in the 2nd parameter

  • The second command has a bit more too it. expects($this->any()) will mean that it doesnā€™t matter whether the method gets called or not: changing it to expects($this->once()) will mean that if the method isnā€™t called (or is called more than once) the test will fail

  • with() is the parameters that you should expect to be passed in (which is a good way to check that the parameters thatā€™s being passed into a particular method are sensible), and will($this->returnValue()) is what you want to give as the known return value, for when you do your test

Of course, thereā€™s much more you can do with PHPUnit mocking. The documentation is a pretty good start to find out what else is there.

Setting the proxy for command-line OS X

In OS X, itā€™s pretty simple to set a Location to set a proxy for whenever youā€™re somewhere you need to use one

However, this doesnā€™t affect some commandline applications, such as Homebrew. If you want to send this through a proxy, youā€™ll have to edit .curlrc to read something like

proxy = proxy.example.com:8080

Files not loading in a Virtualbox virtual machine

Every so often, randomly I see a problem where a virtual machine will only partly load a CSS or Javascript file, and when you load it in the browser it will have a bunch of strange unicode characters in there

We even saw it in joind.in

The fix is fairly simple - just edit your vhost configuration and add the following lines:

EnableMMAP Off
EnableSendfile Off

Switching branches in Subversion without losing changes

The problem: you want to switch branches in Subversion, but youā€™ve got changes in your local code that youā€™re not ready to commit

The solution: export a patch that you can store somewhere safe (or even commit into the repo so others can see it or work on it)

To export all changes, use svn diff to create a patch file:

svn diff > fix-that-annoying-bug.diff

As a sidenote, if Iā€™m using a bug tracker, I like to put the bug ID in the filename: not only does this keep all the different projects together, it makes it easy to know what exactly the code changes does:

svn diff > myproject-1234-fix-that-annoying-bug.diff

From there I can revert all changes and switch branch:

svn revert -R . svn switch http://svn.example.com/my-new-branch/

Once Iā€™m done with the new branch and want to go back, and assuming Iā€™ve committed all my changes I switch back to my old branch:

svn switch http://svn.example.com/my-original-branch/

And I import my original changes patch file to start work again, carrying on from where I left off:

patch -p0 -i fix-that-annoying-bug.diff