Categories
development php

Mockery (test doubles/mocking dependencies)

[This is a relatively old post I think I forgot to publish….] Previously, I’d only used PHPUnit’s mock implementation; however lately I’ve been exposed to Mockery. While they both achieve broadly the same result (at least from my point of view), here’s an example of how to mock dependencies with Mockery. Class to test: class […]

Categories
bash development linux

curl, jq and slightly dynamic input to a service

I keep forgetting the syntax for these two things, so there’s a chance writing it here will help me remember. Possibly of use/relevance for: elasticsearch or Debezium….

Categories
development mysql php postgresql

PostgreSQL unbuffered queries and PHP (cursors)

From using MySQL, I’ve used the ‘unbuffered queries‘ feature a number of times. It’s where you don’t fetch the entire resultset into memory at once – which is necessary if you’re retrieving more data than you have memory available. If’s often also generally gets results/data back to you sooner.

Categories
development

vagrant commands for the lazy and forgetful

Vagrant commands : vagrant up  – aka “clocking on at work, time to boot up the VM” vagrant status – aka “did I leave that VM running last night?” vagrant halt – aka “time to go home or change project” vagrant destroy – aka “VM is broken; kill it with fire and deploy a virgin […]

Categories
development php

Checking PHP code for compatibility issues

One project I occassionally hack on is Xerte Toolkits. Yesterday on the mailing list it came up that someone was trying to use XOT with PHP4. After getting over some initial shock that people still use PHP4 (it was end-of-lifed in August 2008) I wondered how easy it would be to check the status of […]

Categories
development php

Netbeans vs Vim … round 1 … fight

So, I think I’ve changed ‘editor’. Perhaps this is a bit like an engineer changing their calculator or something. For the last 10 years, I’ve effectively only used ‘vim‘ for development of any PHP code I work on. I felt I was best served using something like vim – where the interface was uncluttered, everything […]

Categories
development php

SQL Injection with added magic_quotes assistance (the joys of legacy code maintenance)

  Sometimes you really have to laugh (or shoot yourself) when you come across legacy code / the mess some other developer(s) left behind. (Names slightly changed to protect the innocent) class RocketShip { function rahrah() { $sql = “insert into foo (rah,rahrah,…) values ( ‘” . $this->escape_str($this->meh) . “‘, …… )”; mysqli_query($this->db_link, $sql) or […]

Categories
development performance php

Zend_Cache – automatic cache cleaning can be bad, mmkay?

$customer uses Zend_Cache in their codebase – and I noticed that every so often a page request would take ~5 seeconds (for no apparent reason), while normally they take < 1 second … Some rummaging and profiling with xdebug showed that some requests looked like : Note how there are 25,000 or so calls for […]

Categories
development php

PHP Serialization & igbinary

Recently I’ve been trying to cache more and more stuff – mostly to speed things up. All was well, while I was storing relatively small numbers of data – because (as you’ll see below) my approach was a little flawed. Random background – I use Zend_Cache, in a sort of wrapped up local ‘Cache’ object, […]

Categories
development javascript

Javascript Linting…

Suffice to say, my minions write a quantity of Javascript. And testing it isn’t all that easy. While rummaging the internet, I came across @NeilCrosby‘s FrontEndTestSuite which aims to automate e.g. w3c validator checks and so on – there will be more on that later I suspect once I get it working. Anyway, the first […]