In defence of deterministic password managers

[Update 30 January 2019 – I made an Ionic mobile app that does just this. πŸ™‚ Read all about it!]

If there’s one thing two decades on the internet has taught me, it’s that techies enjoy binary battles between opposing and equivalent technologies.

iOS vs Android. Vi vs Emacs. Tabs vs spaces. Didactic and fundamentalist exposition is kind of the norm when it comes to these discussions.

One topic I had not expected to see alongside these traditional battlegrounds is the nature of the tool one uses to manage distinct passwords across web sites. Until now.

Continue reading

Multi-threaded quicksort! In PHP!

Yeah! In PHP!

Why would you do this?

Well, I went to a PHP meetup presenting some common implementations and comparing them to the speedy native PHP implementation of sort() and related functions.

I figured that while efficient sorting isn’t the most common use case for PHP – and in a web context you often don’t want to let each user spin up numerous threads – for command line cases this approach should be able to provide a real performance boost.

In particular, the already-PHP-favoured quicksort algorithm works with a divide and conquer approach that should be perfectly suited to divvying up work between threads.

Continue reading

rclone to S3 Glacier class: A remote backup horror/fairy tale

Update 3 May 2020: after a bit of a requests bill spike, I had another look at rclone’s options and the S3 storage classes. You can now directly create backup objects with Intelligent Tiering by setting the backend storage_class, which in theory should be much cheaper for frequent backups. I’ll report back on whether it really is!

Update 10 Apr 2021: I think the answer to this is… maybe?! Costs are very slightly lower on average but this also coincides with several months with fewer backups. One thing that is noticeable so far is that the variation is less – I’ve not hit such a big subsequent cost spike again. But this could be down to my behaviour as much as the tiered pricing’s, and of course your mileage will certainly vary!


I recently tried out a new remote backup approach.

Whether you consider it a success will probably depend on your quantity of files, and how much money you have lying around for month #1.

Continue reading

Twig cache permissions for Apache + cron on CentOS

I probably should have seen this coming, but when introducing Twig to a non-Symfony project, it hadn’t occurred to me to expect the same permissions dance that Symfony cover helpfully in their setup guide.

Having built a shiny new system that uses the same template cache for web requests (handled by the Apache user) and emailed reports (handled by another user via cron / command-line invocation), of course I hit exactly the same problem that those steps avoid. If you share any templates across the two users’ remits, eventually one will want to write to an existing cache file generated by the other user. It won’t have write permission, and Twig will freak out:

Continue reading

Facebook + Cordova + AngularJS encapsulation is no more?

Just a quick update following my previous post about using this Cordova Facebook plugin neatly with Cordova & AngularJS: unfortunately it seems EasyFB no longer supports the plugin because the plugin’s creators have decided to change the API and drop the previous transparent compatibility with Facebook’s JS SDK.
Continue reading

Phonegap, AngularJS & Facebook fun!

Update 6 August 2014: If you want to use up-to-date plugins, please beware the EasyFB approach isn’t going to work any more, so you might not get much out of this post. πŸ™

I thought that getting Phonegap, AngularJS and Facebook working together couldn’t be a big jump from the simple quickstart guides available for each of those components. This was probably naΓ―ve.

It’s a nightmare

If any part of the above are new to you, starting out can be confusing and poorly documented. If, like me, you’re a newbie with both Phonegap and Angular… it’s worse.

Perhaps it’s because most of the constituent parts are changing so fast at the moment – despite myriad posts out there on each of the technologies involved, it took me absolutely ages to get it all working as I wanted, and even longer to replicate the steps reliably enough to write this!

As I never really found an article or post with my exact goals and a full explanation all in one place, hopefully this one might make the process less of a time sink for anyone taking the same route.

Continue reading

Retrieving a user’s friends with PHP & the latest Facebook API

I’ve not had to do much recently with Facebook APIs, which I found to be pretty poor a few years ago. However with some projects coming up which will need FB integration and the announcement this week that lots of things are changing, I thought it might be worth getting myself up to date and seeing if anything has improved.

To be fair, today’s PHP SDK looks to be miles ahead of what they were providing in 2011. But for all that the introduction of proper API versioning seems like a positive step, it doesn’t look like they waited to get the docs finished before announcing these changes! I found some PHP SDK documentation links broken (e.g. to the fundamental GraphObject!), and several features are only documented for PHP if you look at deprecated versions, which have a completely different instantiation style.

So on to my first post here! It’s not a very hard problem but it took me a little while to figure out how to list a user’s friends the ‘new way’.

Show me the code

Let’s assume you already have a FacebookSession called $fbSession, as that part is fairly well documented for the latest SDK. To get your authenticated user’s friends’ names in an array $this->_friends (keyed on user ID), you’d do:

$friends = (new FacebookRequest($fbSession, 'GET', '/me/friends'))
    ->execute()
    ->getGraphObject(GraphUser::className())
    ->asArray();

foreach($friends['data'] as $friend) {
    $this->_friends[$friend->id] = $friend->name;
}

This is working for me with v4.0.0 of the PHP SDK and the v2.0 API. I explicitly specified the API version in my FacebookRequest instantiation (not shown), but new apps should default to v2.0 anyway.

Since I didn’t find docs which even explained that I should look at ['data'] (I got to this through printing objects and trial & error), I’m unclear whether it’s possible to get actual objects for the friends listed and examine further properties. Given the new focus on privacy, with app-scoped user IDs and user-controlled sharing settings for each app, I suspect this may be all you get – but any comments would be helpful.

Where are your friends tonight?

Finally, don’t be surprised when your friend list is a bit shorter than before! The new API only returns friends who are also using your app. Perhaps a headache for some developers but I think a positive step for users concerned about data mining and which pieces of their information are being connected by marketers.

A cynic could argue it’s primarily an opportunity for Facebook to become the only ones who can connect those dots and to make more cash in the process – but I’d still rather have it this way than trust every single app to treat everyone’s data responsibly.