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.
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 toexpects($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), andwill($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